QXmlSchema Class Reference
[QtXmlPatterns module]
该QXmlSchema类提供了一个W3C XML模式的加载和验证。More…
Methods
__init__ (self)
QUrl documentUri (self)
bool isValid (self)
bool load (self, QUrl source)
bool load (self, QIODevice source, QUrl documentUri = QUrl())
bool load (self, QByteArray data, QUrl documentUri = QUrl())
QAbstractMessageHandler messageHandler (self)
QXmlNamePool namePool (self)
QNetworkAccessManager networkAccessManager (self)
setMessageHandler (self, QAbstractMessageHandler handler)
setNetworkAccessManager (self, QNetworkAccessManager networkmanager)
setUriResolver (self, QAbstractUriResolver resolver)
QAbstractUriResolver uriResolver (self)
Detailed Description
该QXmlSchema类提供了一个W3C XML模式的加载和验证。
该QXmlSchema类加载,编译和验证,可以进一步通过用于XML实例文档验证的W3C XML Schema文件QXmlSchemaValidator。
下面的示例演示如何从网络加载一个XML Schema文件,并测试它是否是一个有效的架构文档:
[QUrl]($docs-qurl.html) url("http://www.schema-example.org/myschema.xsd");
QXmlSchema schema;
if (schema.load(url) == true)
qDebug() << "schema is valid";
else
qDebug() << "schema is invalid";
XML Schema Version
这个类是用来表示符合的模式XML Schema1.0规范。
Method Documentation
QXmlSchema.__init__ (self)
构造不能使用,直到无效,空架构load()被调用。
QUrl QXmlSchema.documentUri (self)
[
返回架构的文档URI或空的URI ,如果没有模式已定。
bool QXmlSchema.isValid (self)
返回True如果这个模式是有效的。失效模式的例子是那些包含语法错误或不符合W3C的XML Schema规范。
bool QXmlSchema.load (self, QUrl source)
]($docs-qurl.html)
此套QXmlSchema以从加载的模式_source_URI。
如果架构is invalid,false
返回和行为是未定义的。
例如:
[QUrl]($docs-qurl.html) url("http://www.schema-example.org/myschema.xsd");
[QXmlSchema]($docs-qxmlschema.html) schema;
if (schema.load(url) == true)
qDebug() << "schema is valid";
else
qDebug() << "schema is invalid";
See also isValid( ) 。
bool QXmlSchema.load (self, QIODevice source, QUrl documentUri = QUrl())
此套QXmlSchema从读取架构source设备。该设备必须已经打开了至少QIODevice.ReadOnly。
documentUri表示从所获得的模式source设备。它是架构的基础URI,它在内部使用,以解决出现在架构相对URI ,以及消息的报告。
If source is null
或无法读取,或者如果documentUri是不是一个有效的URI ,行为是未定义的。
如果架构is invalid,false
返回和行为是未定义的。
例如:
[QFile](qfile.html) file("myschema.xsd");
file.open([QIODevice](qiodevice.html).ReadOnly);
[QXmlSchema]($docs-qxmlschema.html) schema;
schema.load(&file, [QUrl]($docs-qurl.html).fromLocalFile(file.fileName()));
if (schema.isValid())
qDebug() << "schema is valid";
else
qDebug() << "schema is invalid";
See also isValid( ) 。
bool QXmlSchema.load (self, QByteArray data, QUrl documentUri = QUrl())
此套QXmlSchema从读取架构data
documentUri表示从所获得的模式data。它是架构的基础URI,它在内部使用,以解决出现在架构相对URI ,以及消息的报告。
If documentUri是不是一个有效的URI ,行为是未定义的。
如果架构is invalid,false
返回和行为是未定义的。
例如:
[QByteArray](qbytearray.html) data( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<xsd:schema"
" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\""
" xmlns=\"http://qt.nokia.com/xmlschematest\""
" targetNamespace=\"http://qt.nokia.com/xmlschematest\""
" version=\"1.0\""
" elementFormDefault=\"qualified\">"
"</xsd:schema>" );
[QXmlSchema]($docs-qxmlschema.html) schema;
schema.load(data);
if (schema.isValid())
qDebug() << "schema is valid";
else
qDebug() << "schema is invalid";
See also isValid()和isValid( ) 。
QAbstractMessageHandler QXmlSchema.messageHandler (self)
返回处理这个编译和验证消息的消息处理程序QXmlSchema。
See also setMessageHandler( ) 。
QXmlNamePool QXmlSchema.namePool (self)
返回此名称池QXmlSchema构建names。有没有setter的名字池,因为混合池的名称会导致错误,由于名称的混乱。
QNetworkAccessManager QXmlSchema.networkAccessManager (self)
[
返回该网络管理器,或0 ,如果它没有被设置。
]($docs-qnetworkaccessmanager.html)
See also setNetworkAccessManager( ) 。
QXmlSchema.setMessageHandler (self, QAbstractMessageHandler handler)
更改message handler这QXmlSchema至handler。该架构将所有的编译和验证消息,此消息处理程序。QXmlSchema不采取所有权handler。
通常情况下,默认的消息处理就足够了。它写的编译和验证消息的stderr。默认的消息处理程序,包括颜色代码,如果stderr可以使色彩。
When QXmlSchema电话QAbstractMessageHandler.message( ) ,参数如下:
message() argument | Semantics |
---|---|
QtMsgType type | Only QtWarningMsg and QtFatalMsg are used. The former identifies a warning, while the latter identifies an error. |
const QString & description | An XHTML document which is the actual message. It is translated into the current language. |
const QUrl &identifier | Identifies the error with a URI, where the fragment is the error code, and the rest of the URI is the error namespace. |
const QSourceLocation & sourceLocation | Identifies where the error occurred. |
See also messageHandler( ) 。
QXmlSchema.setNetworkAccessManager (self, QNetworkAccessManager networkmanager)
设置网络管理员manager。QXmlSchema不采取所有权manager。
See also networkAccessManager( ) 。
QXmlSchema.setUriResolver (self, QAbstractUriResolver resolver)
设置的URI解析器resolver。QXmlSchema不采取所有权resolver。
See also uriResolver( ) 。
QAbstractUriResolver QXmlSchema.uriResolver (self)
返回架构的URI解析器。如果没有的URI解析器已定,QtXmlPatterns将使用的URI的模式,因为它们。
这个URI解析器提供了一个抽象层,或polymorphic URIs。解析器可以重写_logical_URI与物理的,或者它可以翻译过时的或无效的URI来有效的。
When QtXmlPatterns电话QAbstractUriResolver.resolve( )的绝对URI是由架构规范规定的URI和相对URI是由用户指定的URI。
See also setUriResolver( ) 。