wood burning stoves*
The moose likes XML and Related Technologies and the fly likes xsd:all / xsd:group troubles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xsd:all / xsd:group troubles" Watch "xsd:all / xsd:group troubles" New topic
Author

xsd:all / xsd:group troubles

Guy Allard
Ranch Hand

Joined: Nov 24, 2000
Posts: 776
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

Joined: Oct 05, 2003
Posts: 2
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

Joined: Oct 05, 2003
Posts: 2
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

Joined: Jan 23, 2002
Posts: 11962
    
    5
Warren, there's a checkbox in the edit post view for disabling smilies. I always forget it myself, but it's there...


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: xsd:all / xsd:group troubles