Subject: [xsl] selecting elements from a flat file From: "Adrian Jordin" <ajordin@xxxxxxxxxxxxxxx> Date: Thu, 15 Jul 2004 15:59:03 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] RE: xslt processing and s, Emmanouil Batsis | Thread | Re: [xsl] selecting elements from a, David Carlisle |
RE: [xsl] Matching similar rows in , Pieter Reint Siegers | Date | [xsl] Match nodes with a range of v, Karl J. Stubsjoen |
Month |