Hi Marco,

     Unfortunately, "XML Schema: Structures" Recommendation doesn't permit an "all" to be extended.  The "All Group Limited" Constraint [1] indicates that if an "all" compositor appears in a particle, it must constitute the content model of the complex type; in other words, it has to be the "top-most" thing in the content model.

     In the case of extension, the content model is a sequence of the content model of the base type followed by the explicit content of the extension itself - in your example, that would be a sequence of two "all"s - so if the content of the base type or the explicit content of the extension is an "all", it will always violate the "All Group Limited" constraint.

     There's not really a way to do what you probably want to do.  You could create a base Item type that contains "Description" and "ItemIdentifier" elements to appear in any order by defining it as a choice of two sequences:

        (D II) | (II D)

and then define the extension type "Book" with "Title", "Author" and "Publisher" elements in any order:

        (T A P) | (T P A) | (P A T) | (P T A) | (A P T) | (A T P)

     The problem with that is that the resulting extension would still require the Description and ItemIdentifier to both come, in any order, before the Title, Author and Publisher, which could also appear in any order.  You wouldn't be able to intermingle the two sets of elements.

Thanks,

Henry

[1] http://www.w3.org/TR/xmlschema-1/#cos-all-limited
------------------------------------------------------------------------
Henry Zongaro      XML Parsers development
IBM SWS Toronto Lab   Tie Line 969-6044;  Phone (905) 413-6044
mailto:[EMAIL PROTECTED]

Please respond to [EMAIL PROTECTED]

To:        "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
cc:        
Subject:        Schema error


Hi all,

I posted this message on xerces-j-user a week ago, but got no answer: if
anyone can provide any help, it would much valuable.

I'm using Xerces 1.4.3, and I'm having a problem validating an XML document
wrt its XML Schema.

The XML Schema defines two complexTypes: the first (Item) has some elements
in an xs:all group, and the second (Book) extends the previous adding
another xs:all group. Here is the schema (catalog.xsd):

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
                <xs:element name="Item" type="Item"/>
                <xs:complexType name="Item">
                                 <xs:all>
                                                  <xs:element name="Description" type="xs:string"/>
                                                  <xs:element name="ItemIdentifier" type="xs:string"/>
                                 </xs:all>
                </xs:complexType>
                <xs:element name="Book" type="Book"/>
                <xs:complexType name="Book">
                                 <xs:complexContent>
                                                  <xs:extension base="Item">
                                                                   <xs:all>
                                                                                    <xs:element name="Title"
type="xs:string"/>
                                                                                    <xs:element name="Author"
type="xs:string"/>
                                                                                    <xs:element name="Publisher"
type="xs:string"/>
                                                                   </xs:all>
                                                  </xs:extension>
                                 </xs:complexContent>
                </xs:complexType>
</xs:schema>

I tested this schema with W3C XSV (http://www.w3.org/2001/03/webdata/xsv)
and no error are found.

The problem is that Xerces gives errors while parsing this schema. I created
the following xml file (book.xml), based on the previous schema:

<?xml version="1.0" encoding="UTF-8"?>
<Book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="catalog.xsd">
                <Description>this is very interesting</Description>
                <ItemIdentifier>B0001</ItemIdentifier>
                <Title>my favourite book</Title>
                <Author>the author of my favourite book</Author>
                <Publisher>whatever</Publisher>
</Book>

I used the default DOMCount example, and if I try

java dom.DOMCount -v book.xml

I get the following error:

[Error] book.xml:3:126: Schema error: ComplexType 'Book':
cos-all-limited.1.2: An "all" model group that is part of a complex type
definition must constitute the entire {content type} of the definition..
book.xml: 771 ms (6 elems, 2 attrs, 0 spaces, 96 chars)

Am I trying to do something illegal, or is this an implementation issue with
Xerces? Does anyone have any suggestion?

Thanks in Advance.
Marco Sbodio

Reply via email to