By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,939 Members | 1,638 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,939 IT Pros & Developers. It's quick & easy.

uniqueness schema problem

P: n/a
Hello:

I’m trying to do a schema with recurrent structure for a Book like a Node
can have many Nodes inside or One leave. So, the leaves have an attribute
that is Identifier. My goal is define Uniqueness that guarantees to the
attribute Identifier his uniqueness. That I don’t know the depth of levels I
have to put in the xpath attribute of the selector something like this
TOC/descendant::Tree/Data, but this is not allow. How I can resolve.
This is the simplified version of the schema.

Hello:

I’m trying to do a schema with recurrent structure for a Book like a Node
can have many Nodes inside or One leave. So, the leaves have an attribute
that is Identifier. My goal is define Uniqueness that guarantees to the
attribute Identifier his uniqueness. That I don’t know the depth of levels I
have to put in the xpath attribute of the selector something like this
TOC/descendant::Tree/Data, but this is not allow. How I can resolve.
This is the simplified version of the schema.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Book">
<xs:complexType>
<xs:sequence>
<xs:element name="TOC">
<xs:complexType>
<xs:sequence>
<xs:element name="Tree" type="typeTree" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>

<xs:key name="UTree">
<xs:selector xpath="TOC/descendant::Tree/Data"/> HERE IS THE PROBLEM
<xs:field xpath="@Identifier"/>
</xs:key>
</xs:element>

<xs:complexType name="typeTree">
<xs:choice>
<xs:element name="Tree" type="typeTree" maxOccurs="unbounded"/>
<xs:element name="Data" nillable="true">
<xs:complexType>
<xs:attribute name="Identifier" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:schema>
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

If you put your key in the TOC element declaration instead, you can start
the path with ".//", which I think would meet your needs. So it would look
like this:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Book">
<xs:complexType>
<xs:sequence>
<xs:element name="TOC">
<xs:complexType>
<xs:sequence>
<xs:element name="Tree" type="typeTree" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:key name="UTree">
<xs:selector xpath=".//Tree/Data"/> HERE IS THE SOLUTION
<xs:field xpath="@Identifier"/>
</xs:key>
</xs:element>
</xs:sequence>
</xs:complexType>

</xs:element>
....

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

"Mr. Almenares" <Mr*********@discussions.microsoft.com> wrote in message
news:C7**********************************@microsof t.com...
Hello:

I'm trying to do a schema with recurrent structure for a Book like a Node
can have many Nodes inside or One leave. So, the leaves have an attribute
that is Identifier. My goal is define Uniqueness that guarantees to the
attribute Identifier his uniqueness. That I don't know the depth of levels
I
have to put in the xpath attribute of the selector something like this
TOC/descendant::Tree/Data, but this is not allow. How I can resolve.
This is the simplified version of the schema.

Hello:

I'm trying to do a schema with recurrent structure for a Book like a Node
can have many Nodes inside or One leave. So, the leaves have an attribute
that is Identifier. My goal is define Uniqueness that guarantees to the
attribute Identifier his uniqueness. That I don't know the depth of levels
I
have to put in the xpath attribute of the selector something like this
TOC/descendant::Tree/Data, but this is not allow. How I can resolve.
This is the simplified version of the schema.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Book">
<xs:complexType>
<xs:sequence>
<xs:element name="TOC">
<xs:complexType>
<xs:sequence>
<xs:element name="Tree" type="typeTree" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>

<xs:key name="UTree">
<xs:selector xpath="TOC/descendant::Tree/Data"/> HERE IS THE
PROBLEM
<xs:field xpath="@Identifier"/>
</xs:key>
</xs:element>

<xs:complexType name="typeTree">
<xs:choice>
<xs:element name="Tree" type="typeTree" maxOccurs="unbounded"/>
<xs:element name="Data" nillable="true">
<xs:complexType>
<xs:attribute name="Identifier" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:schema>

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.