[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: get the text value of a following sibling
A stylesheet with (just) the two templates <xsl:template match="a"> <xsl:text> </xsl:text> <xsl:apply-templates/. </xsl:template> <xsl:template match="br"> <xsl:text>: </xsl:text> </xsl:template> should do what you want. To coment on your code sample <xsl:value-of select="text()"/> It's best to use . rather than text() here as text() will (in xslt 1) just select the first text node child of a so if there are any comments for example, you lose any text after the comment, <xsl:value-of select="following-sibling::*[2]/text()"/> In your poseed input, typically an a element has two following br elments so following-sibling::*[2] is teh second of those br and then /text() selects the (empty) node set of children of the br. > It only outputs the text in the <a> tag just a comment on terminology the content of the a tag is 'a href="..."' you mean the text between the tags <a> and </a> but XSLT does not have any access to the tags in the document. > How should I treat that text? Isn't it considered as a node? yes it is a node, but as shown above you were looking in the br element rather than at sibling nodes of the a. It's simpler just to process it all from the parent element as shown with the templates above rather than for-each over the a and then pick up the related nodes. David
|
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
|