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