aspose file tools*
The moose likes XML and Related Technologies and the fly likes Schema design Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Schema design Help" Watch "Schema design Help" New topic
Author

Schema design Help

Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Hi,
I would like to create a schema such that an element should represent either of the one option tag.
for example the XML document can be either
<Book>
<authorname>John</authorname>
<Book>
(or)
<Book>
<authorId>3423<authorId>
<Book>
but it should not be like this
<Book>
<authorname>John</authorname>
<authorId>4323<authorId>
<Book>
Please tell me whether it is possible to specify this is Schema file (.XSD).due i need to use <xs:choice> tag ??


Spritle Software Blogs
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
I found the answer..
Below is the answer.
<xs:element name="Book">
<xs:annotation>
<xs ocumentation>Root Element</xs ocumentation>
</xs:annotation>
<xs:complexType>
<xs:choice>
<xs:element name="AuthorName"/>
<xs:element name="AuthorID"/>
</xs:choice>
</xs:complexType>
</xs:element>
Please delete if this message,if unnecessary.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Schema design Help