If I select / text (), all I get is apples. How would I track pear apples
Just use :
normalize-space(/)
Explanation
The string value of the root node ( / ) of the document is the concatenation of all its descendants text-node. Since text nodes exist only for spaces, we need to eliminate these unwanted text nodes.
Here is a short demonstration of how this solution works and what it produces:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="/"> '<xsl:value-of select="normalize-space()"/>' </xsl:template> </xsl:stylesheet>
when this conversion is applied to the provided XML document:
<a> apples <b><c/></b> pears </a>
the desired, correct result is output:
'apples pears'
Dimitre novatchev
source share