Qyoto
4.0.5
Qyoto is a C# language binding for Qt
|
The QXmlSchemaValidator class validates XML instance documents against a W3C XML Schema. More...
Public Member Functions | |
QXmlSchemaValidator () | |
| |
QXmlSchemaValidator (QXmlSchema schema) | |
| |
virtual void | CreateProxy () |
new QXmlNamePool | NamePool () |
| |
new bool | Validate (QUrl source) |
| |
new bool | Validate (QIODevice source) |
| |
new bool | Validate (QByteArray data) |
| |
new bool | Validate (QIODevice source, QUrl documentUri) |
| |
new bool | Validate (QByteArray data, QUrl documentUri) |
| |
new void | Dispose () |
Protected Member Functions | |
QXmlSchemaValidator (System.Type dummy) | |
Protected Attributes | |
SmokeInvocation | interceptor |
Properties | |
new QAbstractMessageHandler | MessageHandler [get, set] |
| |
new QNetworkAccessManager | NetworkAccessManager [get, set] |
| |
new QXmlSchema | Schema [get, set] |
| |
new QAbstractUriResolver | UriResolver [get, set] |
| |
virtual System.IntPtr | SmokeObject [get, set] |
The 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 Version
This class implements schema validation according to the XML Schema 1.0 specification.
See also QXmlSchema and XML Schema Validation Example.
|
protected |
QXmlSchemaValidator.QXmlSchemaValidator | ( | ) |
Constructs a schema validator. The schema used for validation must be referenced in the XML instance document via the xsi:schemaLocation or xsi:noNamespaceSchemaLocation attribute.
QXmlSchemaValidator.QXmlSchemaValidator | ( | QXmlSchema | schema | ) |
Constructs a schema validator that will use schema for validation. If an empty QXmlSchema schema is passed to the validator, the schema used for validation must be referenced in the XML instance document via the xsi:schemaLocation or xsi:noNamespaceSchemaLocation attribute.
|
virtual |
new void QXmlSchemaValidator.Dispose | ( | ) |
new QXmlNamePool QXmlSchemaValidator.NamePool | ( | ) |
Returns the name pool used by this QXmlSchemaValidator for constructing names. There is no setter for the name pool, because mixing name pools causes errors due to name confusion.
new bool QXmlSchemaValidator.Validate | ( | QUrl | source | ) |
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";
new bool QXmlSchemaValidator.Validate | ( | QIODevice | source | ) |
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";
new bool QXmlSchemaValidator.Validate | ( | QByteArray | data | ) |
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";
new bool QXmlSchemaValidator.Validate | ( | QIODevice | source, |
QUrl | documentUri | ||
) |
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";
new bool QXmlSchemaValidator.Validate | ( | QByteArray | data, |
QUrl | documentUri | ||
) |
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";
|
protected |
|
getset |
Returns the message handler that handles parsing and validation messages for this QXmlSchemaValidator.
Changes the message handler for this QXmlSchemaValidator to handler. The schema validator sends all parsing and validation messages to this message handler. QXmlSchemaValidator does not take ownership of handler.
Normally, the default message handler is sufficient. It writes compile and validation messages to stderr. The default message handler includes color codes if stderr can render colors.
When QXmlSchemaValidator calls QAbstractMessageHandler::message(), the arguments are as follows:
message() argumentSemantics
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.
|
getset |
Returns the network manager, or 0 if it has not been set.
Sets the network manager to manager. QXmlSchemaValidator does not take ownership of manager.
|
getset |
Returns the schema that is used for validation.
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.
|
getset |
|
getset |
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.
Sets the URI resolver to resolver. QXmlSchemaValidator does not take ownership of resolver.