QXmlSchema¶
The
QXmlSchemaclass provides loading and validation of a W3C XML Schema. More…

New in version 4.6.
Synopsis¶
Functions¶
def
documentUri()def
isValid()def
load(data[, documentUri=QUrl()])def
load(source)def
load(source[, documentUri=QUrl()])def
messageHandler()def
namePool()def
networkAccessManager()def
setMessageHandler(handler)def
setNetworkAccessManager(networkmanager)def
setUriResolver(resolver)def
uriResolver()
Detailed Description¶
The
QXmlSchemaclass loads, compiles and validates W3C XML Schema files that can be used further for validation of XML instance documents viaQXmlSchemaValidator.The following example shows how to load a XML Schema file from the network and test whether it is a valid schema document:
QUrl 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¶
This class is used to represent schemas that conform to the XML Schema 1.0 specification.
- class PySide2.QtXmlPatterns.QXmlSchema¶
PySide2.QtXmlPatterns.QXmlSchema(other)
- param other:
Constructs an invalid, empty schema that cannot be used until
load()is called.Constructs a
QXmlSchemathat is a copy ofother. The new instance will share resources with the existing schema to the extent possible.
- PySide2.QtXmlPatterns.QXmlSchema.documentUri()¶
- Return type:
Returns the document URI of the schema or an empty URI if no schema has been set.
- PySide2.QtXmlPatterns.QXmlSchema.isValid()¶
- Return type:
bool
Returns true if this schema is valid. Examples of invalid schemas are ones that contain syntax errors or that do not conform the W3C XML Schema specification.
- PySide2.QtXmlPatterns.QXmlSchema.load(source[, documentUri=QUrl()])¶
- Parameters:
source –
PySide2.QtCore.QIODevicedocumentUri –
PySide2.QtCore.QUrl
- Return type:
bool
- PySide2.QtXmlPatterns.QXmlSchema.load(data[, documentUri=QUrl()])
- Parameters:
data –
PySide2.QtCore.QByteArraydocumentUri –
PySide2.QtCore.QUrl
- Return type:
bool
- PySide2.QtXmlPatterns.QXmlSchema.load(source)
- Parameters:
source –
PySide2.QtCore.QUrl- Return type:
bool
Sets this
QXmlSchemato a schema loaded from thesourceURI.If the schema
is invalid,falseis returned and the behavior is undefined.Example:
QUrl url("http://www.schema-example.org/myschema.xsd"); QXmlSchema schema; if (schema.load(url) == true) qDebug() << "schema is valid"; else qDebug() << "schema is invalid";
See also
- PySide2.QtXmlPatterns.QXmlSchema.messageHandler()¶
- Return type:
Returns the message handler that handles compile and validation messages for this
QXmlSchema.See also
- PySide2.QtXmlPatterns.QXmlSchema.namePool()¶
- Return type:
Returns the name pool used by this
QXmlSchemafor constructingnames. There is no setter for the name pool, because mixing name pools causes errors due to name confusion.
- PySide2.QtXmlPatterns.QXmlSchema.networkAccessManager()¶
- Return type:
Returns the network manager, or 0 if it has not been set.
See also
- PySide2.QtXmlPatterns.QXmlSchema.setMessageHandler(handler)¶
- Parameters:
Changes the
message handlerfor thisQXmlSchematohandler. The schema sends all compile and validation messages to this message handler.QXmlSchemadoes not take ownership ofhandler.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
QXmlSchemacallsmessage(), the arguments are as follows:message() argument
Semantics
QtMsgTypetypeOnly
QtWarningMsgandQtFatalMsgare used. The former identifies a warning, while the latter identifies an error.const
QString& descriptionAn XHTML document which is the actual message. It is translated into the current language.
const
QUrl&identifierIdentifies the error with a URI, where the fragment is the error code, and the rest of the URI is the error namespace.
const
QSourceLocation& sourceLocationIdentifies where the error occurred.
See also
- PySide2.QtXmlPatterns.QXmlSchema.setNetworkAccessManager(networkmanager)¶
- Parameters:
networkmanager –
PySide2.QtNetwork.QNetworkAccessManager
Sets the network manager to
manager.QXmlSchemadoes not take ownership ofmanager.See also
- PySide2.QtXmlPatterns.QXmlSchema.setUriResolver(resolver)¶
- Parameters:
resolver –
PySide2.QtXmlPatterns.QAbstractUriResolver
Sets the URI resolver to
resolver.QXmlSchemadoes not take ownership ofresolver.See also
- PySide2.QtXmlPatterns.QXmlSchema.uriResolver()¶
- Return type:
Returns the schema’s URI resolver. If no URI resolver has been set, Qt XML Patterns will use the URIs in schemas 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 Qt XML Patterns calls
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
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.