XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
dinesh ramSubject: Schema Newbie
Author: dinesh ram
Date: 11 Jul 2006 11:14 PM
Hi,

This is in regard to usage of global elements in schema. This is the structure for a 'Product' having multiple 'Charge' component.

<xsd:element name="Product">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="Charge" maxOccurs="unbounded" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Name" type="xsd:string" use="optional"/>
<xsd:attribute name="ID" type="xsd:string" use="optional"/>
<xsd:attribute name="Desc" type="xsd:string" use="optional"/>
</xsd:complexType>
</xsd:element>

I have defined Charge component independently.

<xsd:element name="Charge">
<xsd:complexType>
<xsd:attribute name="Amount" type="xsd:string"/>
<xsd:attribute name="Description" type="xsd:string"/>
</xsd:complexType>
</xsd:element>

Should I be using the 'Charge' as a ref directly in Product or should I need to use a element of type 'Charge' in Product structure?

Kindly advise.

Regards

Posttop
Ivan PedruzziSubject: Schema Newbie
Author: Ivan Pedruzzi
Date: 13 Jul 2006 12:55 AM

Hi Dinesh,

It's a design choice.

If you decide to use a reference you need to define a global element as well. All global element are considered when validating a document root.

If you are planning to use "Charge" only as child element of other elements then you should consider to define a global complex type.
See the attached example product-charge.xsd

If you need to create just a group of attributes to re-use you should consider the AttributeGroup construct.
See the attached example product-charge-attributegroup.xsd


Hope this helps
Ivan Pedruzzi
Stylus Studio Team


DocumentProduct-charge.xsd


DocumentProduct-charge-attributegroup.xsd

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.