|
Subject: Re: [xsl] Extract values from first occurrence of a node From: Rick Taylor <taylor@xxxxxxxx> Date: Wed, 16 Jul 2003 10:59:31 -0600 |
<xsl:for-each select="B">
<xsl:sort select="substring(.,1,5)" data-type="number"/>
<xsl:if test="position() = 1">
<xsl:value-of select="substring(.,7,4)"/>
</xsl:if>
</xsl:for-each>
</xsl:template>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
Rick Taylor XML Developer PPDM Association
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Extract values from first, David Carlisle | Thread | RE: [xsl] Extract values from first, Tengshe, Ashish |
| Re: [xsl] Extract values from first, Matthew Mateyak | Date | Re: [xsl] Arbitrary XML document me, Scott Powell |
| Month |