Subject: Re: [xsl] Conditional merge of 2 XML files From: "Joris Gillis" <roac@xxxxxxxxxx> Date: Thu, 01 Sep 2005 11:35:41 +0200 |
Where file_1.xml are the logs generated by a test campaign and file_2.xml are the reference logs generated thanks to a test plan. The aim of doing this is to show all the tests that have been defined by the test plan but that we forgot to implement and then that don't appear in the logs.
<merge> <test>file_1.xml</test> <reference>file_2.xml</reference> </merge>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/>
<xsl:template match="merge"> <xsl:variable name="test" select="document(test)"/> <xsl:variable name="reference" select="document(reference)"/> <xsl:apply-templates mode="merge" select="$reference/*"> <xsl:with-param name="test" select="$test/*"/> <xsl:with-param name="reference" select="$reference/*"/> </xsl:apply-templates> </xsl:template>
<xsl:template match="*" mode="merge"> <xsl:param name="test"/> <xsl:param name="reference"/>
<xsl:choose> <xsl:when test="count(.|$reference)=count($reference)"> <xsl:copy> <xsl:copy-of select="$test[name()=name(current())][.=current()]/@*"/> <xsl:apply-templates mode="merge" select="*|text()"> <xsl:with-param name="test" select="$test/*"/> <xsl:with-param name="reference" select="$reference/*"/> </xsl:apply-templates> </xsl:copy> </xsl:when> <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> </xsl:choose> </xsl:template>
regards, -- Joris Gillis (http://users.telenet.be/root-jg/me.html) B+There are only 10 types of people in this world. Those who understand binary, and those who don'tB;
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Client XSL transformation, David Carlisle | Thread | Re: [xsl] Conditional merge of 2 XM, Joris Gillis |
Re: [xsl] Reg apply-templates and f, David Carlisle | Date | Re: [xsl] Diferent behaviour using , António Mota |
Month |