[Home] [By Thread] [By Date] [Recent Entries]
Hi,
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. Thanks! Here is my xml: (simplied version) <dataset1 someData> <Root> <Item ID="A" Value="001"></Item> <Item ID="B" Value="002"></Item> <Item ID="C" Value="003"></Item> <Item ID="D" Value="004"></Item> </Root> </dataset2> <dataset2 someData> <Root someData <Item ID="B" Value="222"></Item> <Item ID="D" Value="444"></Item> </Root> </dataset2>
Xsl:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:s="http://recs.data"
><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:choose>
<xsl:when test="dataset2/Root">
<xsl:call-template name="build-rec-lookup-table">
<xsl:with-param name="dataset" select="dataset2/Root"/>
</xsl:call-template>
</xsl:when>
</xsl:choose> <!-- process dataset 1 -->
<div align="center" class="whitebg">
<!-- process raw data -->
<xsl:choose>
<xsl:when test="dataset1/Root">
<xsl:call-template name="generate-html">
<xsl:with-param name="dataset" select="dataset1/Root"/>
</xsl:call-template>
</xsl:when>
</xsl:choose></div> </xsl:template>
<s:recs>
<xsl:for-each select="$dataset/Item">
<s:rec>
<s:keyid><xsl:value-of select="@ID" /></s:keyid>
<s:value><xsl:value-of select="@Value" /></s:value>
</s:rec>
</xsl:for-each>
</s:recs></xsl:template> <xsl:template name="generate-html"> <!-- incomplete coding, only a brief testing to look up the table -->
<td>
A<xsl:value-of select="key('rec-lookup','A')" />
</td></xsl:template> _________________________________________________________________ Call friends with PC-to-PC calling -- FREE http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline
|

Cart



