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

comparing xml documents

Subject: comparing xml documents
From: Koteswararao Mogili <raomvk@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 16 Sep 2003 11:24:07 -0400
compare xml documents
Hi,

I am trying to compare two XML documents and create a new document which is the merge of the both documents. The following code is comparing properly but when i try to use copy or copy-of command in the template , i am getting wrong output, Any suggestion is greatly appreciated..

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" indent="yes" method="xml" version="1.0"/>


<xsl:template match="/">

<xsl:variable name="doc2node" select="document('/XML/offer_1_2.xml')"/>

<xsl:attribute name="action">N</xsl:attribute>
<xsl:for-each select="descendant-or-self::*">
<xsl:copy-of select="."/>
<xsl:variable name="index" select="position()"/>
<xsl:apply-templates select=".">
<xsl:with-param name="doc2node" select="$doc2node/descendant-or-self::*[position() = $index]"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:template>


    <xsl:template match="*">
        <xsl:param name="doc2node"/>

<xsl:variable name="elementName" select="name()"/>
<xsl:message>doc1node---><xsl:value-of select="$elementName"/></xsl:message>
<xsl:message>doc2node---><xsl:value-of select="name($doc2node)"/></xsl:message>
<xsl:apply-templates mode="C" select="$doc2node"/>
<xsl:for-each select="@*">
<xsl:variable name="attributeName" select="name()"/>
<xsl:apply-templates select=".">
<xsl:with-param name="doc2node" select="$doc2node/@*[name()=$attributeName]"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:template>


    <xsl:template match="@*">
        <xsl:param name="doc2node" />

<xsl:choose>
<xsl:when test="not(.=$doc2node)">
<xsl:message>-----><xsl:value-of select="$doc2node"/></xsl:message>
<xsl:attribute name="action">N</xsl:attribute>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>




Thanks

Rao


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.