wood burning stoves 2.0*
The moose likes Product and Other Certifications and the fly likes XSD doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "XSD doubt" Watch "XSD doubt" New topic
Author

XSD doubt

Hari babu
Ranch Hand

Joined: Jun 25, 2001
Posts: 208
1.
<xsd:element name="A" type="foo"/>
<xsd:complexType name="foo">
<xsd:sequence>
<xsd:element name="B" �/>
<xsd:element name="C" �/>
</xsd:sequence>
</xsd:complexType>
2.
<xsd:element ref="foo"/>
<xsd:element name="foo">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="B" �/>
<xsd:element name="C" �/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

I have couple of questions
1. Is the 2nd XSD a correct definition ?
2. Whats the diffrence between the two definition. In first i have used "Type". In second it uses "reference"
Can anyone clear my doubts ?
Thanks in advance
Hari
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1167
Hari,
My understanding is that you use types when types are involved.
Sometimes, on the other hand, you just want to break down your schema to more manageable pieces, without introducing new types.
In just a case you can use the reference way.
So, for example, the element toysco is very complex. The customer part is an element, which is referred to by element name in the toysco element. The same is done for the product and invoice elements.

Regards,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Rakesh Gudur
Ranch Hand

Joined: Apr 29, 2002
Posts: 79
Hari babu,
The first one is a named complex type and the second one is an anonymous complex type. As the name suggests, a named complex type can be reused with the name.
In the case of an anonymous complex type, you have to include the complexType definition in an element and refer to the element as given in the second snippet.
In case of named complexType, you can directly refer to the complexType from an element as given in the first snippet.
It is important to note the way the complexType is referred to from the elements in both the cases.
For more details check out the Primer in w3c spec.
Thank you,
Rakesh.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XSD doubt
 
Similar Threads
How to make an element value unique within entire instance document?
Axis 2 Binding question (Important)
XML Schema - doubt..
XML Schemas
Problem with SOAP