Hi Marco,
I think that the fact that XSV and XMLSpy do not report errors may mean that the developers have missed or misunderstood the requirement. This issue was discussed by the XML Schema Working Group in May 2001 - see [1], which you should be able to access as an employee of a W3C member.
I agree that it can be awkward to work with that restriction.
Thanks,
Henry
[1] http://lists.w3.org/Archives/Member/w3c-xml-schema-ig/2001May/0039.html
------------------------------------------------------------------------
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: RE: Schema error
Thank you Henry for your answer.
I read the W3C Recommendation you mentioned, and I agree with you: it looks
like what I want to do is not allowed.
Anyway I still don't understand why W3C XSV utility finds no error on my
schema. Besides this I tested the Schema with XMLSpy 4 and it say it's OK,
and it also successfully validate the sample XML. Does this mean that they
implement a somehow relaxed version of the W3C Recommendation?
There's one more thing that gives me some thought: I've read a book and some
articles that use the same schema structure that I used. Here is an example
taken from one of this articles:
<xs:element name="Address" type="Address" abstract="true"/>
<xs:complexType name="Address" abstract="true">
<xs:all>
<xs:element name="name" type="xs:string"/>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
</xs:all>
</xs:complexType>
<xs:element name="USAddress" type="USAddress"
substitutionGroup="Address"/>
<xs:complexType name="USAddress">
<xs:complexContent>
<xs:extension base="Address">
<xs:all>
<xs:element name="state" type="USState"/>
<xs:element name="zip" type="xs:positiveInteger"/>
</xs:all>
</xs:extension>
</xs:complexContent>
</xs:complexType>
and here is the link to the article:
http://www.xml.com/lpt/a/2001/09/19/uml.html.
>From W3C Recommendation looks like all this is not allowed ... is it really
so?
I'd like to read your opinion.
Sorry for this message, which is probably somehow 'out of topic' on this
mailing list, but the issue came out when I started implementing using
Xerces-j
Thank you
Marco Sbodio
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: luned� 29 ottobre 2001 16.31
To: [EMAIL PROTECTED]
Subject: Re: Schema error
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
