A simple way to do this:
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="/*/file1/*/*/client">
<xsl:if test="not(../@cat = /*/file2/*/*/client[number =
current()/number]/../@cat)">
<xsl:copy-of select=". | /*/file2/*/*/client[number =
current()/number]" />
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
when this transformation is applied on this source.xml (I combined the two
files in one for convenience -- you'll have to use document()):
<files>
<file1>
<root>
<clients cat="corp">
<client>
<number>0098</number>
<lastname>Smith </lastname>
<frstname>Joh n</frstname>
<email>1@1.1</email>
</client>
<client>
<number>0067</number>
<lastname>Carte r</lastname>
<frstname>Gar y</frstname>
<email>2@2.2</email>
</client>
</clients>
<clients cat="prvt">
<client>
<number>0076</number>
<lastname>Lavig ne</lastname>
<frstname>Avril </frstname>
<email>3@3.3</email>
</client>
<client>
<number>0055</number>
<lastname>Donne ly</lastname>
<frstname>Al</frstname>
<email>4@4.4</email>
</client>
</clients>
</root>
</file1>
<file2>
<root>
<clients cat="corp">
<client>
<number>0098</number>
<lastname>Smith </lastname>
<frstname>Joh n</frstname>
<email>1@1.1</email>
</client>
</clients>
<clients cat="prvt">
<client>
<number>0076</number>
<lastname>Lavig ne</lastname>
<frstname>Avril </frstname>
<email>3@3.3</email>
</client>
<client>
<number>0055</number>
<lastname>Donne ly</lastname>
<frstname>Al</frstname>
<email>4@4.4</email>
</client>
<client>
<number>0067</number>
<lastname>Carte r</lastname>
<frstname>Gar y</frstname>
<email>2@2.2</email>
</client>
</clients>
</root>
</file2>
</files>
the wanted result is produced:
<client>
<number>0067</number>
<lastname>Carte r</lastname>
<frstname>Gar y</frstname>
<email>2@2.2</email>
</client>
<client>
<number>0067</number>
<lastname>Carte r</lastname>
<frstname>Gar y</frstname>
<email>2@2.2</email>
</client>
=====
Cheers,
Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
"Frank" <fr************ *@yahoo.com> wrote in message
news:23******** *************** ***@posting.goo gle.com...
Hi, is there a way to use XSL to compare two XML files to verify if a
"record"
in an XML file has changed of parent in another XML file ?
I am trying to implement a template in an XSL stylesheet that would be
able to compare the two files below
and indicate if a client has changed of category (ex.: from "corp" to
"prvt").
Any help would be gladly appreciated, I am desparatly trying to find a
solution to this.
In the above example, client number 0067 has changed
from "corp" (in file1.xml) to "prvt" (in file2.xml).
file1.xml:
-----------
<root>
<clients cat="corp">
<client>
<number>0098</number>
<lastname>Smith </lastname>
<frstname>Joh n</frstname>
<email>1@1.1</email>
</client>
<client>
<number>0067</number>
<lastname>Carte r</lastname>
<frstname>Gar y</frstname>
<email>2@2.2</email>
</client>
</clients>
<clients cat="prvt">
<client>
<number>0076</number>
<lastname>Lavig ne</lastname>
<frstname>Avril </frstname>
<email>3@3.3</email>
</client>
<client>
<number>0055</number>
<lastname>Donne ly</lastname>
<frstname>Al</frstname>
<email>4@4.4</email>
</client>
</clients>
</root>
file2.xml:
-----------
<root>
<clients cat="corp">
<client>
<number>0098</number>
<lastname>Smith </lastname>
<frstname>Joh n</frstname>
<email>1@1.1</email>
</client>
</clients>
<clients cat="prvt">
<client>
<number>0076</number>
<lastname>Lavig ne</lastname>
<frstname>Avril </frstname>
<email>3@3.3</email>
</client>
<client>
<number>0055</number>
<lastname>Donne ly</lastname>
<frstname>Al</frstname>
<email>4@4.4</email>
</client>
<client>
<number>0067</number>
<lastname>Carte r</lastname>
<frstname>Gar y</frstname>
<email>2@2.2</email>
</client>
</clients>
</root>
THANKS!