QNameDatatypeValidator does not resolve namespaces when making comparisions
---------------------------------------------------------------------------
Key: XERCESC-1441
URL: http://issues.apache.org/jira/browse/XERCESC-1441
Project: Xerces-C++
Type: Bug
Components: Validating Parser (Schema) (Xerces 1.5 or up only)
Versions: 2.6.0
Environment: Linux 2.4.21-27 i686 GNU/Linux
gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-49)
Reporter: Alex Dickinson
Attachments: qname-bad.xml, qname-good.xml, qname.xsd
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.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]