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

Re: Extract values from first occurrence of a node

Subject: Re: Extract values from first occurrence of a node
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 16 Jul 2003 17:40:34 +0100
xsl template match first occurrence
  Recognize the first <B> with 12344 (substring from 1 with length 5) and 
  extract ABCD (substring from 7 with length 4), but ignore all other <B>

do you mean "ignore other B" or "ignore other B which start 12344"

in the first case

<xsl:template match="A">
 <xsl:apply-templates select="B[starts-with(.,'12344')][1]"/>
</xsl:template>

In the second interpretation of your question, you want to just
find the first B with a specified sort key (first five letters)
Then the answer of yesterday holds:

> This is a "grouping problem" 
> 
> see
> 
> http://www.jenitennison.com/xslt/grouping/index.html
> 
> David
> 

Specifically, set up a key of first five characters of a B node

<xsl:key name="x" match="B" use="substring(.,1,5)"/>

then muenchify your selection (See Jeni's site)

<xsl:template match="A">
 <xsl:apply-templates select="B[generate-id(.)=generate-id(key('x',substring(.,1,5)))]"/>
</xsl:template>

which will select the first B node with each unique first five letter
string.

ie the ones marked with !!
<A>
<B>12345 ABCD</B>!!
<B>12344 ABCD</B>!!
<B>12333 EFGH</B>!!
<B>12344 WXYZ</B>
</A>

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. 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
________________________________________________________________________

 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.