• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

xsd:all / xsd:group troubles

 
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
reply
    Bookmark Topic Watch Topic
  • New Topic