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 "Octavian Nadolu (JIRA)" <xe...@xml.apache.org> on 2012/10/09 14:20:02 UTC

[jira] [Created] (XERCESJ-1590) Alternative type is not detected corectly

Octavian Nadolu created XERCESJ-1590:
----------------------------------------

             Summary: Alternative type is not detected corectly
                 Key: XERCESJ-1590
                 URL: https://issues.apache.org/jira/browse/XERCESJ-1590
             Project: Xerces2-J
          Issue Type: Bug
          Components: XML Schema 1.1 Structures
    Affects Versions: 2.11.0
            Reporter: Octavian Nadolu
            Priority: Trivial


When I validate the following xml document with the associated schema, I get the error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'NameFr'. One of '{NameEn}' is expected.
There should be no error because the lang attribute is inheritable, and the Author element type should be frAuthorType.
I tested on the xml-schema-1.1-dev branch. 

----------XML Document-----------------
<BookStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
    <Book lang="fr">
        <TitleFr></TitleFr>
        <Author>
            <NameFr></NameFr>
        </Author>
    </Book>
</BookStore>
-----------------------------------------------------

-------------- schema.xsd -----------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:element name="BookStore">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="Book" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    
    <xs:element name="Book">
        <xs:alternative test="@lang='en'" type="enType"/>
        <xs:alternative test="@lang='fr'" type="frType"/>
    </xs:element>
    
    <xs:element name="Author">
        <xs:alternative test="@lang='en'" type="enAuthorType"/>
        <xs:alternative test="@lang='fr'" type="frAuthorType"/>
        <xs:alternative type="enAuthorType"/>
    </xs:element>
    
    <xs:complexType name="enType">
        <xs:sequence>
            <xs:element name="TitleEn" type="xs:string"/>
            <xs:element ref="Author"/>
        </xs:sequence>
        <xs:attribute name="lang" inheritable="true" type="xs:string"/>
    </xs:complexType>
    
    <xs:complexType name="frType">
        <xs:sequence>
            <xs:element name="TitleFr" type="xs:string"/>
            <xs:element ref="Author"/>
        </xs:sequence>
        <xs:attribute name="lang" inheritable="true" type="xs:string"/>
    </xs:complexType>
    
    <xs:complexType name="enAuthorType">
        <xs:sequence>
            <xs:element name="NameEn" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="frAuthorType">
        <xs:sequence>
            <xs:element name="NameFr" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
</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


Re: [jira] [Updated] (XERCESJ-1590) Alternative type is not detected correctly

Posted by Mukul Gandhi <mu...@apache.org>.
Hi Octavian,
   Here are some more thoughts, about this bug report.

You've specified the attribute declaration, <xs:attribute name="lang"
inheritable="true" type="xs:string"/> within two different complex
type definitions ("enType" and "frType"), and then say that this
attribute is inheritable. I feel, this is an incorrect modelling of
inheritable attribute in the schema.

For an attribute to be inheritable, all references to it in an XML
instance document should originate from the same complex type
definition (this is necessary, to ensure a common identity of an
inheritable attribute).

I would propose the following schema document for this use case (one
of the various, I believe):
(this one works fine, with our current implementation)

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">

     <xs:element name="BookStore">
           <xs:complexType>
                <xs:sequence>
                     <xs:element ref="Book" maxOccurs="unbounded"/>
                 </xs:sequence>
           </xs:complexType>
      </xs:element>

      <xs:element name="Book" type="AbstractBook">
           <xs:alternative test="@lang='en'" type="enType"/>
           <xs:alternative test="@lang='fr'" type="frType"/>
	   <xs:alternative type="enType"/>
      </xs:element>

      <xs:element name="Author">
           <xs:alternative test="@lang='en'" type="enAuthorType"/>
           <xs:alternative test="@lang='fr'" type="frAuthorType"/>
           <xs:alternative type="enAuthorType"/>
      </xs:element>
	
      <xs:complexType name="enType">
	    <xs:complexContent>
	         <xs:restriction base="AbstractBook">
                     <xs:sequence>
                         <xs:element name="TitleEn" type="xs:string"/>
                         <xs:element ref="Author"/>
                     </xs:sequence>
		</xs:restriction>
	    </xs:complexContent>
      </xs:complexType>

      <xs:complexType name="frType">
	   <xs:complexContent>
	        <xs:restriction base="AbstractBook">
                    <xs:sequence>
                        <xs:element name="TitleFr" type="xs:string"/>
                        <xs:element ref="Author"/>
                    </xs:sequence>
	        </xs:restriction>
	   </xs:complexContent>
      </xs:complexType>
	
      <xs:complexType name="AbstractBook" abstract="true">
	    <xs:sequence>
	         <xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
	    </xs:sequence>
	    <xs:attribute name="lang" inheritable="true" type="xs:string"/>
      </xs:complexType>

      <xs:complexType name="enAuthorType">
            <xs:sequence>
                <xs:element name="NameEn" type="xs:string"/>
            </xs:sequence>
      </xs:complexType>

      <xs:complexType name="frAuthorType">
            <xs:sequence>
                 <xs:element name="NameFr" type="xs:string"/>
            </xs:sequence>
      </xs:complexType>

