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

RE: Getting all the values between empty elements

Subject: RE: Getting all the values between empty elements
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Mon, 5 Jan 2004 21:06:25 -0000
RE:  Getting all the values between empty elements
> I have one final XPath-related question.

Optimist!
> 
> If I have a series of sibling elements like <a/>, below:
> 
> <p>
> 	<a/>One or two <b>items</b><a/>or <i>another</i>, I 
> dare say<a/><c val="#0f0">a third</c>, do you think?<br/> </p>
> 
> how can I get at "everything between one a and the next a"?

If the <a> elements are always at the same (top) level, this isn't too
difficult. If they can be at any depth, it gets tough, though there are
solutions in the archive of the list.

You can do something along the lines of

<xsl:for-each select="a">
  <xsl:variable name="next"
select="generate-id(following-sibling::a[1])"/>
  <xsl:apply-templates select="following::sibling::node()
    [generate-id(following-sibling::a[1]) != $next or $next='']"/>

Michael Kay

> 
> Right now, I am formatting by matching on <br/> and looping 
> backwards (this is greatly simplified).
> 
> <xsl:template match="br">
> 
> 	<xsl:for-each select="preceding-sibling::a">
> 
> 		<xsl:value-of select="preceding-sibling::text()[1]"/>	
> 								
> 	</xsl:for-each>
> 			
> </xsl:template>	
> 
> But, of course, I've run into the problem that what is 
> in-between <a/>s, could contain elements that would call for 
> further application of templates - it might not be text-alone.
> 
> This is my last question on this particular problem.  Thank 
> you very much, everyone who has helped me thus far. I hope 
> eventually I will progress to a point where I can say 
> something that is of help to someone else.
> 
> KP
> 
> 
>  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.