Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.6.0
-
None
-
Linux 2.4.21-27 i686 GNU/Linux
gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-49)
Description
Xerces-C can not properly validate enumerations with a QName base.It will validate only if the enumeration's QName's prefix is exactly the same as the namespace prefix defined in the XSD.
For example, the schema is defined as:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.example.com/qname"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
targetNamespace="http://www.example.com/qname"
elementFormDefault="qualified" > ...
(the full schema is included below)
Then the XML document will validate (using same namespace prefix):
<tns:Body xmlns:tns="http://www.example.com/qname"
xmlns:xml="http://www.w3.org/XML/1998/namespace">
<tns:Fault>
<tns:Code>
<tns:Value>tns:Sender</tns:Value>
</tns:Code>
</tns:Fault>
</tns:Body>
But the following will not (using a different namespace prefix):
<my-tns:Body xmlns:my-tns="http://www.example.com/qname"
xmlns:xml="http://www.w3.org/XML/1998/namespace">
<my-tns:Fault>
<my-tns:Code>
<my-tns:Value>my-tns:Sender</my-tns:Value>
</my-tns:Code>
</my-tns:Fault>
</my-tns:Body>
I have tracked the root of this problem down to trunk/src/xercesc/validators/datatype/QNameDatatypeValidator.cpp line 185:
for ( ; i < enumLength; i++)
{ if (XMLString::equals(normContent, getEnumeration()->elementAt(i))) break; } if (i == enumLength)
ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content, manager);
The comparison XMLString::equals is comparing the QName string with the URI prefix (i.e. tns:Sender) instead of the the URI itself (i.e.
{http://www.example.com/qname}:Sender). So if the XML uses a different namespace prefix than that of the schema definition, it will fail.