Altova Mailing List Archives>Archive Index >xmlschema-dev Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Another multi-field key question Another multi-field key questionTo: <xmlschema-dev@--.---> Date: 12/13/2004 7:09:00 AM
Just when I think I understand all this key/keyref stuff, another
conundrum arises:
I have "categories" under my root, each with one or more "property
definitions" consisting of name-value pairs. Several of my categories
have duplicate property definitions, something like below:
<root>
<category>
<name>Foo</name>
<propDef>
<name>Color</name>
<type>integer</type>
</propDef>
<propDef>
<name>Flavor</name>
<type>String</type>
</propDef>
<category>
<category>
<name>Bar</name>
<propDef>
<name>Color</name>
<type>integer</type>
</propDef
<propDef>
<name>Odor</name>
<type>String</type>
</propDef>
</category>
</root>
If I define a primary key as follows:
<xs:key name="catElem.PK">
<xs:selector xpath="category/propDef"/>
<xs:field xpath="name"/>
</xs:key>
XMLSpy tells me that the duplicate value "Color" has been already
matched by the identity constraint. If I configure it like so:
<xs:key name="catElem.PK">
<xs:selector xpath="category"/>
<xs:field xpath="propDef/name"/>
</xs:key>
it tells me that the field "propDef/name" matches twice within the
scope of element 'category'.
I don't get this. I thought after the last go-round that using just
'category' as the field selector created an automatic unique constraint
per category. I need to make sure that the combination of category name
*plus* propDef/name (Foo + Color) is unique. Can someone shed some
light (again?)
Thanks
Jim Stanley
Media Services, Inc.
From K.Buchcik@4... Tue Dec 14 11:32:58 2004
Received: from bart.w3.org ([128.30.5 | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
