Subject: [xsl] Immediately preceding-sibling From: m.vanrootseler@xxxxxxxxx Date: Mon, 20 Oct 2003 16:59:56 +0200 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Is this node, the documen, Adam Heinz | Thread | Re: [xsl] Immediately preceding-sib, Wendell Piez |
[xsl] Is this node, the document ro, Stephen Cunliffe | Date | RE: [xsl] Is this node, the documen, Adam Heinz |
Month |