[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: problem building a lookup table and find match fro
Subject: Re: problem building a lookup table and find match from a different template
From: "Leslie Young" <xlr8sx@xxxxxxxxxxx>
Date: Wed, 30 Aug 2006 15:19:39 -0500
|
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@xxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: 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
___________________________________________________________________________
Dicouvrez un nouveau moyen de poser toutes vos questions quelque soit le
sujet !
Yahoo! Questions/Riponses pour partager vos connaissances, vos opinions et
vos expiriences.
http://fr.answers.yahoo.com
_________________________________________________________________
Check the weather nationwide with MSN Search: Try it now!
http://search.msn.com/results.aspx?q=weather&FORM=WLMTAG
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|