| Home · All Classes · Modules · QSS HELP · QSS 案例 · VER007 HOME |
该QXmlSchemaValidator类验证XML实例文档对W3C XML架构。More...
该QXmlSchemaValidator类验证XML实例文档对W3C XML架构。
该QXmlSchemaValidator类加载,解析一个XML实例文档,并对其进行验证已编译与W3C XML模式QXmlSchema。
下面的示例演示如何从本地文件中加载XML架构,检查它是否是一个有效的模式文档,并将其用于XML实例文档的验证:
QUrl schemaUrl("file:///home/user/schema.xsd");
QXmlSchema schema;
schema.load(schemaUrl);
if (schema.isValid()) {
QFile file("test.xml");
file.open(QIODevice.ReadOnly);
QXmlSchemaValidator validator(schema);
if (validator.validate(&file, QUrl.fromLocalFile(file.fileName())))
qDebug() << "instance document is valid";
else
qDebug() << "instance document is invalid";
}
根据这个类实现模式验证XML Schema1.0规范。
构造一个模式验证。用于验证的架构必须在XML实例文档中通过引用xsi:schemaLocation or xsi:noNamespaceSchemaLocation属性。
构建将使用模式验证schema进行验证。如果空QXmlSchema模式被传递给验证器,用于验证的架构,必须在XML实例文档中通过引用xsi:schemaLocation or xsi:noNamespaceSchemaLocation属性。
返回处理这个解析和验证消息的消息处理程序QXmlSchemaValidator。
See also setMessageHandler( ) 。
返回此名称池QXmlSchemaValidator构建names。有没有setter的名字池,因为混合池的名称会导致错误,由于名称的混乱。
返回该网络管理器,或0 ,如果它没有被设置。
See also setNetworkAccessManager( ) 。
返回一个用于验证的架构。
See also setSchema( ) 。
更改message handler这QXmlSchemaValidator至handler。模式验证器将所有解析和验证消息,此消息处理程序。QXmlSchemaValidator不采取所有权handler。
通常情况下,默认的消息处理就足够了。它写的编译和验证消息的stderr。默认的消息处理程序,包括颜色代码,如果stderr可以使色彩。
When QXmlSchemaValidator电话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( ) 。
设置网络管理员manager。QXmlSchemaValidator不采取所有权manager。
See also networkAccessManager( ) 。
设置schema这将用于进一步的验证。如果架构是空的,用于验证的架构,必须在XML实例文档中通过引用xsi:schemaLocation or xsi:noNamespaceSchemaLocation属性。
See also schema( ) 。
设置的URI解析器resolver。QXmlSchemaValidator不采取所有权resolver。
See also uriResolver( ) 。
返回架构的URI解析器。如果没有的URI解析器已定,QtXmlPatterns将使用的URI的实例文档,因为它们。
这个URI解析器提供了一个抽象层,或polymorphic URIs。解析器可以重写logicalURI与物理的,或者它可以翻译过时的或无效的URI来有效的。
When QtXmlPatterns电话QAbstractUriResolver.resolve( )的绝对URI是由架构规范规定的URI和相对URI是由用户指定的URI。
See also setUriResolver( ) 。
验证读取XML实例文档source针对架构。
Returns true如果根据模式的XML实例文档是有效的,false否则。
例如:
const QXmlSchema schema = getSchema();
const QUrl url("http://www.schema-example.org/test.xml");
QXmlSchemaValidator validator(schema);
if (validator.validate(url))
qDebug() << "instance document is valid";
else
qDebug() << "instance document is invalid";
验证读取XML实例文档source用给定的documentUri针对架构。
Returns true如果根据模式的XML实例文档是有效的,false否则。
例如:
const QXmlSchema schema = getSchema();
QFile file("test.xml");
file.open(QIODevice.ReadOnly);
QXmlSchemaValidator validator(schema);
if (validator.validate(&file, QUrl.fromLocalFile(file.fileName())))
qDebug() << "instance document is valid";
else
qDebug() << "instance document is invalid";
验证读取XML实例文档data用给定的documentUri针对架构。
Returns true如果根据模式的XML实例文档是有效的,false否则。
例如:
const QXmlSchema schema = getSchema();
QByteArray data("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<test></test>");
QBuffer buffer(&data);
buffer.open(QIODevice.ReadOnly);
QXmlSchemaValidator validator(schema);
if (validator.validate(&buffer))
qDebug() << "instance document is valid";
else
qDebug() << "instance document is invalid";
| PyQt 4.10.3 for X11 | Copyright © Riverbank Computing Ltd and Nokia 2012 | Qt 4.8.5 |