Re: [xsl] AVT use and doc() function in xslt 2.0?

Subject: Re: [xsl] AVT use and doc() function in xslt 2.0?
From: "Tony Graham" <tgraham@xxxxxxxxxx>
Date: Thu, 18 Aug 2011 20:34:23 +0100 (IST)
On Thu, August 18, 2011 8:19 pm, dvint@xxxxxxxxx wrote:
...
> I have even gone as far as putting the value into a variable and then
> referencing the variable:
>
> <xsl:variable select="'GAASIB0'" name="modelic"/>
> <xsl:copy-of
> select="doc('dmcmapping.xml')/searchReplace/smodelic[@val='{$modelic}']"/>
>
>
> What am I missing?

It's not so much what you're missing as what you have extra.  Try:

<xsl:variable select="'GAASIB0'" name="modelic"/>
<xsl:copy-of
select="doc('dmcmapping.xml')/searchReplace/smodelic[@val=$modelic]"/>

The XSLT spec (and, consequently, Mulberry's XSLT quick reference [1]) has
'{' and '}' in the prototypes of attributes where AVTs are meaningful.

Based on your example, you should also be able use 'current()' [2] to do:

<xsl:copy-of
select="doc('dmcmapping.xml')/searchReplace/smodelic[@val=current()/modelic]"/>

Regards,


Tony Graham                                   tgraham@xxxxxxxxxx
Consultant                                 http://www.mentea.net
Mentea       13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
 --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
    XML, XSL FO and XSLT consulting, training and programming

[1] http://www.mulberrytech.com/quickref/index.html
[2] http://www.w3.org/TR/xslt20/#current-function

Current Thread