Subject: [xsl] Selecting first descendant text node From: Christian Roth <roth@xxxxxxxxxxxxxx> Date: Fri, 11 Jan 2002 15:23:20 +0100 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: XSLT Repository, Dimitre Novatchev | Thread | RE: [xsl] Selecting first descendan, Oleg Tkachenko |
RE: Regular expression functions (W, Michael Kay | Date | Re: [xsl] [XSL] [XSL:FO] Arabic no, Lee Goddard |
Month |