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

Combining XMLs

Subject: Combining XMLs
From: Kevin.Gutch@xxxxxxxxxxx
Date: Fri, 2 Nov 2001 14:46:52 -0500
combining 2 xmls
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

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.