[xslt] xpath and variable



Maybe I'm completly OT.
Some time ago there was a discussion about
node-set...

The thing I try to do is:
==================

apply a stylesheet to a XML-File and
than use the result tree of this transformation
for an other part of my stylesheet.

One possibility would be:
xsltproc test.xsl test.xml > test2.xml   
xsltproc test2.xsl test2.xml > result.html

It would be nice to have both transformations
in one XSLT File.
The Stylesheets will be stored in 2 different include
Files.

Maybe I'm completely blind but I only found the
method you can see below.

Why doesn't it work?
Is there an other possibility to do that?


XML-File:
=========

<?xml version="1.0"?>
<tree>
<one>first</one>
<two>second</two>
</tree>


XSLT_File:
=========

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:libxslt="http://xmlsoft.org/XSLT/namespace">

<xsl:output method="xml" indent="no" encoding="ISO-8859-1"/>
 
<!-- put the tree to a variable --> 
<xsl:variable name="tree">
   <xsl:copy-of select="/"/>
</xsl:variable>
 
<!-- xpath in variable -->
 <xsl:template match="/">
<!-- that works fine -->
<xsl:text>Complete tree variable:
</xsl:text>
<xsl:copy-of select="$tree"/>

<!-- but why doesn't that work -->
<xsl:text>Element selected fom tree variable:
</xsl:text>
<xsl:value-of select="libxslt:node-set($tree)/tree/one"/>
<!-- some (no) result -->
<xsl:value-of select="$tree/tree/one"/>
</xsl:template>
 
 
</xsl:stylesheet>

Version:
=======
xsltproc -V
Using libxml 20400 and libxslt 10000
xsltproc was compiled against libxml 20400 and libxslt 10000
libxslt 10000 was compiled against libxml 20400




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]