[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
Matt,
Although this can be done without them, keys are very useful in XSLT for this kind of operation. You'd declare a key to match <B> elements, with the string value you care about (your substring) as the key value: <xsl:key name="B-by-string" match="B" use="substring(.,1,5)"/> Then the XPath "key('B-by-string','12344')" will get you all <B> elements that have that key value, while "key('B-by-string','12344')[1]" will get you the first of these (in document order). You could of course use a variable as that second argument. Part of getting your head around XSLT's non-proceduralness is in learning the various ways nodes can be selected, without having to run processes over the set (or find out what processes may have already been run -- in a side-effect free system this isn't appropriate, desirable or generally possible). Cheers, Wendell At 12:09 PM 7/16/2003, you wrote: 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. ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ====================================================================== XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|