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

RE: Selecting a range of siblings between specified el

Subject: RE: Selecting a range of siblings between specified elements: resend
From: "Kenny Akridge" <kenny@xxxxxxxxxxxxxxxxx>
Date: Mon, 8 Mar 2004 09:19:05 -0500
david akridge
Here is one solution:

<xsl:template match="doc">
	<xsl:variable name="sent" select="3"/>
	<xsl:for-each select="a">
		<xsl:if test="position() &lt;= $sent">
			<xsl:value-of select="preceding-sibling::b[2]"/>
			<xsl:value-of select="preceding-sibling::b[1]"/>
		</xsl:if>
	</xsl:for-each>
</xsl:template>

This will work with a static xml structure of the format you have provided.

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of David Holden
Sent: Monday, March 08, 2004 9:03 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Selecting a range of siblings between specified elements:
resend


Hello,

I'm currently a little puzzled on how to select a range of siblings between 
specified elements, e.g.

<?xml version="1.0"?>
<doc>
<a>cont1</a><b/><b/>
<a>cont2</a><b/><b/>
<a>cont3</a><b/><b/><c/><c/>
<a>cont4</a><b/><b/><c/><c/>
</doc>


I would like to select firstly the <b/><b/> of

<a>cont1</a><b/><b/>

then the <b/><b/> of

<a>cont2</a><b/><b/>

then the <b/><b/> of

<a>cont3</a><b/><b/><c/><c/>

and finally the <b/><b/> of

<a>cont4</a><b/><b/><c/><c/>


So:

/doc/a[1]/following-sibling::*

will select all elements after the first <a>

how do I reduce this to just the <b/><b/> before the second <a> 

and similarly for the <b/><b/> between the all the other <a>'s.

 thanks.

 Dave.



-- 
Dr. David Holden. (Systems Developer)
Crystallography Journals Online: <http://journals.iucr.org>

Thanks in advance:-
Please avoid sending me Word or PowerPoint attachments.
See: <http://www.fsf.org/philosophy/no-word-attachments.html>

UK Privacy (R.I.P)  : http://www.stand.org.uk/commentary.php3
Public GPG key available on request.
-------------------------------------------------------------

 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.