[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

References in XSD/XML

  • To: xml-dev@l...
  • Subject: References in XSD/XML
  • From: =?ISO-8859-15?Q?Alain_T=E9sio?= <ate@n...>
  • Date: Sun, 07 Dec 2003 15:13:34 +0100
  • User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US) Gecko/20031007

xsd xml
Hi, I'm having problems writing a schema with elements referencing each
other. I've written a large schema with several business objects defined
in complex types.

Let's say I have two complex types "asset" and "order" in the namespace
"test", "order" has an element with the type "test:asset"

Here is the .xsd file :

================= test.xsd
<?xml version="1.0" encoding="iso-8859-1"?>
<xs:schema targetNamespace="Test" xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:test="Test" elementFormDefault="qualified" 
attributeFormDefault="unqualified">
	<xs:complexType name="order">
		<xs:sequence>
			<xs:element name="Reference" type="xs:string"/>
			<xs:element name="Status" type="xs:string"/>
			<xs:element name="Asset" type="test:asset"/>
		</xs:sequence>
		<xs:attribute name="ID" type="xs:long" use="required"/>
	</xs:complexType>
	<xs:complexType name="asset">
		<xs:sequence>
			<xs:element name="ISINCode" type="xs:string"/>
			<xs:element name="Designation" type="xs:string"/>
		</xs:sequence>
		<xs:attribute name="ID" type="xs:long" use="required"/>
	</xs:complexType>
	<xs:element name="testObjects">
		<xs:complexType name="testEntity">
			<xs:choice>
				<xs:element name="order" type="test:order"/>
				<xs:element name="asset" type="test:asset"/>
			</xs:choice>
		</xs:complexType>
	</xs:element>
</xs:schema>
=================

And here is a valid xml file for this schema:

================= test.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<testObjects xmlns="Test" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="Test 
C:\tmp\test.xsd">
	<order ID="951">
		<Reference>ATE-030912113020</Reference>
		<Status>Executed</Status>
		<Asset ID="5709">
			<ISINCode>FR0000060899</ISINCode>
			<Designation>BACOU DALLOZ</Designation>
		</Asset>
	</order>
</testObjects>
=================


What I'd like is to define the second object "asset" outside the
object "order", and have a single line in "order" referencing it
with its id, I can have several objects with the same type in one
xml file.

I think I can do this with elements and ref to elements but the
number and types of elements in the xml file depends on the object.

Thanks for your time

Alain



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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