Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

xsd:all / xsd:group troubles

 
Guy Allard
Ranch Hand
Posts: 776
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All- I am having problems with a task I think am sure should be simple.
I am trying to write a schema definition by hand, I do not have schema generation tools available.
A portion of the parsed document has the following characteristics:
-A parent element 'p'.
-Child elements 'ca, 'cb', and 'cc'.
-All child elements must appear 0 or 1 times.
-Child elements may appear in any order.
-Child elements are complex type (does this matter? - I cannot get this working even with simple types).
I have done a lot of experimenting with xsd:all and xsd:group elements. I get various parse exceptions on the schema document depending on how creative I am being.
Can any one point me to a URL example?
Or maybe post some sample schema definition? I know the answer to this is easy ......
Regards, Guy
 
Warren Mitlak
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guy,
I am just learning XML but I have tried out the included XML files with the include XSD schema and it seemed to work OK. You can set minOccurs="0" for any element that you want to allow to include 0 or 1 time in the group. Hope this helps.
Warren
XML #1 ----------------------------------
<?xml version="1.0" ?>
<x arent xmlns:x="urn:books">
<ca>child a</ca>
<cb>child b</cb>
<cc>child c</cc>
</x arent>
XML #2 --------------------------------
<?xml version="1.0" ?>
<x arent xmlns:x="urn:books">
<ca>child a</ca>
<cc>child c</cc>
</x arent>
XSD -------------------------------------
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:books"
xmlns:b="urn:books">
<xsd:element name="parent" type="b arentData"/>
<xsd:complexType name="ParentData">
<xsd:all>
<xsd:element name="ca" type="xsd:string"/>
<xsd:element name="cb" type="xsd:string" minOccurs="0"/>
<xsd:element name="cc" type="xsd:string" />
</xsd:all>
</xsd:complexType>
</xsd:schema>
 
Warren Mitlak
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guy,
I wherever you see a "similies" in my previous post, please substitute a ":p". I didn't realize that Javaranch would convert my text to a face.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Warren, there's a checkbox in the edit post view for disabling smilies. I always forget it myself, but it's there...
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic