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

Re: XML Merge

Subject: Re: XML Merge
From: David Carver <d_a_carver@xxxxxxxxx>
Date: Fri, 27 Jun 2003 12:19:52 -0700 (PDT)
xml merge
>I've changed that to the following now:
><xsl:when test="action">
>    <xsl:apply-templates select="action"/>
></xsl:when>
>
>
>unless you also moved the xsl:copy outside that is still going to give
>you the problem that parents of action elements are not copied.
>I don'tthink you want the xsl:choose at all.

Thanks to Dave Carlise's help, I now have the merge working as I wanted
it too.   Dave, I did end up getting rid of the xsl:choose, I had in
the main template.

Anyway, I had to end up using a for loop to handle the output of the
forward elements the way I wanted too.  For those that are intersted
here is the completed XSLT.  Any way to shorten this or make it more
efficient would be appreciated.

This XSLT takes an struts-config.xml file, and merges it with an
external file that contains updates that need to be done to the action
elements and child forward elements.

XSLT Merge:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
   <xsl:template match="/">
      <xsl:apply-templates />
   </xsl:template>
   
   <xsl:template 
     match="*|@*|comment()|processing-instruction()|text()">
        <xsl:copy>
         <xsl:apply-templates
          select="*|@*|comment()|processing-instruction()|text()"/>
         </xsl:copy>
   </xsl:template>
   
   <xsl:template match="action-mappings/action">
      <xsl:choose>
      <xsl:when test="@path =
document('struts-config_new_variables01.xml')//action/@path">
      <!-- Copy the value where @path = document()//action/@path -->
           <xsl:variable name="pathvalue" select="@path"/>
           <xsl:variable name="nodeset"
select="document('struts-config_new_variables01.xml')//action[@path =
$pathvalue]"/>
         <xsl:element name="action">
             <xsl:apply-templates select="$nodeset/@*"/>
             <xsl:apply-templates select="$nodeset/forward"/>
        <xsl:for-each select="./forward">
            <xsl:if test="not(@name = $nodeset/forward/@name)">
             <xsl:copy>
         <xsl:apply-templates
          select="*|@*|comment()|processing-instruction()|text()"/>
    </xsl:copy>
           </xsl:if>
        </xsl:for-each>
         </xsl:element>
      </xsl:when>
      <xsl:otherwise>
         <xsl:copy>
             <xsl:apply-templates
          select="*|@*|comment()|processing-instruction()|text()"/>
         </xsl:copy>

      </xsl:otherwise>
      </xsl:choose>
   </xsl:template>
   
 <xsl:template match="action/forward">
     <xsl:copy>
         <xsl:apply-templates
          select="*|@*|comment()|processing-instruction()|text()"/>
    </xsl:copy>
   </xsl:template>
</xsl:stylesheet>




=====
"The difference between fiction and reality is that fiction has to make
sense." - Tom Clancy

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


Current Thread
  • Re: XML Merge
    • David Carver - Fri, 27 Jun 2003 15:20:31 -0400 (EDT) <=

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.