What is the XSLT to get a parent node based on the value of the child?
My xml:
<cast>
<character>
<name>Bugs</name>
<id>1</id>
</character>
<character>
<name>Daffy</name>
<id>2</id>
</character>
I have tried this:
<xsl:template match="/cast/character/id">
<xsl:if test="text()=1">
<xsl:apply-templates select="../self" mode='copier'/>
</xsl:if>
</xsl:template>
<xsl:template match="*" mode='copier'>
<xsl:apply-templates />
</xsl:template>
But this outputs the text of every node in the document.
EDIT: I have to output XML here, I’m planning to extend this to XML generation
Just use:
or, if the wanted node should just be copied with no further processing: