|
next
|
Subject: Recursively Mathcing up two XML Schemas? Author: Ronan Hayes Date: 14 Feb 2006 09:55 AM Originally Posted: 14 Feb 2006 09:30 AM
|
Not 100% clear on whats going on there, but I wll take a closer read in a second.<br>
<br>
The problem with the approach above, is that I am not 100% as to what has been changed, hence why I was hoping for a recursive style <br>
<br>
eg:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/test">
<diff>
<xsl:call-template name="compareNodes">
<xsl:with-param name="curNode" select="."/>
<xsl:with-param name="ghostNode" select="document('comp2.xml')/test"/>
<xsl:with-param name="repPath" select="'/test'"/>
</xsl:call-template>
</diff>
</xsl:template>
<xsl:template name="compareNodes">
<xsl:param name="curNode"/>
<xsl:param name="ghostNode"/>
<xsl:param name="repPath"/>
<xsl:choose>
<xsl:when test="*">
<xsl:for-each select="*">
<xsl:variable name="cname" select="name()"/>
<xsl:choose>
<xsl:when test="$ghostNode/*[name() = $cname]">
<xsl:call-template name="compareNodes">
<xsl:with-param name="curNode" select="."/>
<xsl:with-param name="ghostNode" select="$ghostNode/*[name() = $cname]"/>
<xsl:with-param name="repPath" select="concat($repPath, '/', $cname)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<missingPath><xsl:value-of select="concat($repPath, '/', $cname)"/></missingPath>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Any ideas on how to adapt the copy-of to this similar style?
<br>
<br>
Basically what I do know, is that each Schema has the same root, and potentially the same structure, just with varios elements being added or removed, depending on how the schemas have been updated. I want to remain generic and flexible, so that in 3 months time when the schema is changed again, that the application still functions correctly.
|
|
|
|