[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: keys and idrefs

Subject: RE: keys and idrefs
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 09 Oct 2001 11:43:09 -0400
xslt idrefs contains
Hi Dave,

At 06:40 AM 10/9/01, DPawson@xxxxxxxxxxx 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>&#160;

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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.