472,958 Members | 2,240 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

XML schema extension question

Hi there, firstly thank you for thinking about this problem of mine.
This is a long message because I want to put all the facts (the XML
and the schema) to try to get a solution from you helpful readers of
the newsgroup.

Here is my problem. I have defined the following XML schema.

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:simpleType name="currencySymbol">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="UKL"/>
<xsd:enumeration value="USD"/>
<xsd:enumeration value="AUD"/>
</xsd:restriction>
</xsd:simpleType>

<xsd:element name="customers">
<xsd:complexType>

<xsd:sequence>

<xsd:element name="companyShareDetails"
minOccurs="1" maxOccurs="unbounded"

<xsd:complexType>
<xsd:sequence>
<xsd:element name="companyCode" type="xsd:string"/>
<xsd:element name="symbol" type="currencySymbol"/>
<xsd:element name="currency" type="xsd:string"
minOccurs="0" maxOccurs="1"
/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

</xsd:sequence>

</xsd:complexType>
</xsd:element>

</xsd:schema>
Here is an example of the type of XML validated by this schema. This
XML is valid according to this schema.

<customers>

<companyShareDetails>
<companyCode>UPC2331</companyCode>
<symbol>USD</symbol>
</companyShareDetails>

<companyShareDetails>
<companyCode>GEC1045</companyCode>
<symbol>UKL</symbol>
</companyShareDetails>
<companyShareDetails>
<companyCode>GEC1045</companyCode>
<symbol>UKL</symbol>
<currency>UKL</currency>
</companyShareDetails>

<companyShareDetails>
<companyCode>BAE4491</companyCode>
<symbol>UKL</symbol>
<currency>GBP</currency>
</companyShareDetails>

<companyShareDetails>
<companyCode>CCM9002</companyCode>
<symbol>UKL</symbol>
<currency>STG</currency>
</companyShareDetails>

</customers>
But I would like it to be validated so that when <currency> is
present, then the element can only be certain values. Furthermore the
values it can be will vary for each <symbol>. The allowed values will
be different for every currency because there is often more than one
valid currency symbol for a currency (including historical data,
Germany is now Euro but of course used to also be the Mark), and the
UK has lots of currency symbols because it just does.

ie <symbol> <currency>
UKL 'UKL' United Kingdom Pounds
UKL 'STG' United Kingdom Pounds (Sterling)
UKL 'GBP' United Kingdom Pounds

USD 'USD' United States Dollar

DEM 'DEM' Deutche Mark
DEM 'EUR' Euro

JPY 'JPY' Japanese Yen
JPY 'YEN' Japanese Yen

So <symbol>UKL</symbol><currency>GBP</currency> is valid.
<symbol>UKL</symbol><currency>UKL</currency> is valid.
<symbol>UKL</symbol><currency>STG</currency> is valid.
<symbol>UKL</symbol> is valid.
<symbol>UKL</symbol><currency>EUR</currency> IS NOT VALID.

My question is can my XML schema be extended so that when <symbol> is
present, it can only be allowed predefined values. I want the solution
to be elegant, I do not want to have to create a 'Facet' for each
currency <symbol>.

Thank you
Tony
Jul 20 '05 #1
0 4995

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gregg Williams | last post by:
Hi--I am having a problem designing a schema to fit my XML data, and I'm hoping that someone can help. Essentially, I have a schema in mind and two target vocabularies for it, where one vocabulary...
2
by: Gehirnloser Zombie | last post by:
Hello folks, Short question: Is it possible to express with XML-Schema that for an element some attributes may apear only disjunctivly (i.e. an element <E> can either carry the attribute "a1" OR...
2
by: inquirydog | last post by:
I am trying to store my computer network information in an xml file, and plan to write an xml schema for the file. The general format of the xml should be like this <networkinfo>...
3
by: Kanchana D S | last post by:
Hi, I am trying to design the schema for an XML file. The approach that I am planning to follow is to have 2 XSD files, each containing some relevant information about the elements in the...
2
by: M Rao | last post by:
I have xml data coming in as a stream from a web service running against exchange server.The attributes for the elements dtstart and dtend, b:dt="dateTime.tz"...
1
by: David Laub | last post by:
The following valid XSD schema can NOT be successfully read by the ReadXMLSchema method of the DataSet object - it errors out with a "NonEmptyString not defined" error. This schema is more complex...
1
by: billa1972 | last post by:
Hi, I am trying to hook into Yellow Freight's rating webservice. Below is the wsdl. When i try and create a proxy file with wsdl.exe i get the following errors, see below. Also, when i...
4
by: olivier.scalbert | last post by:
Hello, I need to create an xsd to validate the following type of xml: <?xml version="1.0" encoding="UTF-8"?> <root <exception1 xsi:type="ExceptionAType"> <Type>1</Type> <Info>Bla bla</Info>...
0
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
0
by: icesign | last post by:
I know that the selector of these elements has a scope relative to the element being declared, but maybe there is a way to get beyond bounds of this scope or maybe just a way to extend base element?...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.