473,785 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:simpleTy pe name="currencyS ymbol">
<xsd:restrictio n base="xsd:strin g">
<xsd:enumeratio n value="UKL"/>
<xsd:enumeratio n value="USD"/>
<xsd:enumeratio n value="AUD"/>
</xsd:restriction >
</xsd:simpleType>

<xsd:element name="customers ">
<xsd:complexTyp e>

<xsd:sequence >

<xsd:element name="companySh areDetails"
minOccurs="1" maxOccurs="unbo unded"

<xsd:complexTyp e>
<xsd:sequence >
<xsd:element name="companyCo de" type="xsd:strin g"/>
<xsd:element name="symbol" type="currencyS ymbol"/>
<xsd:element name="currency" type="xsd:strin g"
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>

<companyShareDe tails>
<companyCode>UP C2331</companyCode>
<symbol>USD</symbol>
</companyShareDet ails>

<companyShareDe tails>
<companyCode>GE C1045</companyCode>
<symbol>UKL</symbol>
</companyShareDet ails>
<companyShareDe tails>
<companyCode>GE C1045</companyCode>
<symbol>UKL</symbol>
<currency>UKL </currency>
</companyShareDet ails>

<companyShareDe tails>
<companyCode>BA E4491</companyCode>
<symbol>UKL</symbol>
<currency>GBP </currency>
</companyShareDet ails>

<companyShareDe tails>
<companyCode>CC M9002</companyCode>
<symbol>UKL</symbol>
<currency>STG </currency>
</companyShareDet ails>

</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><currenc y>GBP</currency> is valid.
<symbol>UKL</symbol><currenc y>UKL</currency> is valid.
<symbol>UKL</symbol><currenc y>STG</currency> is valid.
<symbol>UKL</symbol> is valid.
<symbol>UKL</symbol><currenc y>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 5063

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

Similar topics

1
2726
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 is a subset of the other. I will describe one part of the schema to give you an idea of what my problem is. The "big" schema calls for 0 or more selector elements, each containing a (required) name attribute and simple character data, as...
2
1625
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 "a2", but never both of them)? Thanks in advance, Puck.
2
2408
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> <ipaddress>1.2.3.4</ipaddress> <hostname>qwerty</hostname> <dnsserver>7.7.7.7</dnsserver> </networkinfo>
3
1834
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 instance document and then planning to automatically generate the XML file from these 2 schema files using the XMLSpy tool.
2
4194
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" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/, are causing trouble. I tried to create schema using xmlspy and I get an error saying name "b:dt" cannot have a namespace prefix. I am new to xml. Can somebody please help with schema. <appointments> <appointment>
1
1991
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 than a plain vanilla schema, but doesn't strike me as obscenely complex. Are there general rules for what can an can not be mapped between any XSD schema & a .net DataSet? Thanks
1
6408
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 reference this wsdl in .NET it seems to do it fine, yet there are no objects to reference except RateQuoteBeanService. In the WSDL it looks like there should be getRateQuote, and QUOTEREQUEST, etc.
4
1306
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> </exception1>
0
2632
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 the particle of the base this xsd file is valid as per w3c standard i am also providing error in detail and geometry.xsd file geometry.xsd <?xml version="1.0" encoding="UTF-8"?> <schema targetNamespace="http://www.opengis.net/gml"...
0
2825
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? Here’s a working example: <xs:schema id="schema" targetNamespace="http://tempuri.org/schema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/schema.xsd" xmlns:mstns="http://tempuri.org/schema.xsd" ...
0
10330
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10093
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.