[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] References in 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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|