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

Re: Selecting the value from diff i/p XML

Subject: Re: Selecting the value from diff i/p XML
From: Hermann Stamm-Wilbrandt <STAMMW@xxxxxxxxxx>
Date: Thu, 16 Sep 2010 01:00:01 +0200
Re:  Selecting the value from diff i/p XML
Gerrit,

good solutions.

While the simpler with Root1.xml as input is to prefer it
is also XSLT 1.0.

I modified your other solution in order to emulate 3-argument
XPath2 key function in XSLT 1.0:

   <xsl:template match="/">
-    <xsl:for-each select="key(
-                            'idlist',
-                            key('idlist', $data/root1/item/@id)/@id,
-                            $data
-                          )
-                          ">
-      <xsl:value-of select="@value"/>
-      <br/>
+    <xsl:variable name="ids"
+                  select="key('idlist', $data/root1/item/@id)/@id"/>
+    <xsl:for-each select="$data">
+      <xsl:for-each select="key(
+                              'idlist',
+                              $ids
+                            )
+                            ">
+        <xsl:value-of select="@value"/>
+        <br/>
+      </xsl:for-each>
     </xsl:for-each>
   </xsl:template>



$ xsltproc 2.xsl Root1.xml
A<br/>C<br/>E<br/>F<br/>H<br/>I<br/>J<br/>
$
$ saxon 1.xsl Root2.xml ; echo
A<br/>C<br/>E<br/>F<br/>H<br/>I<br/>J<br/>
$
$ xsltproc 1a.xsl Root2.xml
A<br/>C<br/>E<br/>F<br/>H<br/>I<br/>J<br/>
$



Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Developer, XML Compiler, L3
Fixpack team lead
WebSphere DataPower SOA Appliances
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294



From:       "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx>
To:         xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Date:       09/15/2010 11:54 PM
Subject:    Re:  Selecting the value from diff i/p XML





On 15.09.2010 23:51, Imsieke, Gerrit, le-tex wrote:
> You key function returns the elements of Root2.xml whose id matches
> those of the Root1 items.
>
> But ultimately you want to lookup the value attributes of the
> corresponding Root1 elements.
>
> If you really want to process root2.xml as primary source, you may try
> this (XPath2's 3-argument key function involved):
In fact, it's the XSLT2 and not an XPath2 key function:
http://www.w3.org/TR/xslt20/#function-key

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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