[xsl] Re: xsl:variable and position question and experience

Subject: [xsl] Re: xsl:variable and position question and experience
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Mon, 3 Mar 2003 07:02:11 +0100
>      Example:
>      1) Inside a template match on *, or $file1//Product the following
strangeness occurs:
>
>      <xsl:value-of select="$file1//Product[1]/@name" /> prints the name of
the product
>      but <xsl:value-of select="$file1//Product[2]/@name"/> does not print
anything.



I tried to reproduce your observations and failed completely. The following
transformation:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

  <xsl:output method="text"/>

  <xsl:template match="/">

    <xsl:variable name="v"
         select="document(/files/file[1]/@href, /)"/>

    <xsl:value-of select="$v//Product[1]/@name"/>
    <xsl:text>&#xA;</xsl:text>
    <xsl:value-of select="$v//Product[2]/@name"/>

  </xsl:template>
</xsl:stylesheet>

when performed against this source.xml:

<files>
  <file href="testxp42.xml" />
  <file href="file2.xml" />
</files>

where testxp42.xml is:

<file>
  <Products>
    <Product name="1"/>
    <Product name="2"/>
    <Product name="3"/>
  </Products>
</file>


produces the following result:

1
2


This result is produced by: MSXML3/4, Saxon 6.5.2, XalanJ 2.4.1, XalanC 1.3
and MS .Net xsltTtransform.



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread