Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Xerces doesn't like choice of empty group

Reply
Thread Tools

Xerces doesn't like choice of empty group

 
 
Ray Lischner
Guest
Posts: n/a
 
      02-21-2007
I have a schema that contains a choice of groups, and one of the groups
contains an empty sequence. I can validate an XML document and the
schema with some validators, but not Xerces. It says "Empty content not
valid for content model: '((one,two)|((a,b),c))', which indicates that
it is ignoring the "empty" group. I think Xerces is wrong, but I'm not
100% certain. What do you think?

The schema is:

<?xml version="1.0" ?>
<xsd:schema xmlnssd="http://www.w3.org/2001/XMLSchema">
<xsd:group name="empty">
<xsd:sequence/>
</xsd:group>
<xsd:group name="numbers">
<xsd:sequence>
<xsd:element name="one" type="xsd:int"/>
<xsd:element name="two" type="xsd:int"/>
</xsd:sequence>
</xsd:group>
<xsd:group name="letters">
<xsd:sequence>
<xsd:element name="a" type="xsd:string"/>
<xsd:element name="b" type="xsd:string"/>
<xsd:element name="c" type="xsd:string"/>
</xsd:sequence>
</xsd:group>
<xsd:complexType name="list">
<xsd:sequence>
<xsd:element name="item" minOccurs="1" maxOccurs="3">
<xsd:complexType mixed="true">
<xsd:choice>
<xsd:group ref="empty"/>
<xsd:group ref="numbers"/>
<xsd:group ref="letters"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="root" type="list"/>
</xsd:schema>

Here's a sample XML document:

<?xml version="1.0" encoding="utf-8" ?>
<root xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="test.xsd">
<item>Nothing</item>
<item>Numbers
<one>1</one>
<two>2</two>
</item>
<item>Letters
<a>A</a>
<b>B</b>
<c>C</c>
</item>
</root>

Who's right, Xerces or me? Thanks.
--
Ray Lischner, Proteus Technologies
 
Reply With Quote
 
 
 
 
usenet@tech-know-ware.com
Guest
Posts: n/a
 
      02-21-2007
On 21 Feb, 03:41, Ray Lischner <(E-Mail Removed)> wrote:
> I have a schema that contains a choice of groups, and one of the groups
> contains an empty sequence. I can validate an XML document and the
> schema with some validators, but not Xerces. It says "Empty content not
> valid for content model: '((one,two)|((a,b),c))', which indicates that
> it is ignoring the "empty" group. I think Xerces is wrong, but I'm not
> 100% certain. What do you think?
>
> The schema is:
>
> <?xml version="1.0" ?>
> <xsd:schema xmlnssd="http://www.w3.org/2001/XMLSchema">
> <xsd:group name="empty">
> <xsd:sequence/>
> </xsd:group>
>...
> <xsd:complexType name="list">
> <xsd:sequence>
> <xsd:element name="item" minOccurs="1" maxOccurs="3">
> <xsd:complexType mixed="true">
> <xsd:choice>
> <xsd:group ref="empty"/>
> <xsd:group ref="numbers"/>
> <xsd:group ref="letters"/>
> </xsd:choice>
> </xsd:complexType>


I'm afraid I'm not sure of what the exact intent of the spec is here
either. But if you expand your empty group into your choice you get:

<xsd:choice>
<xsd:sequence/>
<xsd:group ref="numbers"/>
<xsd:group ref="letters"/>
</xsd:choice>

Hence there is nothing of substance in the empty group, and probably
why it ignores it.

If you want to allow an empty option, you could try:

<xsd:choice minOccurs="0">
<xsd:group ref="numbers"/>
<xsd:group ref="letters"/>
</xsd:choice>

HTH,

Pete.
--
=============================================
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx
(or http://www.xml2cpp.com)
=============================================

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
c++ as choice for long term application choice. miles.jg C++ 16 11-14-2007 03:43 PM
Upgrade of Xalan 1.2.2 and Xerces 1.4.4 to Xalan 2.6 and Xerces 2.6.2 cvissy XML 0 11-16-2004 07:06 AM
Can Choice components respond to keyboard input like HTML Choice components? Mickey Segal Java 0 02-02-2004 10:59 PM
Choice of DHCP-server? Is the "IOS-one" a good choice? Fred Cisco 1 12-11-2003 06:25 AM
Re: Which group is the PC discussion group (like comp.sys.mac.----)? LooseLips Computer Support 0 08-03-2003 08:37 AM



Advertisments