473,657 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xml schema: rule between atribute value in one element

I need know how define xml schema for this xml fragment:

<set name="person-id" value="secure-card"/>
<set name="person-id" value="thumb-print"/>

<set name="length-unit" value="inch"/>
<set name="length-unit" value="cm"/>

so if name="person-id", then value can contain only one of value
"secure-card","thumb-print".
if name="length-unit", then value can contain only one of value
"inch","cm"
Jul 20 '05 #1
2 1543
You can't define that in XML Schema. What you can do is define the
following:

<personID value="secure-card"/>
<personID value="thumb-print"/>
<lengthUnit value="inch"/>
<lengthUnit value="cm"/>

using the following schema:

<xs:element name="personID" >

<xs:complexType >

<xs:attribute name="value" type="personAtt "/>

</xs:complexType>

</xs:element>

<xs:element name="lengthUni t">

<xs:complexType >

<xs:attribute name="value" type="lengthAtt "/>

</xs:complexType>

</xs:element>

<xs:simpleTyp e name="personAtt ">

<xs:restricti on base="xs:string ">

<xs:enumerati on value="secure-card"/>

<xs:enumerati on value="thumb-print"/>

</xs:restriction>

</xs:simpleType>

<xs:simpleTyp e name="lengthAtt ">

<xs:restricti on base="xs:string ">

<xs:enumerati on value="inch"/>

<xs:enumerati on value="cm"/>

</xs:restriction>

</xs:simpleType>
--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"ocelka" <oc****@ics.mun i.cz> wrote in message
news:2b******** *************** ***@posting.goo gle.com...
I need know how define xml schema for this xml fragment:

<set name="person-id" value="secure-card"/>
<set name="person-id" value="thumb-print"/>

<set name="length-unit" value="inch"/>
<set name="length-unit" value="cm"/>

so if name="person-id", then value can contain only one of value
"secure-card","thumb-print".
if name="length-unit", then value can contain only one of value
"inch","cm"

Jul 20 '05 #2
To ht best of my knowledge -- I dont think XML Schema supports your
conditional kind of validation.

I suggest taking a look at an alternative way i.e. XML Schematron
(Conditional Constraints are supported). Or you could think in terms of
XSLT itself i.e. write an XSLT that will be used as a way to validate.
However I am not sure if the this would be worth in the effort in the
overall context of what you are trying to validate here.

Jul 20 '05 #3

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

Similar topics

0
2212
by: Lewis G. Pringle, Jr. | last post by:
Folks: I have some XML text I'm tranforming from one schema to another. Both schemas have their own notion of 'address' (as well as many other contepts). XSL seems to be mainly suited to transforming XML types based on their name. For example: <xsl:template match="user-address"> <xsl:element name="Addr"> <xsl:element name="Addr1"><xsl:value-of select="line-1"/></xsl:element>
4
2286
by: bibsoconner | last post by:
Hi, I hope someone can please help me. I'm having a lot of trouble with schema files in .NET. I have produced a very simple example that uses "include" to include other schema files. It all works with SPY, but when I pick "Validate Schema" from the .NET 2003 menu, it fails with message: "Type XType is not declared." As I hinted at in my subject line, I suspect that it has to do with including another schema multiple times.
2
2247
by: Frosty | last post by:
Howto make datagrid enforce rules of xml schema? Created xml schema in the designer. Constraints created there using the following <xs:simpleType name="zipcode"><xs:restriction base="xs:string"><xs:pattern value="\d{5}" /></xs:restriction></xs:simpleType Datagrid does not enforce this rule, even though dataGrid1_Validating() is called. dataset.WriteXml() saves withouth any warning, but
2
1886
by: mrc-1 | last post by:
Hi, i'd like to validate my XML file (see below) using XML Schema. Now my question: is it possible to limit the occurrence of the element b in the data element. I mean: data can contain up to 10 b elements, but it doesn't matter how the b elements are allocated in the elements a and c. Any help would be appreciated -- thank you!
5
1196
by: Reuven Nisser | last post by:
Hi, How can I describe an XML like this: <X> <Y/> <Z/> <Y/> <Y/> </X>
5
3409
by: j.tremlett | last post by:
Hi, I have read various articles on this and I have had a few suggestions but would like to know which is correct. I have an XML file with the element <root> Within <root> I can have a number of child elements occuring in any order and any number of times.
4
1216
by: cmay | last post by:
I am beginning to wonder if it is not possible to get this working. I am trying to do: <root> <a/> <b/> <c/> </root>
1
373
by: Nichino | last post by:
Hello, I'm trying to define my first Xml Schema and have a problem. The XML I'd like to define through the Schema is the following one. Can you help me please? I don't know how to insert the 3 final notes. Many thanks and my apologies for the trouble. Best, Nick <language>
9
3008
by: mstilli | last post by:
Hi, I am trying to use schema for server side validation using xerces to catch the validation errors. validating this XML: <Content4> <textarea13></textarea13> <binaryobject3></binaryobject3>
0
8403
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8833
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...
0
8737
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
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
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1730
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.