Hi drkm,
Thanks so much! It works better than the table lookup I was going after. I
have another question. Is there a limitation that this key can be used?
Somehow, I can get a key match in one template, but not in another template.
I did make sure the key value is the right value.
Thanks again!
From: Florent Georges <darkman_spam(_at_)yahoo(_dot_)fr>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] problem building a lookup table and find match from a
different template
Date: Wed, 30 Aug 2006 20:09:18 +0200 (CEST)
Leslie Young wrote:
Hi
> What I need to do is to process 2 elements in a xml:
> dataset1 and dataset2. If same id exists in dataset2,
> display warning, then display the value from dataset2. If
> not found in dataset2, display dataset1 value.
You don't need to use a variable for this. Dynamically
build trees in XSLT 1.0 (Result Tree Fragments) have a
boring restriction: you can't navigate in their structure as
you can for the input tree. You can just copy them in the
output. But you can use keys:
<xsl:key name="ds2" match="Dataset2/Item" use="@ID"/>
<xsl:template match="/">
<xsl:apply-templates select="Dataset1/Item" mode="dispatch"/>
</xsl:template>
<xsl:template match="Item" mode="dispatch">
<xsl:variable name="item2" select="key('ds2', @ID)"/>
<xsl:choose>
<xsl:when test="$item2">
<xsl:apply-templates select="$item2"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="Dataset1/Item">
In 1: <xsl:value-of select="."/>
</xsl:template>
<xsl:template match="Dataset2/Item">
[warn] In 2: <xsl:value-of select="."/>
</xsl:template>
Warning: not tested, and written in my MUA...
Regards,
--drkm
p5.vert.ukl.yahoo.com uncompressed/chunked Wed Aug 30 12:13:39 GMT 2006
___________________________________________________________________________
Découvrez un nouveau moyen de poser toutes vos questions quelque soit le
sujet !
Yahoo! Questions/Réponses pour partager vos connaissances, vos opinions et
vos expériences.
http://fr.answers.yahoo.com
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
_________________________________________________________________
Check the weather nationwide with MSN Search: Try it now!
http://search.msn.com/results.aspx?q=weather&FORM=WLMTAG
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--