Subject: RE: [xsl] Immediately preceding-sibling From: "John Marshall" <John.Marshall@xxxxxxxxxxxxxx> Date: Mon, 20 Oct 2003 17:01:49 +0100 |
How about:- <xsl:template match="line"> <xsl:apply-templates/> </xsl:template> <xsl:template match="word"> <xsl:value-of select="."> <xsl:if test="following-sibling!=nospace"> <xsl:text> </xsl:text> </xsl:if> </xsl:template> <xsl:template match="nospace"> <xsl:text>_</xsl:text> </xsl:template> John Marshall Accurate Software 80 Peach Street, Wokingham, Berkshire, RG40 1XH, UK. Tel: +44 (0)118 977 3889 Fax: +44 (0)118 977 1260 http://www.accuratesoftware.com <http://www.accuratesoftware.com> -----Original Message----- From: m.vanrootseler@xxxxxxxxx [mailto:m.vanrootseler@xxxxxxxxx] Sent: 20 October 2003 16:00 To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] Immediately preceding-sibling I have the following problem that I've been staring at for too long now. I'm sure the solution is a simple one, I just can't find it. I have the following XML (simplified): <root> <page id="1"> <line id="1"> <word id="1">One</word> <nospace/> <word id="2">Two</word> <word id="3">Three</word> <nospace/> <word id="4">Four</word> <word id="5">Five</word> </line> </page> </root> What I want to do is to present the contents of the line; where a word is *not* preceded by a <nospace/> tag, I want to put a space, where it *is* preceded by a <nospace/> tag, I want to display an underscore. In other words, I'm looking for a way to find the *immediate* preceding <nospace/> tag to a <word>-tag. The result should look like this: One_Two Three_Four Five I can't get the XPath right by using preceding-sibling::nospace. I'm using MSMXL and my XSLT looks like this (and I have to stick to the nested templates): <xsl:template match="/"> <html> <head> </head> <body> <table border="0"> <xsl:apply-templates select="root/page"/> </table> </body> </html> </xsl:template> <xsl:template match="page"> [page <xsl:value-of select="@id"/>] <br/> <br/> <xsl:apply-templates/> </xsl:template> <xsl:template match="line"> <xsl:value-of select="@id"/> <xsl:text> </xsl:text> <xsl:apply-templates/> </xsl:template> <xsl:template match="word"> -->???<-- <xsl:apply-templates/> </xsl:template> Has anyone got any idea how to accomplish getting the XPath right? Much appreciated. Mick XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list Visit Accurate at Sibos, the world's premier financial services event, where we will be presenting our Operational Risk Management solution, Accurate NXG, at Stand 4103, October 20th - 24th. Accurate Software info@xxxxxxxxxxxxxxxxxxxx www.accuratesoftware.com Europe . North America . Australasia . Africa The information in this email is confidential and privileged and is intended only for the use of the individual or entity listed above. If you are neither the intended individual, or entity listed above, nor the person responsible for the delivery of this email to the intended recipients, you are hereby notified that any unauthorised distribution, copying or use of this email is prohibited. If you have received this email in error, please notify the Accurate system manager at postmaster@xxxxxxxxxxxxxxxxxxxx or on +44 (0)118 977 3889. The views expressed in this communication may not necessarily be the views held by the Accurate Group. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Immediately preceding-sib, Jeff Beadle | Thread | RE: [xsl] Immediately preceding-sib, Americo Albuquerque |
[xsl] Images in block-containers, Skwirel Software Ltd | Date | RE: [xsl] Encoding while parsing, Andreas L. Delmelle |
Month |