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

selecting elements from a flat file

Subject: selecting elements from a flat file
From: "Adrian Jordin" <ajordin@xxxxxxxxxxxxxxx>
Date: Thu, 15 Jul 2004 15:59:03 +0100
adrian jordin
Hi,

I am having problems selecting a group of sibling elements from a flat
file.
The file is of the form...

<main>
	<a name='Title'></a>
	<a></a>
	<a></a>
	<a></a>
	<b></b>
	<a></a>
	<a></a>
	<b></b>
	<a></a>
</main>

and I need to select all the <a> elements between <a name='Title'> and
the first <b> element.

I am trying to use keys to achieve this using the following XSL.....



<xsl:key name="about_st" match="a"
use="generate-id(preceding-sibling::a[@name='Title'][1])"/>

<xsl:key name="about_en" match="a"
use="generate-id(following-sibling::b[1])"/>

<xsl:template match="main">
<manual>
<about>
	<xsl:apply-templates select="a[@name='Title']"/>
</about>
</manual>
</xsl:template>

<xsl:template match="a[@name='Title']">
	<xsl:variable name="genID" select="generate-id()"/>
	<xsl:for-each select="key('about_st', $genID)">
		<xsl:apply-templates select="key('about_en', $genID)"/>
	</xsl:for-each>
</xsl:template>

<xsl:template match="a">
	<xsl:value-of select="."/>
</xsl:template>



The problem is that the first key selects all the <a> elements following
a name='Title'>
but the second key returns nothing.

Can someone point out where I have gone wrong? Or is there a better way
to do this?
(I am trying to do this without using XSL 2 to avoid having to install
additional software
on the customers machine.)

Many thanks,

==========================================

Adrian Jordin
Senior Analyst Developer
ePublishing Department,
Piper Group plc,

Email : ajordin@xxxxxxxxxxxxxxx+

300 Aztec West
Almondsbury
Bristol
BS32 4SE

Phone + 44 (0) 1454 284900
Fax + 44(0) 1454 284950

Information contained in this e-mail is intended for the use of the
addressee only, and is confidential and may be the subject of legal
professional privilege. Any dissemination, distribution, copying or use
of this communication without permission of the addressee is strictly
prohibited. The views expressed in this communication may not
necessarily be the views held by Piper Group plc

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.