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 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:


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" />

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

> [...]

    Thomas Schraitle

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