How do i modify the text content within a specified set of nodes using XSL?
- by user323719
I have a list of node ids. I want to append "-Selected" to all the text nodes within the given set of node ids. Please let me know how we can achieve the same using XSL?
Input:
<node1 id="a">
<node2 id="b">
<node3 id="c" />
<node4 id="d">
<node5 id="e">Text node1</node5>
<node6 id="f">Text node2</node6>
</node4>
</node2>
<node7 id="g">Text node3
<node8 id="h" align="center">Text node4</node8>
<node9 id="i">Text node5</node9>
</node7>
<node10 id="j">Text node6
</node10>
<node11 id="h">Text node7
</node11>
Input Param: List of node ids
<xsl:param name="pNodes">
<nodes>
<node>4</node>
<node>7</node>
<node>11</node>
</nodes>
Expected output:
<node1 id="a">
<node2 id="b">
<node3 id="c" />
<node4 id="d">
<node5 id="e">Text node1 - Selected</node5>
<node6 id="f">Text node2 - Selected</node6>
</node4>
</node2>
<node7 id="g">Text node3
<node8 id="h" align="center">Text node4 - Selected</node8>
<node9 id="i">Text node5 - Selected</node9>
</node7>
<node10 id="j">Text node6
</node10>
<node11 id="h">Text node7 - Selected
</node11>