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

problem building a lookup table and find match from a

Subject: problem building a lookup table and find match from a different template
From: "Leslie Young" <xlr8sx@xxxxxxxxxxx>
Date: Tue, 29 Aug 2006 20:38:36 -0500
match problems
I am trying to create a table lookup using a set of data (dataset2), then process a different set of data (dataset1). While going through each item in the dataset1, if a value is found for the item in dataset2, use dataset2's value. If not, display dataset1's value in a html page. I have a couple of problems, not sure what to do with it.

1) All the data stored in the table display on the html page as a long string. The data is supposed to be used for lookup. I do not know why it shows up in the html page.

2) I have a statement to do a quick lookup, but it does not seem find the match in the lookup table. How to do the lookup in a different template than the template where the lookup table is built? If I move the statement to where the lookup table is built, it can find the value.

Any suggestion is greatly appreciated.

Here is my xml: (simplied version)

<dataset1 someData>
   <Item ID="A" Value="001"></Item>
   <Item ID="B" Value="002"></Item>
   <Item ID="C" Value="003"></Item>
   <Item ID="D" Value="004"></Item>

<dataset2 someData>
 <Root someData
   <Item ID="B" Value="222"></Item>
   <Item ID="D" Value="444"></Item>

Desired output: A 001 B 222 C 003 D 444

<xsl:stylesheet version="1.0"

<xsl:key name="rec-lookup" match="s:rec" use="s:keyid"/>
<xsl:variable name="recs-top" select="document('')/*/s:recs"/>

<xsl:template name="main-html">

 <!-- use dataset2 to build table    -->
     <xsl:when test="dataset2/Root">
       <xsl:call-template name="build-rec-lookup-table">
         <xsl:with-param name="dataset" select="dataset2/Root"/>

 <!-- process dataset 1 -->
 <div align="center" class="whitebg">
   <!-- process raw data -->
     <xsl:when test="dataset1/Root">
       <xsl:call-template name="generate-html">
         <xsl:with-param name="dataset" select="dataset1/Root"/>



<xsl:template name="build-rec-lookup-table"> <xsl:param name="dataset"/>

 <xsl:for-each select="$dataset/Item">
         <s:keyid><xsl:value-of select="@ID" /></s:keyid>
         <s:value><xsl:value-of select="@Value" /></s:value>


<xsl:template name="generate-html">

 <!-- incomplete coding, only a brief testing to look up the table -->
    A<xsl:value-of select="key('rec-lookup','A')" />


Call friends with PC-to-PC calling -- FREE http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline

Current Thread


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.
First Name
Last Name
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.