OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   References in XSD/XML

[ Lists Home | Date Index | Thread Index ]
  • To: xml-dev@lists.xml.org
  • Subject: References in XSD/XML
  • From: =?ISO-8859-15?Q?Alain_T=E9sio?= <ate@nexfi.fr>
  • Date: Sun, 07 Dec 2003 15:13:34 +0100
  • User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US) Gecko/20031007

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






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS