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

RE: from start tag A to end tag B

Subject: RE: from start tag A to end tag B
From: "Robert Soesemann" <rsoesemann@xxxxxxxxxxx>
Date: Mon, 31 Jan 2005 17:25:02 +0100
xsl end tag
That is perfectly what I was looking for.

Her is the final code with some adjustments to my real world case.
The only problem that I now have is that I get all the node inside
<textItem> in the opposite order. How can I prevent the xsl from doing
this?



<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">

	<xsl:key name="x" match="node()"
use="generate-id((self::p[@class='headline_04']|preceding-sibling::p[@cl
ass='headline_04'])[last()])"/>


	<xsl:template match="/ | @* | node()">
		<xsl:copy>
			<xsl:apply-templates select="@* | node()"/>
		</xsl:copy>
	</xsl:template>


	<xsl:template match="attribute[@markup='yes']">

		<xsl:for-each select="p[@class='headline_04']">
			<textItem>
				<xsl:copy-of
select="key('x',generate-id())"/>
			</textItem>
		</xsl:for-each>
	</xsl:template>

</xsl:stylesheet>

-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: Montag, 31. Januar 2005 17:01
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  from start tag A to end tag B



> I do not understand how to do that.


jeni's site will explain how to use grouping based on "content" but in
your case the content is not a text string from element or attribute
content but rather the node identity of the nearest p node with a foo
class. generate-id returns a unique string for each node, so once you
have that string you just use the usual grouping idioms.

Note there are alternative mechanisms, eg Joris has just answered an
almost identical question in the parallel
Re:  Grouping immediate follow sibling
thread, giving two other strategies.

David
this works on your input:


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="2.0">



<xsl:key name="x" match="root/node()"
use="generate-id((self::p[@class='foo']|preceding-sibling::p[@class='foo
'])[last()])"/>


<xsl:template match="root">
<xsl:for-each select="p[@class='foo']">
<textitem>
<xsl:copy-of select="key('x',generate-id())"/>
</textitem>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>



________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.