|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Conditional merge of 2 XML files
On Thu, 01 Sep 2005 11:35:41 +0200, Joris Gillis <roac@xxxxxxxxxx> wrote:
Tempore 04:54:32, die 09/01/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Thomas Tarpin-Lyonnet <bartleby@xxxxxxxxxx>: After partial recovery of the breakdown (caused by whitespace text nodes), I've managed to produce a solution. This stylesheet should match your requirements more closely: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:strip-space elements="*"/> <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:variable name="n"><xsl:number/></xsl:variable> <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()|$test/*"> <xsl:with-param name="test" select="$test[name()=name(current())][number($n)]/*"/> <xsl:with-param name="reference" select="*"/> </xsl:apply-templates> </xsl:copy> </xsl:when> <xsl:when test="$reference and $test[count(.|current())=1]"> <xsl:if test="current()[text()[normalize-space()!='']][not(text()=$reference/text())] or not($reference[name()=name(current())][number($n)])"> <xsl:copy-of select="."/> </xsl:if> </xsl:when> </xsl:choose> </xsl:template> </xsl:stylesheet>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








