Re: Is it possible in XSLT -- Please help us ....
This is another natural use for keys. Funny how these things all happen at once: this is the third of fourth we've had in the last couple of days.
You want to retrieve hazmatlang nodes given a string value, namely the hazcode for any given hazmat.
(Hazmats are those things they don't let on the highway, right? :-)
<xsl:key name="hzmlang-by-code" match="hazmatlang" use="hazcode"/>
The key is set to use the hazcode element child of any hazmatlang element to retrieve that element.
Then, in your template for hazmats:
<xsl:variable name="matched-langs" select="key('hzmlang-by-code', hazcode)"/>
<!-- The key retrieves any hazmatlang whose hazcode element
is the same as the hazcode element of the hazmat
(the second argument). Strictly speaking you don't need
a local variable, but hey. -->
Process them here: you'll get all of them.
Or you could use an apply-templates instead of
the for-each, and process them in their own template. -->
<!-- fallback processing for hazmats that have no
matching hazmatlangs can go here -->
This can also be done the long way with an XPath expression such as '//hazmatlang[hazcode=current()/hazcode]' but the key is a little cleaner and allows the processor to optimize retrieval. As someone just remarked yesterday, they also have the virtue of legibility once you learn how they work.
I hope that helps-- Wendell
At 01:16 AM 7/11/01, you wrote:
Hi all, Please help us!!!
====================================================================== 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