[xsl] Matching attribute with condition in predicate

Subject: [xsl] Matching attribute with condition in predicate
From: Михаил Сабуренков <jack.vosmerkin@xxxxxxxxx>
Date: Tue, 22 Dec 2009 17:44:16 +0300
Hi,

I make two-pass transformation in my XSL using exsl:node-set (libxslt).
While identity-transforming everything by default, I filter out some nodes.
I think it's very widespread case:

XML:
<root condition='ru'><tree/></root>

XSL:
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:exsl="http://exslt.org/common";
  extension-element-prefixes="exsl">

  <xsl:template match="root">
    <xsl:variable name="nodeset">
      <xsl:apply-templates select="tree"/>
    </xsl:variable>
    <xsl:apply-templates select="exsl:node-set($nodeset)" mode="parse"/>
  </xsl:template>

  <xsl:template match="tree">
    <node attr="foo"/>
  </xsl:template>

  <xsl:template match="@*|node()" mode="parse">
     <xsl:copy>
      <xsl:apply-templates select="@*|node()" mode="parse"/>
     </xsl:copy>
  </xsl:template>

  <xsl:template match="@attr" mode="parse">
    <xsl:attribute name="attr">default</xsl:attribute>
  </xsl:template>

  <xsl:template match="@attr[/root/@condition='ru']" mode="parse">
    <xsl:attribute name="attr">matched</xsl:attribute>
  </xsl:template>

</xsl:stylesheet>

Last template should (i hope so) match my @attr 'cause it's more exact.
And it's working w/o predicate.

But it doesn't with.

Any thoughts why?

Thanks in advance,

Mike.

p.s. xsltproc -V:
Using libxml 20705, libxslt 10124 and libexslt 813
xsltproc was compiled against libxml 20632, libxslt 10124 and libexslt 813
libxslt 10124 was compiled against libxml 20632
libexslt 813 was compiled against libxml 20632

Current Thread