How do i select all the text nodes within a specific element node using XSL?

Posted by user323719 on Stack Overflow See other posts from Stack Overflow or by user323719
Published on 2010-05-27T22:57:05Z Indexed on 2010/05/28 1:21 UTC
Read the original article Hit count: 322

Filed under:
|
|

How do i select all the text nodes within a specific element node using XSL?

Input xml:

 <node1 id="1">
 <node2 id="2">
 <node3 id="3" />
 <node4 id="4">
 <node5 id="5">Text node1</node5>
 <node6 id="6">Text node2</node6>
 </node4>
 </node2>
 <node7 id="7">Text node3
 <node8 id="8">Text node4</node8>
 <node9 id="9">Text node5</node9>
 </node7>
 <node10 id="10">Text node6</node10>
 <node11 id="11">Text node3
 <node12 id="12">Text node4</node12>
 <node13 id="13">Text node5</node13>
 </node11>
 </node1>

Input Param: List of ids of the element nodes whose txt nodes are to be retrieved.

 <nodes><node>4</node><node>7</node><node>10</node></nodes>

Expected Output:

Text node1

Text node2

Text node3

Text node4

Text node5

Text node6

How can this be achieved using XSL? Please share your ideas.

© Stack Overflow or respective owner

Related posts about xslt

Related posts about xsl