This section describes the built-in primitive datatype, 'QName' that represents XML element and attribute names with or without namespaces. Leading and trailing whitespaces are allowed and trimmed.
"QName" is a built-in datatype that represents (namespace URI, local name) pairs used as XML element
and attribute names with these rules:
The value space of "QName" is all (namespace URI, local name) pairs with "namespace URI" as optional.
The lexical space of "QName" is all possible "QName" values represented in
/((namepspacePrefix):)?(localName)/ patten.
"namespacePrefix" part is optional.
If exists, if must be defined to a URI.
"namespacePrefix" and "localName" must be valid "NCName" lexical representations.
Leading and trailing whitespaces allowed and trimmed.
To verify these rules, I wrote this simple XSD document that uses "QName" datatype to declare XML elements:
When validating this XML document with my XsdSchemaValidator.java program presented earlier in the book,
I get 3 groups of errors for 3 invalid XML elements:
c:\Progra~1\Java\jdk1.7.0_07\bin\java XsdSchemaValidator
QName_datatype_test.xsd QName_datatype_test.xml
Error:
Line number: 13
Column number: 34
Message: cvc-datatype-valid.1.2.1: '2ndOption' is not a valid value
for 'QName'. (Numeric digits not allowed as the leading character)
Error:
Line number: 13
Column number: 34
Message: cvc-type.3.1.3: The value ' 2ndOption ' of element
'QName' is not valid.
Error:
Line number: 14
Column number: 34
Message: UndeclaredPrefix: Cannot resolve 'xs:schema' as a QName:
the prefix 'xs' is not declared. ("xs" must be declared)
Error:
Line number: 14
Column number: 34
Message: cvc-type.3.1.3: The value ' xs:schema ' of element
'QName' is not valid.
Error:
Line number: 15
Column number: 34
Message: cvc-datatype-valid.1.2.1: 'hy:hy:any' is not a valid
value for 'QName'. (Maximum 1 ":" allowed)
Error:
Line number: 15
Column number: 34
Message: cvc-type.3.1.3: The value ' hy:hy:any ' of element
'QName' is not valid.
Failed with errors: 6