This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: keys and idrefs
- To: DPawson at rnib dot org dot uk
- Subject: RE: [xsl] keys and idrefs
- From: Wendell Piez <wapiez at mulberrytech dot com>
- Date: Tue, 09 Oct 2001 11:43:09 -0400
- Cc: xsl-list at lists dot mulberrytech dot com
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Dave,
At 06:40 AM 10/9/01, DPawson@rnib.org.uk wrote:
> > So you'd have
> > <xsl:for-each select="key('processes-by-control', @id)"> ...
>
>Which only appears to return a single value, where
>
> <xsl:for-each
> select="//process ">
> <xsl:if test="contains(@control, $thisDoc)">
> <a href="{@id}.html"> <xsl:value-of select="name"/>
></a> 
>
>returns 5 process element whose control attribute contains the id value of
>the current node.
>
>Unsure, but the symptoms are that it finds an idref which is alone,
>but not those which are second or further in the list of idrefs.
>E.g.
><process id="metadataDesign" control="XAG" >
> <name>Metadata Design</name>
> </process>
>is found, for XAG
>
> <process id="deliver" control="DIGL WCAG XAG UANegotiation" >
> <name>Deliver Content</name>
> </process>
>
>but this is not found for XAG.
>Hence the use of my solution for treating the idrefs as
>a string, rather than an attribute value.
>
>
> >
> > Since you want <process> elements back and @control on each
> > process is an
> > IDREF, not an ID, I think you have to use keys; the id()
> > function only goes
> > the other way.
>
>No, its an idrefs (plural) not an idref, which I think is the heart
>of the matter.
Ah! I see, yes. Missed that important subtlety, sorry.
Yes, this is considerably trickier. Unless someone (where's Jeni?) can come
up with some cunning way to make key() work like id() with a
space-delimited list of tokens, I don't see a key solution here. That is,
how do I set up a key that will return the node
<process id="deliver" control="DIGL WCAG XAG UANegotiation" >
<name>Deliver Content</name>
</process>
when given the value "XAG"?
I'm afraid the rather brutal expression "//process[contains(@control,
$value)]" where $value is your id, is the only XSLT 1.0 alternative. (And
even that's not foolproof. What if you have control="DIGL WCAG XAG
UANegotiation" and your id value is "CAG"?)
The saxon:tokenize extension method returns a node set when given a list of
tokens as a string. If you're using Saxon, you could try
<xsl:key name="processes-by-control-token" match="process"
use="saxon:tokenize(@control)"/>
But general string-chopping methods won't work, since they won't fit into
the 'use' attribute on the key declaration.
I'd be interested to see what the wizards on this list will come up with.
(The schoolteacher says "can't be done".)
Cheers,
Wendell
======================================================================
Wendell Piez mailto:wapiez@mulberrytech.com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list