QXmlSchemaValidator Class ReferenceThe QXmlSchemaValidator class validates XML instance documents against a W3C XML Schema. More... #include <QXmlSchemaValidator> Note: All functions in this class are reentrant. This class was introduced in Qt 4.6. Public Functions
Detailed DescriptionThe QXmlSchemaValidator class validates XML instance documents against a W3C XML Schema. The QXmlSchemaValidator class loads, parses an XML instance document and validates it against a W3C XML Schema that has been compiled with QXmlSchema. The following example shows how to load a XML Schema from a local file, check whether it is a valid schema document and use it for validation of an XML instance document: 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 Schema VersionThis class implements schema validation according to the XML Schema 1.0 specification. See also QXmlSchema and XML Schema Validation Example. Member Function Documentation
|
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().
Sets the network manager to manager. QXmlSchemaValidator does not take ownership of manager.
See also networkAccessManager().
Sets the schema that shall be used for further validation. If the schema is empty, the schema used for validation must be referenced in the XML instance document via the xsi:schemaLocation or xsi:noNamespaceSchemaLocation attribute.
See also schema().
Sets the URI resolver to resolver. QXmlSchemaValidator does not take ownership of resolver.
See also uriResolver().
Returns the schema's URI resolver. If no URI resolver has been set, QtXmlPatterns will use the URIs in instance documents as they are.
The URI resolver provides a level of abstraction, or polymorphic URIs. A resolver can rewrite logical URIs to physical ones, or it can translate obsolete or invalid URIs to valid ones.
When QtXmlPatterns calls QAbstractUriResolver::resolve() the absolute URI is the URI mandated by the schema specification, and the relative URI is the URI specified by the user.
See also setUriResolver().
Validates the XML instance document read from source against the schema.
Returns true if the XML instance document is valid according to the schema, false otherwise.
Example:
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";
Validates the XML instance document read from source with the given documentUri against the schema.
Returns true if the XML instance document is valid according to the schema, false otherwise.
Example:
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";
Validates the XML instance document read from data with the given documentUri against the schema.
Returns true if the XML instance document is valid according to the schema, false otherwise.
Example:
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";
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.8 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com