OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Re: [docbook-apps] support for xpointer

Hi Thomas,

On 2014-09-19 10:17, Thomas Schraitle wrote:
> Hi Stefan,
> On Fri, 19 Sep 2014 09:53:33 -0400
> Stefan Seefeld <stefan@seefeld.name> wrote:
>> [...]
>> Ideally I would like to be able to encode the query in an attribute,
>> much as I would have preferred with xpointer, such as
>> <listitem my:ref="*[@xml:id='foo']//d:listitem" />
>> However, I can't manage to extract the above "ref" into a variable and
>> concatenate that into a valid xpath expression inside a custom
>> stylesheet:
>> <xsl:template match="*[@my:ref]">
>>   <xsl:variable name="ref" select="@my:ref" />
>>   <xsl:variable name=content select="document('dict.xml')//$ref" />
>>   ...
>> </xsl:template>
>> It seems I'm misunderstanding something, as no matter how I spell the
>> above, I get XPath errors from xsltproc.
> Yes, as you try to dynamically evaluate a string as an XPath
> expression. This is not possible with standard XSLT 1.0 and 2.0.
> However, you could look into the dyn:evaluate() extension functions from
> the EXSLT initiative:
>   http://exslt.org/dyn/functions/evaluate/index.html
> You may try this, although I haven't tested it:
>  <xsl:template match="*[@my:ref]" xmlns:dyn="http://exslt.org/dynamic";>
>    <xsl:variable name="ref" select="dyn:evaluate(@my:ref)" />
>    <xsl:variable name=content select="document('dict.xml')//$ref" />
>    ...
>  </xsl:template>

Great, it seems dyn:evaluate() is exactly what I'm looking for. Note
that I had to rephrase the above a little, as the way you wrote it
wouldn't work, since the evaluation of the (dynamic) xpath only makes
sense in the context of the "doct.xml" document, and thus can't be done
outside it.

But with that little adjustment I now get the expected result. It's
still not very pretty, but a huge step in the right direction.

> Unfortunately, very few XSLT 1.0 processors implement dyn:evaluate().
> It works in xsltproc, but it's unlikely it will work for Saxon.

Yeah, tools support has always been a great bottleneck with XML
processing. :-(

Many thanks,


      ...ich hab' noch einen Koffer in Berlin...

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]