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

RE: Lookup kind of Functionality with XSL

Subject: RE: Lookup kind of Functionality with XSL
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 30 Oct 2009 09:38:44 -0000
RE:  Lookup kind of Functionality with XSL
> I have a requirement like this.
> 
> <employee hireDate="09/01/1998">
>     <COLUMN NAME="LAST">Herbert three</COLUMN>
>     <COLUMN NAME="FIRST">Johnny</COLUMN>
>     <COLUMN NAME="ANL_RATE"><![CDATA[26525.8500]]></COLUMN>
>     <COLUMN NAME="STATUS"><![CDATA[A]]></COLUMN>
>   </employee>
> 
> another piece of XML is
> <DESC_TABLE>
> <COLUMN NAME="STATUS"><![CDATA[A]]></COLUMN>
> <COLUMN NAME="DESCR"><![CDATA[Active]]></COLUMN>
> </ROW>
> </DESC_TABLE>
> 
> 
> while reading STATUS (status A), I need to look up the 
> corresponding Description ('Active').

Assuming that the <employee> element is bound to variable $emp, and the
<DESC_TABLE> element to variable $table, and that there is a <ROW> start tag
carelessly omitted from the sample XML, you want

$table/ROW[COLUMN[@name='DESCR'][.=$emp/COLUMN[@name='STATUS']]/COLUMN[@NAME
='DESCR']

As I suggested in a response to a previous post, this would all become a lot
easier if you first transform this verbose representation of your data into
something cleaner, like

<statusCodes>
  <status code="A" description="Active"/>
  ...
</statusCodes>

so the logic would become

$statusCodes/status[@code=$emp/status]/@description

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

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-2011 All Rights Reserved.