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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Help with an XSD problem

[ Lists Home | Date Index | Thread Index ]

Title: Message
I am new to XSD and have spent about 3 hours trying to find out if what I want to do is possible
 
I have a stock element. This element has several child elements eg Currency, number and name. My problem is that I want (if possible to allow a choice re the type_of_stock. I want to limit it to either Equity or Bond - I have found two ways of doing this - either using enumeration or patterns. I have no preference as to which. However if they select BOND I want to force the user to input further elements eg the Interest_rate.
 
Is there any way of doing a test and if I see BOND in the type_of_stock element I ask for the extra elements - or am I trying to achieve the impossible via an automated process
 
<xs:element name="stock">
<xs:complexType>
<xs:sequence>
<xs:element name="Stock_Number"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="1"/>
<xs:maxLength value="20"/>
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Stock_Name">
.
.
</xs:element>
<xs:element ref="Currency">
</xs:element>
<xs:element name="types_of_stock" type="types_of_stock"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexTypename="types_of_stock">
<xs:all>
<xs:element name="Equity">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="EQUITY|BOND"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Bond">
<xs:complexType>
<xs:sequence> <xs:element name="Interest_rate">
<xs:simpleType>
<xs:restriction base="xs:decimal">
</xs:simpleType>
</xs:element>
<xs:element name="Issue_date" type="xs:date"/>
<xs:element name="Expiry_date" type="xs:date"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
 

etc
 
Any suggestions gratefully received
 
Helen



_______________________________________________________________________


The information contained in this email is confidential and is intended

for the use of the addressee only. Any unauthorised dissemination or

copying of this email, and any use of disclosure of information

contained in it, is strictly prohibited and may be illegal.


Please let us know immediately by telephone if the email has been sent

to you in error (+44 1481 711166).

________________________________________________________________________





 

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

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