</xs:schema>

Here are rationale for this modified schema design:
There is an abstract complex type "AbstractBook" which declares an
attribute to be inheritable. From this schema type, two other types
are derived ("enType" and "frType"). Now, all references to an
inheritable attribute in an XML instance document get validated by the
same attribute declaration (which is declared to be inheritable). This
seems a necessary and logical schema model to me.

Therefore, I would think that your bug report may be incorrect. I
haven't cross checked the above suggested rationale with the XSD 1.1
spec (I'll do that in due course. In the meantime, comments from
others are welcome).

On Tue, Oct 9, 2012 at 5:50 PM, Octavian Nadolu (JIRA)
<xe...@xml.apache.org> wrote:
>
>      [ https://issues.apache.org/jira/browse/XERCESJ-1590?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
>
> Octavian Nadolu updated XERCESJ-1590:
> -------------------------------------
>
>     Summary: Alternative type is not detected correctly  (was: Alternative type is not detected corectly)
>
>> Alternative type is not detected correctly
>> ------------------------------------------
>>
>>                 Key: XERCESJ-1590
>>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1590
>>             Project: Xerces2-J
>>          Issue Type: Bug
>>          Components: XML Schema 1.1 Structures
>>    Affects Versions: 2.11.0
>>            Reporter: Octavian Nadolu
>>            Priority: Trivial
>>
>> When I validate the following xml document with the associated schema, I get the error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'NameFr'. One of '{NameEn}' is expected.
>> There should be no error because the lang attribute is inheritable, and the Author element type should be frAuthorType.
>> I tested on the xml-schema-1.1-dev branch.
>> ----------XML Document-----------------
>> <BookStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
>>     <Book lang="fr">
>>         <TitleFr></TitleFr>
>>         <Author>
>>             <NameFr></NameFr>
>>         </Author>
>>     </Book>
>> </BookStore>
>> -----------------------------------------------------
>> -------------- schema.xsd -----------------------
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
>>     <xs:element name="BookStore">
>>         <xs:complexType>
>>             <xs:sequence>
>>                 <xs:element ref="Book" maxOccurs="unbounded"/>
>>             </xs:sequence>
>>         </xs:complexType>
>>     </xs:element>
>>
>>     <xs:element name="Book">
>>         <xs:alternative test="@lang='en'" type="enType"/>
>>         <xs:alternative test="@lang='fr'" type="frType"/>
>>     </xs:element>
>>
>>     <xs:element name="Author">
>>         <xs:alternative test="@lang='en'" type="enAuthorType"/>
>>         <xs:alternative test="@lang='fr'" type="frAuthorType"/>
>>         <xs:alternative type="enAuthorType"/>
>>     </xs:element>
>>
>>     <xs:complexType name="enType">
>>         <xs:sequence>
>>             <xs:element name="TitleEn" type="xs:string"/>
>>             <xs:element ref="Author"/>
>>         </xs:sequence>
>>         <xs:attribute name="lang" inheritable="true" type="xs:string"/>
>>     </xs:complexType>
>>
>>     <xs:complexType name="frType">
>>         <xs:sequence>
>>             <xs:element name="TitleFr" type="xs:string"/>
>>             <xs:element ref="Author"/>
>>         </xs:sequence>
>>         <xs:attribute name="lang" inheritable="true" type="xs:string"/>
>>     </xs:complexType>
>>
>>     <xs:complexType name="enAuthorType">
>>         <xs:sequence>
>>             <xs:element name="NameEn" type="xs:string"/>
>>         </xs:sequence>
>>     </xs:complexType>
>>
>>     <xs:complexType name="frAuthorType">
>>         <xs:sequence>
>>             <xs:element name="NameFr" type="xs:string"/>
>>         </xs:sequence>
>>     </xs:complexType>
>> </xs:schema>




-- 
Regards,
Mukul Gandhi

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


[jira] [Commented] (XERCESJ-1590) Alternative type is not detected correctly

Posted by "Mukul Gandhi (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESJ-1590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13473118#comment-13473118 ] 

Mukul Gandhi commented on XERCESJ-1590:
---------------------------------------

I agree, that there seems to be a bug as you've given an appropriate example for that. If you remove the following element from the schema which you've provided, <xs:alternative type="enAuthorType"/> (within the element declaration, <xs:element name="Author">) I can see that the needed functionality becomes available.

Great to see that, Michael has volunteered to look at this issue.
                
> Alternative type is not detected correctly
> ------------------------------------------
>
>                 Key: XERCESJ-1590
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1590
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: XML Schema 1.1 Structures
>    Affects Versions: 2.11.0
>            Reporter: Octavian Nadolu
>            Assignee: Michael Glavassevich
>            Priority: Trivial
>
> When I validate the following xml document with the associated schema, I get the error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'NameFr'. One of '{NameEn}' is expected.
> There should be no error because the lang attribute is inheritable, and the Author element type should be frAuthorType.
> I tested on the xml-schema-1.1-dev branch. 
> ----------XML Document-----------------
> <BookStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
>     <Book lang="fr">
>         <TitleFr></TitleFr>
>         <Author>
>             <NameFr></NameFr>
>         </Author>
>     </Book>
> </BookStore>
> -----------------------------------------------------
> -------------- schema.xsd -----------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
>     <xs:element name="BookStore">
>         <xs:complexType>
>             <xs:sequence>
>                 <xs:element ref="Book" maxOccurs="unbounded"/>
>             </xs:sequence>
>         </xs:complexType>
>     </xs:element>
>     
>     <xs:element name="Book">
>         <xs:alternative test="@lang='en'" type="enType"/>
>         <xs:alternative test="@lang='fr'" type="frType"/>
>     </xs:element>
>     
>     <xs:element name="Author">
>         <xs:alternative test="@lang='en'" type="enAuthorType"/>
>         <xs:alternative test="@lang='fr'" type="frAuthorType"/>
>         <xs:alternative type="enAuthorType"/>
>     </xs:element>
>     
>     <xs:complexType name="enType">
>         <xs:sequence>
>             <xs:element name="TitleEn" type="xs:string"/>
>             <xs:element ref="Author"/>
>         </xs:sequence>
>         <xs:attribute name="lang" inheritable="true" type="xs:string"/>
>     </xs:complexType>
>     
>     <xs:complexType name="frType">
>         <xs:sequence>
>             <xs:element name="TitleFr" type="xs:string"/>
>             <xs:element ref="Author"/>
>         </xs:sequence>
>         <xs:attribute name="lang" inheritable="true" type="xs:string"/>
>     </xs:complexType>
>     
>     <xs:complexType name="enAuthorType">
>         <xs:sequence>
>             <xs:element name="NameEn" type="xs:string"/>
>         </xs:sequence>
>     </xs:complexType>
>     
>     <xs:complexType name="frAuthorType">
>         <xs:sequence>
>             <xs:element name="NameFr" type="xs:string"/>
>         </xs:sequence>
>     </xs:complexType>
> </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


[jira] [Updated] (XERCESJ-1590) Alternative type is not detected correctly

Posted by "Octavian Nadolu (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1590?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Octavian Nadolu updated XERCESJ-1590:
-------------------------------------

    Summary: Alternative type is not detected correctly  (was: Alternative type is not detected corectly)
    
> Alternative type is not detected correctly
> ------------------------------------------
>
>                 Key: XERCESJ-1590
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1590
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: XML Schema 1.1 Structures
>    Affects Versions: 2.11.0
>            Reporter: Octavian Nadolu
>            Priority: Trivial
>
> When I validate the following xml document with the associated schema, I get the error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'NameFr'. One of '{NameEn}' is expected.
> There should be no error because the lang attribute is inheritable, and the Author element type should be frAuthorType.
> I tested on the xml-schema-1.1-dev branch. 
> ----------XML Document-----------------
> <BookStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
>     <Book lang="fr">
>         <TitleFr></TitleFr>
>         <Author>
>             <NameFr></NameFr>
>         </Author>
>     </Book>
> </BookStore>
> -----------------------------------------------------
> -------------- schema.xsd -----------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
>     <xs:element name="BookStore">
>         <xs:complexType>
>             <xs:sequence>
>                 <xs:element ref="Book" maxOccurs="unbounded"/>
>             </xs:sequence>
>         </xs:complexType>
>     </xs:element>
>     
>     <xs:element name="Book">
>         <xs:alternative test="@lang='en'" type="enType"/>
>         <xs:alternative test="@lang='fr'" type="frType"/>
>     </xs:element>
>     
>     <xs:element name="Author">
>         <xs:alternative test="@lang='en'" type="enAuthorType"/>
>         <xs:alternative test="@lang='fr'" type="frAuthorType"/>
>         <xs:alternative type="enAuthorType"/>
>     </xs:element>
>     
>     <xs:complexType name="enType">
>         <xs:sequence>
>             <xs:element name="TitleEn" type="xs:string"/>
>             <xs:element ref="Author"/>
>         </xs:sequence>
>         <xs:attribute name="lang" inheritable="true" type="xs:string"/>
>     </xs:complexType>
>     
>     <xs:complexType name="frType">
>         <xs:sequence>
>             <xs:element name="TitleFr" type="xs:string"/>
>             <xs:element ref="Author"/>
>         </xs:sequence>
>         <xs:attribute name="lang" inheritable="true" type="xs:string"/>
>     </xs:complexType>
>     
>     <xs:complexType name="enAuthorType">
>         <xs:sequence>
>             <xs:element name="NameEn" type="xs:string"/>
>         </xs:sequence>
>     </xs:complexType>
>     
>     <xs:complexType name="frAuthorType">
>         <xs:sequence>
>             <xs:element name="NameFr" type="xs:string"/>
>         </xs:sequence>
>     </xs:complexType>
> </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


[jira] [Assigned] (XERCESJ-1590) Alternative type is not detected correctly

Posted by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1590?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Glavassevich reassigned XERCESJ-1590:
---------------------------------------------

    Assignee: Michael Glavassevich
    
> Alternative type is not detected correctly
> ------------------------------------------
>
>                 Key: XERCESJ-1590
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1590
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: XML Schema 1.1 Structures
>    Affects Versions: 2.11.0
>            Reporter: Octavian Nadolu
>            Assignee: Michael Glavassevich
>            Priority: Trivial
>
> When I validate the following xml document with the associated schema, I get the error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'NameFr'. One of '{NameEn}' is expected.
> There should be no error because the lang attribute is inheritable, and the Author element type should be frAuthorType.
> I tested on the xml-schema-1.1-dev branch. 
> ----------XML Document-----------------
> <BookStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
>     <Book lang="fr">
>         <TitleFr></TitleFr>
>         <Author>
>             <NameFr></NameFr>
>         </Author>
>     </Book>
> </BookStore>
> -----------------------------------------------------
> -------------- schema.xsd -----------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
>     <xs:element name="BookStore">
>         <xs:complexType>
>             <xs:sequence>
>                 <xs:element ref="Book" maxOccurs="unbounded"/>
>             </xs:sequence>
>         </xs:complexType>
>     </xs:element>
>     
>     <xs:element name="Book">
>         <xs:alternative test="@lang='en'" type="enType"/>
>         <xs:alternative test="@lang='fr'" type="frType"/>
>     </xs:element>
>     
>     <xs:element name="Author">
>         <xs:alternative test="@lang='en'" type="enAuthorType"/>
>         <xs:alternative test="@lang='fr'" type="frAuthorType"/>
>         <xs:alternative type="enAuthorType"/>
>     </xs:element>
>     
>     <xs:complexType name="enType">
>         <xs:sequence>
>             <xs:element name="TitleEn" type="xs:string"/>
>             <xs:element ref="Author"/>
>         </xs:sequence>
>         <xs:attribute name="lang" inheritable="true" type="xs:string"/>
>     </xs:complexType>
>     
>     <xs:complexType name="frType">
>         <xs:sequence>
>             <xs:element name="TitleFr" type="xs:string"/>
>             <xs:element ref="Author"/>
>         </xs:sequence>
>         <xs:attribute name="lang" inheritable="true" type="xs:string"/>
>     </xs:complexType>
>     
>     <xs:complexType name="enAuthorType">
>         <xs:sequence>
>             <xs:element name="NameEn" type="xs:string"/>
>         </xs:sequence>
>     </xs:complexType>
>     
>     <xs:complexType name="frAuthorType">
>         <xs:sequence>
>             <xs:element name="NameFr" type="xs:string"/>
>         </xs:sequence>
>     </xs:complexType>
> </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