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

Re: variable question

Subject: Re: variable question
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 10 Nov 2004 22:00:19 +0000
xsl variable jeni
Hi Bruce,

I haven't been following this thread, just saw my name mentioned...

Wendell said:
>> Maybe Mike or Jeni or someone can suggest an easier way to do this in
>> XSLT 2.0.

There isn't any way of dynamically evaluating strings as XPaths in
XSLT 2.0 -- you still have to generate the stylesheet to do it. But of
course, if you're using Saxon you can use the saxon:evaluate()
extension function.

> Maybe use a key?
> I'm confused (again!). I'm basically trying to rework some of my
> code, in part based around Geert's suggestions, but I can't really
> see how to do what I'm wanting to do (which is to be able to work on
> content from external files). It seems, for example, that I cannot
> use a key on content I want to access via the doc function.
>         <xsl:variable name="bibrecord" select="doc(concat('bib-data/',
> $bibkey, '.mods'))" />
>         <xsl:key name="biblio" match="$bibrecord//mods:mods" use="@ID" />

The document that's searched when you call the key() function is the
current document at the time of the call. So you should do:

<xsl:key name="biblio" match="mods:mods" use="@ID" />

and then something along the lines of:

<xsl:for-each select="$bibrecord/key('biblio', $bibkey)">

though I think that you need $bibkey to be defined as:

<xsl:variable name="bibkey" select="//db:bilioref/@linkend" />

since the <biblioref> elements can occur anywhere within the (source)

Note that the path "$bibrecord/key('biblio', $bibkey)" is newly
allowed in XPath 2.0, and makes searching documents using keys a whole
lot easier than it used to be.



Jeni Tennison

Current Thread


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.
First Name
Last Name
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.