Hi
I have the following document (made up sample)
<doc>
<node id="1"/>
<node id="2">
<node id="2.1"/>
</node>
<node id="3">
<node id="3.1"/>
<node id="3.2"/>
</node>
</doc>
I want to be able to filter the document so that only certain id's are
returned but the number of ids may change each call, so for example:
If I wanted Id's 2.1 and 3 I would expect to see the following document
returned
<doc>
<node id="2">
<node id="2.1"/>
</node>
<node id="3"/>
</doc>
and maybe next time I would want to filter just on id 3.1 to return
<doc>
<node id="3">
<node id="3.1"/>
</node>
</doc>
each time I want to return the element with the id I have selected and
everything leading up to it but no further and I may want to pass in
different ids and number of ids each time
I currently have the following xsl which if I hardcode in a single id will
return the results I expect for a single id, put I have no idea how to
expand this for multiple ids.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl=" <xsl
aram name="idwanted">3.2</xsl
aram>
<xsl:template match="/ | * | @* | node()">
<xsl:copy>
<xsl:apply-templates select="* | @* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="node[not(@id='3.2') and not(.//node[@id='3.2'])]" />
</xsl:stylesheet>
as soon as I try to get this to use a param to replace the hardcoded id like
this
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl=" <xsl
aram name="idwanted">3.2</xsl
aram>
<xsl:template match="/ | * | @* | node()">
<xsl:copy>
<xsl:apply-templates select="* | @* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="node[not(@id=$idwanted) and
not(.//node[@id=$idwanted])]" />
</xsl:stylesheet>
I am getting the error that param and variables are not allowed in patterns
Any help greatly appreciated, even if its just to say your being stupid you
should be doing x as this is driving me nuts!!
Thanks
G
I have the following document (made up sample)
<doc>
<node id="1"/>
<node id="2">
<node id="2.1"/>
</node>
<node id="3">
<node id="3.1"/>
<node id="3.2"/>
</node>
</doc>
I want to be able to filter the document so that only certain id's are
returned but the number of ids may change each call, so for example:
If I wanted Id's 2.1 and 3 I would expect to see the following document
returned
<doc>
<node id="2">
<node id="2.1"/>
</node>
<node id="3"/>
</doc>
and maybe next time I would want to filter just on id 3.1 to return
<doc>
<node id="3">
<node id="3.1"/>
</node>
</doc>
each time I want to return the element with the id I have selected and
everything leading up to it but no further and I may want to pass in
different ids and number of ids each time
I currently have the following xsl which if I hardcode in a single id will
return the results I expect for a single id, put I have no idea how to
expand this for multiple ids.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl=" <xsl
<xsl:template match="/ | * | @* | node()">
<xsl:copy>
<xsl:apply-templates select="* | @* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="node[not(@id='3.2') and not(.//node[@id='3.2'])]" />
</xsl:stylesheet>
as soon as I try to get this to use a param to replace the hardcoded id like
this
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl=" <xsl
<xsl:template match="/ | * | @* | node()">
<xsl:copy>
<xsl:apply-templates select="* | @* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="node[not(@id=$idwanted) and
not(.//node[@id=$idwanted])]" />
</xsl:stylesheet>
I am getting the error that param and variables are not allowed in patterns
Any help greatly appreciated, even if its just to say your being stupid you
should be doing x as this is driving me nuts!!
Thanks
G