[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Immediately preceding-sibling

Subject: RE: Immediately preceding-sibling
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Mon, 20 Oct 2003 17:58:09 +0100
html nospace
To test whether the immediately preceding element is a nospace element,
use

test="preceding-sibling::*[1][self::nospace]"

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> m.vanrootseler@xxxxxxxxx
> Sent: 20 October 2003 16:00
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  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
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.