You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Mukul Gandhi (JIRA)" <xe...@xml.apache.org> on 2013/03/15 15:38:12 UTC

[jira] [Commented] (XERCESJ-1596) Open content validation problem

    [ https://issues.apache.org/jira/browse/XERCESJ-1596?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13603416#comment-13603416 ] 

Mukul Gandhi commented on XERCESJ-1596:
---------------------------------------

Here's something I tried today while studying this issue.

Using your same schema document, I attempted validation with following XML instance document,

<r:BookStore xmlns:r="http://www.books.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.books.org schema.xsd">
    <r:Book>
        <r:Title>Title0</r:Title>
        <r:Author>Author0</r:Author>
        <r:Date>2006</r:Date>
        <r:ISBN>ISBN0</r:ISBN>
        <r:Publisher>Publisher0</r:Publisher>
        <r:Edition>First</r:Edition>
    </r:Book>
</r:BookStore>

and I did not get an error. I've introduced a new element named "r:Edition" as last sibling within children of element "r:Book".

If a new sibling element within "r:Book" is introduced after all currently existing siblings, and a new sibling element has same name as one of the already declared sibling elements (for e.g, r:Title etc), Xerces gives an error as you've reported. This current implementation looks sensible to me, from a schema author's point of view.

But I agree, that this behavior is against the spirit of xs:openContent schema element (but I haven't crosschecked with the spec, the behavior which language desires).
                
> Open content validation problem
> -------------------------------
>
>                 Key: XERCESJ-1596
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1596
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: XML Schema 1.1 Structures
>    Affects Versions: 2.11.0
>            Reporter: Octavian Nadolu
>            Priority: Minor
>
> If I validate the following XML file with the XML Schema I get an error: 
> "cos-element-consistent.4: A wildcard matched a global element 'r:Title'  ...."
> The problem is that in the "<r:Book>" element we have as last child the "<r:Title>" element. There should be no error because the "Book" element has an open content which specifies that elements from target namespace are permitted as last children.
> ------ XML Instance -------------------------
> <r:BookStore xmlns:r="http://www.books.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>   xsi:schemaLocation="http://www.books.org schema.xsd">
>     <r:Book>
>         <r:Title>Title0</r:Title>
>         <r:Author>Author0</r:Author>
>         <r:Date>2006</r:Date>
>         <r:ISBN>ISBN0</r:ISBN>
>         <r:Publisher>Publisher0</r:Publisher>
>         <r:Title>Title1</r:Title>
>     </r:Book>
> </r:BookStore>
> -----------------------------------------
> ----- XML Schema -------------------------
> <?xml version="1.0"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org"
>     xmlns:r="http://www.books.org" elementFormDefault="qualified">
>     <xs:element name="BookStore">
>         <xs:complexType>
>             <xs:sequence>
>                 <xs:element name="Book" maxOccurs="unbounded">
>                     <xs:complexType>
>                         <xs:openContent mode="suffix">
>                             <xs:any processContents="lax" namespace="##targetNamespace"/>
>                         </xs:openContent>
>                         <xs:sequence>
>                             <xs:element name="Title" type="xs:string"/>
>                             <xs:element name="Author" type="xs:string"/>
>                             <xs:element name="Date" type="xs:gYear"/>
>                             <xs:element name="ISBN" type="xs:string"/>
>                             <xs:element name="Publisher" type="xs:string"/>
>                         </xs:sequence>
>                     </xs:complexType>
>                 </xs:element>
>             </xs:sequence>
>         </xs:complexType>
>     </xs:element>
> </xs:schema>
> ------------------------------------------

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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