473,473 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Schema - How to ensure that attributes are different?

2 New Member
I'm utterless clueless on how I can go about declaring in my schema that two attributes must contain different values, e.g.

Expand|Select|Wrap|Line Numbers
  1. <mail to="" from="">Text</mail>
How do I set the restriction in the schema that the "to" attribute and "from" attribute must contain different values? Hence 'to="Amy" from="Bob"' will validate, while 'to="Amy" from="Amy"' will fail the validation?

Hope to hear from this community soon. Thanks!
Jun 22 '09 #1
3 1709
jkmyoung
2,057 Recognized Expert Top Contributor
Unfortunately, I do not know of any way to do this using just xml schema. Are you allowed to use other validation tools such as RelaxNG or SchemaTron?
Jun 22 '09 #2
hammie
2 New Member
Sorry, I'm limited to using W3C - unless I break with the standard (in my project team, that is) and use a different schema type *plus* rebuild the schema for the rest of the XML.. Which is pretty long, so I'm hoping that there's a W3C-schema-solution somewhere out there!

Out of curiosity, how would I restrict the attribute values as mentioned in RelaxNG/SchemaTron? Thanks!
Jun 23 '09 #3
jkmyoung
2,057 Recognized Expert Top Contributor
Not quite an expert in schematron, but it'd be something like:
Expand|Select|Wrap|Line Numbers
  1. <pattern name="Unique atribute"> 
  2.   <rule context="mail"> 
  3.     <assert test="@to != @from">Sender and recipient are the same.</assert> 
  4.  
Jun 23 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Pieter | last post by:
I've read a lot of posts on "why relax ng is so very good" and on "why w3c xml schema should be the only schema language". I'm, however, still not clear on why I should prefer one over the other. ...
5
by: Ralf Wahner | last post by:
Dear Masters of XML As I'm new to XML Schema I dare to ask a possibly recurring question: Given an element <elem> with two attributes @a and @b. The attributes are bound by the condition, that...
2
by: wumingshi | last post by:
Hi, When validating an XML instance, sometimes the schema is not enough to expression the validation rules. Additional validation rules may be expressed in an application-specific way. For...
2
by: Shailendra Batham | last post by:
Hello Gurus, I want to put some restrictions on my attribute tag in my XML Schema, anyone out there have any idea how to do that. here is my XML and the XML Schema <?xml version="1.0"...
6
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a...
2
by: Chuck Bowling | last post by:
AIML Schema: http://209.168.21.76/CommunityStarterKit/Downloads/258.aspx I have a Schema (in the link above) that I've been trying to make work in VS2003 for a while now and just can't seem to...
4
by: craig.wagner | last post by:
I have a situation where I need to carry additional information in an XML Schema. What I've found to appear to work is doing something like the following: <xs:schema xmlns:xs="...
0
by: Mark Ingram | last post by:
Hi, i want to ensure that an xml file has been created properly, but i dont want to rely on the creator of the xml file to correctly enter the required namespaces (without the correct namespaces...
3
by: kkao77 | last post by:
I am trying to use schema to validate the data that user sent to my service. How do I achieve that using schema? Do I give schema to the client? or do I write my own schema validation inside web...
0
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,...
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
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...
1
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...
1
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...
0
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...
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.