|
Subject: [xsl] 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 |
Any suggestion is greatly appreciated. Thanks!
<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>
Desired output: A 001 B 222 C 003 D 444
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"/> <!-- 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>
<xsl:template name="build-rec-lookup-table"> <xsl:param name="dataset"/>
<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> <!-- incomplete coding, only a brief testing to look up the table -->
<td>
A<xsl:value-of select="key('rec-lookup','A')" />
</td>| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] failed to find the right , David Carlisle | Thread | Re: [xsl] problem building a lookup, Florent Georges |
| Re: [xsl] XPath location problem, Florent Georges | Date | [xsl] match multiple values for an , Jeff Sese |
| Month |