XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Peter LarbalestierSubject: Key field - duplicate values - NO error
Author: Peter Larbalestier
Date: 14 Oct 2004 06:57 PM
Good morning,

I know I must be doing something wrong but what ?

1. Please find attached relevant simple files.

2. I have declared a unique key

3. I have purposely placed in a duplicate value in the field which I
have set as a unique field

4. Why don't I get an error in SS? In VB .NET IDE I get an error for
the same XML file !

What do I have to do to trigger this error in SS?

Thanks

Pete


ImageVBNet_XML_Error.JPG


DocumentTemplate_Tree.xsd


DocumentTemplateTree.xml

Postnext
Ivan PedruzziSubject: Key field - duplicate values - NO error
Author: Ivan Pedruzzi
Date: 14 Oct 2004 09:06 PM
Peter

Your schema doesn't do what you would like to do; I also try .NET validator and the document passes.

Depending where the unique constraint is defined determines the scope of the uniqueness.

You have defined the unique constraint inside the element "Node", and clearly it passes because is unique within itself

If you move the declaration one level up to the "Nodes" element you enforce the uniqueness among "Nodes" children.

If you really desire to learn schema I suggest buying the best book out there

"Definitive XML Schema" by Priscilla Walmsley
http://www.amazon.com/exec/obidos/tg/detail/-/0130655678/qid=1097802368/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/102-5163643-0718564?v=glance&s=books&n=507846

Here is the modified schema


<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="TreeStructure">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Nodes" maxOccurs="1">

<xsd:complexType>
<xsd:sequence>
<xsd:element name="Node" id="NodeKey" maxOccurs="unbounded">

<xsd:complexType>
<xsd:attribute name="ID" type="xsd:string"/>
<xsd:attribute name="ParentId" type="xsd:string"/>
<xsd:attribute name="Name" type="xsd:string"/>
</xsd:complexType>

<!--
<xsd:unique name="NodeKey">
<xsd:selector xpath="."/>
<xsd:field xpath="@ID"/>
</xsd:unique>
-->
</xsd:element>
</xsd:sequence>
</xsd:complexType>

<xsd:unique name="NodeKey">
<xsd:selector xpath="Node"/>
<xsd:field xpath="@ID"/>
</xsd:unique>

</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

Postnext
Peter LarbalestierSubject: Key field - duplicate values - NO error
Author: Peter Larbalestier
Date: 14 Oct 2004 09:37 PM
Ivan,

thanks for the answer and more importantly the tip about
which book to buy.

I will be definately getting the book.

That is what I was talking to Minollo about yesterday.

It's these URL's, books and other pointers that will keep
me away from bugging you guys with inane questions
buty more importantly if we could have another "branch"
with such knowledge for all and sundry, now that would
be brilliant.

Thanks again

Pete

Posttop
Peter LarbalestierSubject: Key field - duplicate values - NO error
Author: Peter Larbalestier
Date: 14 Oct 2004 10:09 PM
Ivan,

spoke to a colleague and as he rightly pointed out to me.

It was the "scope" that I had got all wrong!

The parent has to have the "key" as the Parent can then govern
all of the children and ensure that the children have a unique key.

By the putting the key inside the Child element, none of the other
children could see that key restraint and thus I had the wrong scope.

Thanks again

Pete

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.