[xsl] passing filtered tree to template

Subject: [xsl] passing filtered tree to template
From: Stefan Hunziker <stefan@xxxxxxxxxxxxx>
Date: Mon, 6 Jun 2011 17:56:45 +0200
I have the following problem: Given an xml like the following:


and a stylesheet like:

<xsl:stylesheet version="1.0"
    <xsl:template match="test">
        <xsl:variable name="xItems">
            <xsl:copy-of select="items"/>
select="items[item/property='y']"/><!-- wrong try! -->

    <xsl:template match="items">
        <xsl:for-each select="item">
                <xsl:value-of select="index"/>

I would like to pass only the items with property='x' to the items
matching template. The first try as written above of course doesn't
work, if there is an x item then the whole tree is passed, if there is
none, nothing is passed. I do further processing in the items
template, so I don't want to change it to match="item" or to apply the
filter in the items template.

Any help is much appreciated!

thanks, kind regards


Current Thread