[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: getting text nodes of subtree?
Hi Jakub, > how can I get string which contains text nodes of all children of > given element? Usually, just getting the string value of a node will do that. > for example what will return > > <a> > aaa > <b> > bbb > <c> > ccc > </c> > BBB > </b> > AAA > </a> It's very easy from this example to get the string: " aaa bbb ccc BBB AAA " Just do: <xsl:value-of select="/a" /> But to get the string that you want: > aaabbbcccBBBAAA you need to get rid of the whitespace that's been added to the tree. The easiest thing to do here is to have a template in 'string' mode that matches text nodes and gives the normalized value of the string: <xsl:template match="text()" mode="string"> <xsl:value-of select="normalize-space()" /> </xsl:template> and then apply templates to the a element in 'string' mode; the built in templates will move through the tree to get to the text nodes, and their normalized values will be returned, concatenated together: <xsl:apply-templates select="/a" mode="string" /> Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|