473,602 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Co-occurrence Constraints

Hi,

Eric van der Vlist's book XML Schema says that we can use xs:key to declare
co-occurrence constraints. The example he uses (boiled down a bit) is a
"book" element that must have either an "isbn" attribute or an "isbn" child
element, but not both:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace ="http://www.example.com "
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.example.com "
elementFormDefa ult="qualified" >

<xs:element name="book">
<xs:complexType >
<xs:sequence>
<xs:element name="isbn" type="xs:string " minOccurs="0"/>
</xs:sequence>
<xs:attribute name="isbn" type="xs:string "/>
</xs:complexType>

<xs:key name="dummy">
<xs:selector xpath="."/>
<xs:field xpath="isbn|@is bn"/>
</xs:key>

</xs:element>

</xs:schema>

Now, if the isbn attribute (only) is present, it validates fine. But if the
isbn child (only) is present, I get the following validation error:

The identity constraint 'http://www.example.com :dummy' validation has failed
due to either a key is missing or the exsisting key has an empty node.

And if both the attribute and child are present, I get no validation error
(which is wrong).

I am using Visual Studio .NET, hence the .NET Framework version 1.0. Am I
experiencing a limitation in Microsoft's support for XML Schema, or am I
missing something? Any insights appreciated!
Eric W. Sirko
Nov 12 '05 #1
2 1775
Hi Eric,

XPath expressions like (isbn|@isbn) are not affected by default namespace
declarations. Therefore, you must assign a prefix to the target namespace
and use that prefix in the XPath expression, or it won't find the isbn
element. So, it should look like this:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace ="http://www.example.com "
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ex="http://www.example.com "
elementFormDefa ult="qualified" >

<xs:element name="book">
<xs:complexType >
<xs:sequence>
<xs:element name="isbn" type="xs:string " minOccurs="0"/>
</xs:sequence>
<xs:attribute name="isbn" type="xs:string "/>
</xs:complexType>

<xs:key name="dummy">
<xs:selector xpath="."/>
<xs:field xpath="ex:isbn| @isbn"/>
</xs:key>

</xs:element>

</xs:schema>

Hope that helps,
Priscilla
------------------------------------------------------------------
Priscilla Walmsley
Author, Definitive XML Schema / XML in Office 2003
http://www.datypic.com
------------------------------------------------------------------

"Eric W. Sirko" <es****@sw-sol.com> wrote in message
news:ed******** *****@TK2MSFTNG P12.phx.gbl...
Hi,

Eric van der Vlist's book XML Schema says that we can use xs:key to
declare
co-occurrence constraints. The example he uses (boiled down a bit) is a
"book" element that must have either an "isbn" attribute or an "isbn"
child
element, but not both:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace ="http://www.example.com "
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.example.com "
elementFormDefa ult="qualified" >

<xs:element name="book">
<xs:complexType >
<xs:sequence>
<xs:element name="isbn" type="xs:string " minOccurs="0"/>
</xs:sequence>
<xs:attribute name="isbn" type="xs:string "/>
</xs:complexType>

<xs:key name="dummy">
<xs:selector xpath="."/>
<xs:field xpath="isbn|@is bn"/>
</xs:key>

</xs:element>

</xs:schema>

Now, if the isbn attribute (only) is present, it validates fine. But if
the
isbn child (only) is present, I get the following validation error:

The identity constraint 'http://www.example.com :dummy' validation has
failed
due to either a key is missing or the exsisting key has an empty node.

And if both the attribute and child are present, I get no validation error
(which is wrong).

I am using Visual Studio .NET, hence the .NET Framework version 1.0. Am I
experiencing a limitation in Microsoft's support for XML Schema, or am I
missing something? Any insights appreciated!
Eric W. Sirko

