473,396 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 5035

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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.