[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Selecting first descendant text node
Hello, how do I select the first descendant text node of an element? My XML: .. <item numbertext="1. "> <par> <italic>first text</italic> </par> <par>next text</par> </item> .. The stylesheet should put the numbertext attribute value before the first textnode of the contents of the <item> element, i.e. expected result should be: .. <item> <par> <italic>1. first text</italic> </par> <par>next text</par> </item> .. First try: .. <xsl:template match="item//text()[1]"> <xsl:value-of select="ancestor::item/attribute::numberingtext" /> <xsl:value-of select="." /> </xsl:template> .. This does not work since it matches both text nodes, since ...text()[1] matches only for first child of its immediate parent, which is true for both text nodes. Second try: .. <xsl:template match="(item//text())[1]"> <xsl:value-of select="ancestor::item/attribute::numberingtext" /> <xsl:value-of select="." /> </xsl:template> .. This does not work since the XSLT processor complains of illegal tokens "item", "/", etc. after the first opening bracket in the match expression. So, how do I select the first (in document order) of all of the descendant text nodes of an element? I was using Xalan 2.1.0 for the test. Regards, Christian. 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
|