You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "John Snelson (JIRA)" <xe...@xml.apache.org> on 2008/03/07 12:51:46 UTC

[jira] Commented: (XERCESC-1393) Identity constraint is not enforced on xs:anySimpleType

    [ https://issues.apache.org/jira/browse/XERCESC-1393?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12576148#action_12576148 ] 

John Snelson commented on XERCESC-1393:
---------------------------------------

I am coming up against this problem as well in both Xerces-C 2.8 and 3.0. Both XML Spy and Visual Studio agree with Xerces-J that the unique constraint is legal and that the document is invalid. I would like to suggest that this issue is fixed by writing a suitable comparison function for values of type xs:anySimpleType.

> Identity constraint is not enforced on xs:anySimpleType
> -------------------------------------------------------
>
>                 Key: XERCESC-1393
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1393
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (XML Schema)
>    Affects 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.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org