Re: [xsl] XML Differences

Subject: Re: [xsl] XML Differences
From: Antonio Fiol Bonnín <fiol@xxxxxxxxxx>
Date: Thu, 27 Jun 2002 07:38:26 +0200
Carlos Sanchez wrote:

Hi,

Has someone work on a style sheet that "detects" the different between
two documents. Taking one of them as the master, the style sheet should
be able to return the included/excluded elements (attributes) and
element content differences.

Any information will be very much appreciated.

Carlos


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



.




I have done something along that line. However the result was very picky (as expected from an automatic comparison tool), and I did not find any way of making it better.

My "tool" (what a great name for what I did) does this:

File 1:
<asdf>
<qwerty>
<poiuyy fwefew="1" />
text
</querty>
<test />
</asdf>

File 2:
<asdf>
<qwerty>
<poiuyy fwefew="2" />
different text
</querty>
</asdf>

Result:
<asdf>
<qwerty>
<xsl:choose>
<xsl:when test="$mode=1">
<poiuyy fwefew="1" />
text
</xsl:when>
<xsl:when test="$mode=2">
<poiuyy fwefew="2" />
different text
</xsl:when>
</xsl:choose>
</querty>
<xsl:choose>
<xsl:when test="$mode=1">
<test />
</xsl:when>
</xsl:choose>
</asdf>

So, this is a document that inserted in a proper stylesheet (which sets the mode param, among other things) is capable to output each of the input documents.

I conceived this as a compression method for a set of similar (template-based) XHTML files.

I found some trouble when extending that to 3 or more files (not that it is not possible, but I did not have enough time. The idea I had for the extension was taking the output of the first transform as file 1 and re-transform it with a third file as file 2. There is some support for that in my code, but it is not tested, and will break if the input files are XSL files, as I treat xsl:choose and xsl:when different from other elements. Removing that should not be that hard...

I found more trouble when I discovered that my XHTML files were not exactly template-based, so my combined version was nearly as big as the sum of two of the documents.

I would give it away. Just ask me if that is what you need.


Antonio Fiol



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



Current Thread