[xsl] Combining XMLs

Subject: [xsl] Combining XMLs
From: Kevin.Gutch@xxxxxxxxxxx
Date: Fri, 2 Nov 2001 14:46:52 -0500
I have the following code (which many of you provided help with. Thanks).
It works well but I have been handed a new wrinkle. Anyway, what I am doing
is combining two XMLs. Below is my code with my problem explained below it.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl
="http://www.w3.org/1999/XSL/Transform";>
     <xsl:output method="xml" indent="no"/>
     <xsl:key name="key-lookup" match
="//data_description_params/properties/property" use="@value"/>
     <xsl:variable name="k" select="document('D:\A.xml')"/>

     <xsl:template match="*|@">
          <xsl:copy>
               <xsl:copy-of select="@*"/>
               <xsl:apply-templates/>
          </xsl:copy>
     </xsl:template>
<xsl:template match="themes">
  <themes>

    <!-- apply templates to get the themes from A.xml -->
    <xsl:apply-templates select="$k" mode="copyThemes">
      <xsl:with-param name="curr-label" select="." />
    </xsl:apply-templates>
  </themes>
</xsl:template>

<xsl:template match="/" mode="copyThemes">
  <xsl:param name="curr-label" />
  <xsl:copy-of select="key
('key-lookup',$curr-label/../data_params/data_description_params/properties/property/@value)/../../../../themes/override_theme"

/>

</xsl:template>

</xsl:stylesheet>


Problem: If there are two elements with the same
$curr-label/../data_params/data_description_params/properties/property/@value
(which is the new wrinkle), I get  the information from every instance of
@value placed into the Themes element. This logically makes sense because I
am telling it to place this value wherever the key value matches @value. I
really want to place the value in order of appearance. So if @value occurs
twice in A.xml then place the first instance in b.xml's  first instance of
@value etc.

Here is my resulting xml snippet:


<themes>
        <override_theme>
           <theme_name/>
           <theme_level>1</theme_level>
           <common_rendition>
             <rendition>
               <style stroke="#FFFFFF" stroke-width="5.0"/>
             </rendition>
           </common_rendition>
        </override_theme>
        <override_theme>
           <theme_name/>
           <theme_level>1</theme_level>
           <common_rendition>
             <rendition>
               <style stroke="#AD9C8C" stroke-width="7.0"/>
             </rendition>
           </common_rendition>
        </override_theme>
      </themes>


I know this may sound confusing but it really makes a lot of sense to me
(j/k). Any suggestions?




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread