[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: "Tengshe, Ashish" <Tengshe.Ashish@xxxxxxxxxxxxx>
Date: Wed, 16 Jul 2003 11:25:58 -0500
xsl first occurrence
Try this

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="A">
<xsl:value-of select="substring(B[substring(.,1,5)='12344'][1], 7, 11)"/>
</xsl:template>

</xsl:stylesheet>

Note that even if you don't use the [1] in the expression, you get the first node only by default. Though I've kept that so that you know where to put [2] (second node matching the criteria) if you need it!

Thanks,
Ashish


-----Original Message-----
From: Matthew Mateyak [mailto:mmateyak@xxxxxxxxxxx]
Sent: Wednesday, July 16, 2003 11:09 AM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Extract values from first occurrence of a node


I am trying to translate XML via XSL/XSLT need to specifically extract the 
values from the first occurrence of a particular node and ignore the rest of 
that same node.

I was attempting to use preceding-sibling::nodeset/node to verify if the 
match has already been made, but having little luck because I not only need 
to match the node but match substrings of the node's value.

Example XML:

<A>
<B>12345 ABCD</B>
<B>12344 ABCD</B>
<B>12333 EFGH</B>
<B>12344 WXYZ</B>
</A>

What I need to do:

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>

This is a very basic example, the XML I am working with is a bit more 
complicated and it is being translated via XSL-FO for PDF generation.

The biggest problem I am having with XSL/XSLT is detaching from my 
procedural language experience!  From my experience, I am having success in 
mapping singlular nodes but more difficulty when trying to accomplish 
"decision logic" in a non-procedural manner.

Any suggestions or recommended reads would be great.

Thanks,
Matt

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online  
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


 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.