xml editor

Supported platforms

Compatible with Windows7 & Mac OS X Snow Leopard

Ready for data server software
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] variable question


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

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)">
  ...
</xsl:for-each>

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)
document.

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.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


Current Thread
Keywords
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>®XML Editor