QXmlSchemaclass provides loading and validation of a W3C XML Schema. 更多 …
4.6 版新增。
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
()
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";
This class is used to represent schemas that conform to the XML Schema 1.0 specification.
QXmlSchema
¶
QXmlSchema(other)
- param other
Constructs an invalid, empty schema that cannot be used until
load()
被调用。
构造
QXmlSchema
that is a copy of
other
. The new instance will share resources with the existing schema to the extent possible.
PySide2.QtXmlPatterns.QXmlSchema.
documentUri
(
)
¶
QUrl
Returns the document URI of the schema or an empty URI if no schema has been set.
PySide2.QtXmlPatterns.QXmlSchema.
isValid
(
)
¶
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()
]
)
¶
source
–
QIODevice
documentUri
–
QUrl
bool
PySide2.QtXmlPatterns.QXmlSchema.
load
(
data
[
,
documentUri=QUrl()
]
)
¶
data
–
QByteArray
documentUri
–
QUrl
bool
PySide2.QtXmlPatterns.QXmlSchema.
load
(
source
)
¶
source
–
QUrl
bool
设置此
QXmlSchema
to a schema loaded from the
source
URI.
若模式
is
invalid
,
false
被返回且行为未定义。
范例:
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";
另请参阅
PySide2.QtXmlPatterns.QXmlSchema.
messageHandler
(
)
¶
Returns the message handler that handles compile and validation messages for this
QXmlSchema
.
另请参阅
PySide2.QtXmlPatterns.QXmlSchema.
namePool
(
)
¶
Returns the name pool used by this
QXmlSchema
for constructing
names
. There is no setter for the name pool, because mixing name pools causes errors due to name confusion.
PySide2.QtXmlPatterns.QXmlSchema.
networkAccessManager
(
)
¶
QNetworkAccessManager
Returns the network manager, or 0 if it has not been set.
PySide2.QtXmlPatterns.QXmlSchema.
setMessageHandler
(
handler
)
¶
handler
–
QAbstractMessageHandler
改变
message
handler
for this
QXmlSchema
to
handler
. The schema sends all compile and validation messages to this message handler.
QXmlSchema
未拥有所有权对于
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.
当
QXmlSchema
calls
message()
, the arguments are as follows:
|
message() argument |
Semantics |
|
|
Only
|
|
const
|
An XHTML document which is the actual message. It is translated into the current language. |
|
const
|
Identifies the error with a URI, where the fragment is the error code, and the rest of the URI is the error namespace. |
|
const
|
Identifies where the error occurred. |
另请参阅
PySide2.QtXmlPatterns.QXmlSchema.
setNetworkAccessManager
(
networkmanager
)
¶
networkmanager
–
QNetworkAccessManager
将网络管理器设为
manager
.
QXmlSchema
未拥有所有权对于
manager
.
PySide2.QtXmlPatterns.QXmlSchema.
setUriResolver
(
resolver
)
¶
resolver
–
QAbstractUriResolver
将 URI 解析器设为
resolver
.
QXmlSchema
未拥有所有权对于
resolver
.
另请参阅
PySide2.QtXmlPatterns.QXmlSchema.
uriResolver
(
)
¶
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.
另请参阅