Identity constraint is not enforced on xs:anySimpleType
-------------------------------------------------------
Key: XERCESC-1393
URL: http://issues.apache.org/jira/browse/XERCESC-1393
Project: Xerces-C++
Type: Bug
Components: Validating Parser (Schema) (Xerces 1.5 or up only)
Versions: 2.6.0
Environment: Windows XP SP2, Visual C++ 6.0
Reporter: Alberto Massari
I have this schema file
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="Songs">
<xs:complexType>
<xs:sequence>
<xs:element name="Song" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="title" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="Song">
<xs:selector xpath="Song"/>
<xs:field xpath="@title"/>
</xs:unique>
</xs:element>
</xs:schema>
It defines a root named "Songs" with child nodes named "Song" having one
attribute, with no type specified (so, it is assumed to be xs:anySimpleType).
It also defines a uniqueness constraint to avoid having two "Song" element with
the same title.
I also have an XML associated with this schema,
<Songs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="xsd_unique.xsd">
<Song title="Hotel California"/>
<Song title="Hotel California"/>
</Songs>
that lists the same song twice.
However, running "Saxcount -n -s xsd_unique.xml" on the XML file result in no
validation errors being reported.
But changing the schema to say
<xs:attribute name="title" type="xs:string" use="required"/>
makes the validator report "Duplicate unique value declared for identity
constraint of element 'Songs'."
The cause of the error is in
inline int AnySimpleTypeDatatypeValidator::compare(const XMLCh* const,
const XMLCh* const
, MemoryManager* const)
{
return -1;
}
that always report two instances of xs:anySimpleType to be different,
regardless of their values.
Strictly speaking, this is not an error, as the XMLSchema specs say (� 2.2.1.2,
Simple Type Definition):
"The mapping from lexical space to value space is unspecified for items whose
type definition is the �simple ur-type definition�. Accordingly this
specification does not constrain processors' behaviour in areas where this
mapping is implicated, for example [...] checking identity constraints
involving such items.
Note: The Working Group expects to return to this area in a future version of
this specification."
Anyhow, this causes confusion in the users (because Xerces-J reports the error,
for instance) so I would like to do one (or both) of the following changes:
1) implement the "compare" operation to do a lexical space comparation (i.e.
using XMLString::equals)
2) emit a warning when an identity field involves a xs:anySimpleType
Feedback?
Alberto
--
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
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]