Nov 12 '05 #2
Thanks, that makes sense. But it makes no difference (well, maybe it's
different, but it still doesn't work properly). The Microsoft validating
parser just blows, I guess..

Eric
"Priscilla Walmsley" <no****@datypic .com> wrote in message
news:#h******** ******@TK2MSFTN GP11.phx.gbl...
Hi Eric,

XPath expressions like (isbn|@isbn) are not affected by default namespace
declarations. Therefore, you must assign a prefix to the target namespace
and use that prefix in the XPath expression, or it won't find the isbn
element. So, it should look like this:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace ="http://www.example.com "
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ex="http://www.example.com "
elementFormDefa ult="qualified" >

<xs:element name="book">
<xs:complexType >
<xs:sequence>
<xs:element name="isbn" type="xs:string " minOccurs="0"/>
</xs:sequence>
<xs:attribute name="isbn" type="xs:string "/>
</xs:complexType>

<xs:key name="dummy">
<xs:selector xpath="."/>
<xs:field xpath="ex:isbn| @isbn"/>
</xs:key>

</xs:element>

</xs:schema>

Hope that helps,
Priscilla
------------------------------------------------------------------
Priscilla Walmsley
Author, Definitive XML Schema / XML in Office 2003
http://www.datypic.com
------------------------------------------------------------------

"Eric W. Sirko" <es****@sw-sol.com> wrote in message
news:ed******** *****@TK2MSFTNG P12.phx.gbl...
Hi,

Eric van der Vlist's book XML Schema says that we can use xs:key to
declare
co-occurrence constraints. The example he uses (boiled down a bit) is a
"book" element that must have either an "isbn" attribute or an "isbn"
child
element, but not both:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace ="http://www.example.com "
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.example.com "
elementFormDefa ult="qualified" >

<xs:element name="book">
<xs:complexType >
<xs:sequence>
<xs:element name="isbn" type="xs:string " minOccurs="0"/>
</xs:sequence>
<xs:attribute name="isbn" type="xs:string "/>
</xs:complexType>

<xs:key name="dummy">
<xs:selector xpath="."/>
<xs:field xpath="isbn|@is bn"/>
</xs:key>

</xs:element>

</xs:schema>

Now, if the isbn attribute (only) is present, it validates fine. But if
the
isbn child (only) is present, I get the following validation error:

The identity constraint 'http://www.example.com :dummy' validation has
failed
due to either a key is missing or the exsisting key has an empty node.

And if both the attribute and child are present, I get no validation error (which is wrong).

I am using Visual Studio .NET, hence the .NET Framework version 1.0. Am I experiencing a limitation in Microsoft's support for XML Schema, or am I
missing something? Any insights appreciated!
Eric W. Sirko


Nov 12 '05 #3

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

Similar topics

8
1536
by: Malcolm Clift | last post by:
Hi All, Using wx, I'm trying to draw all items in a range of 50 in a text at certain co -ordinates (a simply textwrap) . A while back Alex Martelli was kind enough to give me the following to work with ; for i in range(len(text)): dc.DrawText(text, 100, 100 + ( i // 50 *200) I have slightly changed this to control the spacing between the
0
1767
by: melledge | last post by:
Mozilla Foundation Co-Hosts Europe's Leading XML and Web Developer Conference XTech 2005 Conference to Bring Together XML and Web Technology Thought Leaders
1
3452
by: Lee J. Moore | last post by:
I've spent a day writing software that will generate a multi-page/level family tree from a single HTML template and a Gedcom file, yet what seems like a minor issue with the CSS in the template is just confounding me. :( Here's my CSS code which applies a background graphic (the branches linking the ancestors) to the table: table.outer-table { width: 430px; background: url(images/tree.gif) no-repeat 0px 0px;
1
2180
by: relisoft | last post by:
SEATTLE, Washington. - July 12, 2006: Reliable Software® announces the upcoming release of Code Co-op® version 5.0. Code Co-op is an affordable peer-to-peer version control system for distributed development enabling collaboration through Email, LAN, or VPN-no server required. The upcoming release of Code Co-op 5.0 is due out this fall. With this release Reliable Software continues its track record of innovation by introducing...
2
1650
by: Mike | last post by:
I am using a server-side component for resizing/cropping images. Cropping is possible if I know the co-ordinates. I want to be able to offer users the ability to specify their own co-ordinates. It seems to me that the easiest way to do this is to try to partially emulate an image editing app's Marquee tool, where a user clicks on an image to define the top left point and drags and releases at the bottom right point. My questions are: ...
5
1251
by: dm3281 | last post by:
Hi all -- We currently have an ecommerce application installed on a W2K Advanced server running .NET 1.1. In November, I installed .NET 2.0 in order to allow a Windows Forms application I wrote to be run on the server for extracting system information. We have recently had an issue with our ecommerce application where we would
8
2184
by: john | last post by:
To test a new piece of software designed to help with (among other things) eCommerce WWW site development. The software is fairly easy to use but you must fit a profile. Retail price is 120 GBP and I'll email full releases to anyone who helps FOC of course: Profile: I'm looking for someone who fits a profile - You must be willing to spend some time with the software and report back
1
1472
by: kailashchandra | last post by:
Hello Everybody i am trying to get co-ordinate position of mouse using java script using the following code.it works fine on IE and other but it is not working on mozilla.i couldn't understand why?please Help me. My code is like below:- <html> <body> <script language="JavaScript"> document.onmousemove = getCoordinate; var mosX = 0 ; var mosY = 0 ;
1
1330
by: =?Utf-8?B?QWJoaXNoZWsgUmFp?= | last post by:
Hi, I am working on the application which is based on the co-ordinate system it will support on different language(Globalization). My problem is to how can get relative co-ordinate in different resolution like(1024x768 or 800x600) in different culture. (e.g. if I store one point co ordinate like (100,100) in 1024x768 resolution with en-us what's the coordinates in 800x600 resolution) Italian language.
0
7993
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
7920
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8268
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...
0
6730
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...
1
5867
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
3900
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...
1
2418
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
1
1510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1254
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.