Re: key/keyref?

Norman Walsh wrote:
> 
> More user error, I'm sure. :-/

:)

> I want to constrain the ID/IDREF relationship between two elements so
> that the IDREF part can only point to specific elements. In this case,
> I want to assert that <wfc def="foo"> can only point to <wfcnote id="foo">.
> 
> So, in the element declaration for the root element, I define a key:
> 
> <element name='spec' type='spec:spec'>
>   <key name="wfcNoteKey">
>     <selector xpath="//wfcnote[@id]"/>
>     <field xpath="@id"/>
>   </key>
> </element>

Wouldn't the definition for this key be better placed in its element:

<element name='wfcnote' type='spec:spec'>
  <key name="wfcNoteKey">
    <selector xpath="."/>
    <field xpath="@id"/>
  </key>
</element>

and the reference as:

<element name='wfc' type='spec:wfc'>
  <keyref name="wfcNoteRef" refer="wfcNoteKey">
    <selector xpath="."/>
    <field xpath="@def"/>
  </keyref>
</element>

???

My understanding is that the selector is a first path which should be
used to select the element to identify relative to the element you're
defining while the field is the path identifying the key or reference
relative to the selector (they are kind of concatenated).

While you can write ./@def, you can't write @def/@def...

Eric
 
> And in the element declaration for the wfc, I make a keyref:
> 
> <element name='wfc' type='spec:wfc'>
>   <keyref name="wfcNoteRef" refer="wfcNoteKey">
>     <selector xpath="@def"/>
>     <field xpath="@def"/>
>   </keyref>
> </element>
> 
> XSV complains:
> 
>   No key or unique constraint named wfcNoteKey declared, refed by keyref
>   wfcNoteRef
> 
> at every occurance of <wfc def="foo">...</wfc> in my test document.
> I didn't expect to get it right without a bit of tinkering, but I'm
> stymied by the 'undeclared' message. I'm an idiot today, because...?
> 
>                                         Be seeing you,
>                                           norm
> 
> --
> Norman Walsh <ndw@nwalsh.com> | The trip doesn't exist that can set you
> http://nwalsh.com/            | beyond the reach of cravings, fits of
>                               | temper, or fears. If it did, the human
>                               | race would be off there in a
>                               | body.--Seneca

-- 
------------------------------------------------------------------------
Eric van der Vlist       Dyomedea                    http://dyomedea.com
http://xmlfr.org         http://4xt.org              http://ducotede.com
------------------------------------------------------------------------

Received on Thursday, 12 October 2000 09:36:08 UTC