XSD: Question on derivation-ok-restriction.5.4.2

C

Cat

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


I'm having trouble getting my head around the reason the that following file
won't validate with the following error output in Xerces version 2.6.0 and
XSLTC version 2.5.2 ( from the standard jdk1.5.0 beta ). Is there something I'm
missing from the spec?

============ OUTPUT (wrapped) =================

cos-particle-restrict.2: Forbidden particle restriction:
'choice:all,sequence,elt'.
SAX Error:
System ID: file:///usr/local/websites/astro/test.xsd
Public ID: unknown
Column: 36 Line: 21
derivation-ok-restriction.5.4.2: Error for type 'restricted'.
The particle of the type is not a valid restriction of the particle of the base
SAX Error:
System ID: file:///usr/local/websites/astro/test.xsd
Public ID: unknown
Column: 36 Line: 21


============== XMLSCHEMA ===============

<?xml version="1.0"?>
<xs:schema targetNamespace="test"
elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="test">

<xs:group name="myGroup" >
<xs:choice>
<xs:element name="two" type="xs:token"/>
<xs:element name="three" type="xs:token"/>
</xs:choice>
</xs:group>

<xs:complexType name="base">
<xs:sequence>
<xs:group ref="myGroup"/>
<xs:element name="one" type="xs:token" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="restricted">
<xs:complexContent>
<xs:restriction base="base">
<xs:group ref="myGroup"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>

<xs:element name="root" type="restricted"/>
</xs:schema>

============== XML FILE ====================

<root xmlns="test" xsi:schemaLocation="test test.xsd"
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<three/>
</root>
- --
Cat

http://www.ratrobot.com/java/pollhandler/ A simple Java Servlet
that takes referrals from web polls and allows you to easily display the
results with jsp pages.
Wed Jun 23 22:32:13 UTC 2004
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA2gTtKHRjYtwQ1QARAon4AKDcX8r+nyBO140Fhr7QS0NnZOEzOQCfQ8jf
4lEpIbLzrCY5/rq3L8RvAdU=
=mksV
-----END PGP SIGNATURE-----
 
H

Henry S. Thompson

Cat said:
I'm having trouble getting my head around the reason the that
following file won't validate with the following error output in
Xerces version 2.6.0 and XSLTC version 2.5.2 ( from the standard
jdk1.5.0 beta ). Is there something I'm missing from the spec?

cos-particle-restrict.2: Forbidden particle restriction:
'choice:all,sequence,elt'.

I read this as saying "you can't restrict a sequence with a choice",
which is what you're trying to do. Try wrapping the <choice> in a
<sequence> in the 'restricted' type.

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: (e-mail address removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 
C

Cat

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I read this as saying "you can't restrict a sequence with a choice",
which is what you're trying to do. Try wrapping the <choice> in a
<sequence> in the 'restricted' type.
Thanks for the reply Henry,
I think I'm starting to get my head around the
problem. As the preceding part of the specification says
'Any pointless occurrences of <sequence>, <choice> or <all> are ignored'
.. The follow examples prove your point in the first example here which still
fails to validate. While the second example where a meaningful <xs:sequence/>
was added *DOES* validate.

=========== example 1 ===================

<?xml version="1.0"?>
<xs:schema targetNamespace="test"
elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="test">

<xs:group name="myGroup" >
<xs:choice>
<xs:element name="two" type="xs:token"/>
<xs:element name="three" type="xs:token"/>
</xs:choice>
</xs:group>

<xs:complexType name="base">
<xs:sequence>
<xs:group ref="myGroup"/>
<xs:element name="one" type="xs:token" minOccurs="0"/>
<xs:element name="four" type="xs:token" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="restricted">
<xs:complexContent>
<xs:restriction base="base">
<xs:sequence>
<xs:group ref="myGroup"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>

<xs:element name="root" type="restricted"/>
</xs:schema>

=========== example 2 ==========

<?xml version="1.0"?>
<xs:schema targetNamespace="test"
elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="test">

<xs:group name="myGroup" >
<xs:choice>
<xs:element name="two" type="xs:token"/>
<xs:element name="three" type="xs:token"/>
</xs:choice>
</xs:group>

<xs:complexType name="base">
<xs:sequence>
<xs:group ref="myGroup"/>
<xs:element name="one" type="xs:token" minOccurs="0"/>
<xs:element name="four" type="xs:token" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="restricted">
<xs:complexContent>
<xs:restriction base="base">
<xs:sequence>
<xs:group ref="myGroup"/>
<xs:element name="one" type="xs:token" minOccurs="0"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>

<xs:element name="root" type="restricted"/>
</xs:schema>

It's actually been about 2 1/2 years since I asked a question in a newsgroup
usually I just goog..

http://lists.w3.org/Archives/Public/xmlschema-dev/2003Oct/0027.html

6 degrees of separation indeed 8^) . I'll grok a little harder next time.

My current understanding is that it's due to the functionality of the
<xs:choice/> vs <xs:sequence/> right? A <xs:choice/> can be constrained to
represent a <xs:sequence/> but there isn't a way to properly constrain a
<xs:sequence/> to a <xs:choice/> right?
- --
Cat

http://www.ratrobot.com/java/pollhandler/ A simple Java Servlet
that takes referrals from web polls and allows you to easily display the
results with jsp pages.
Fri Jun 25 03:03:10 UTC 2004
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA25XuKHRjYtwQ1QARAhOVAKCiiM9vbBymWzytT+IqmHkIF1vfDQCgnR4c
497AfQW2+ACLrlfM91Y79Hs=
=78xD
-----END PGP SIGNATURE-----
 
H

Henry S. Thompson

Cat said:
I think I'm starting to get my head
around the problem. As the preceding part of the specification says
'Any pointless occurrences of <sequence>, <choice> or <all> are
ignored' . The follow examples prove your point in the first example
here which still fails to validate. While the second example where a
meaningful <xs:sequence/> was added *DOES* validate.

Yup. The 'pointless occurrence' stuff fixed a bunch of problems, but
introduced a few as well, and you've found one of the latter.
My current understanding is that it's due to the functionality of the
<xs:choice/> vs <xs:sequence/> right? A <xs:choice/> can be constrained to
represent a <xs:sequence/> but there isn't a way to properly constrain a
<xs:sequence/> to a <xs:choice/> right?

Yes.

The XML Schema WG hope we'll soon be in a position to do better, and
allow things that clearly _ought_ to be valid restrictions to actually
_be_ valid restrictions :).

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: (e-mail address removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top