Re: key/keyref?

Eric van der Vlist <vdv@dyomedea.com> writes:

> 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>


This is actually backwards.  You have to declare the keyref on an
element which scopes the key.  So if you pull your keyref up to the
top level as well, with the obvious change to the selector, it should
work.

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/

Received on Thursday, 12 October 2000 10:20:04 UTC