Subject: [xsl] Follow path in source-xml according to another source-document From: christoph.naber@xxxxxxxxxxx Date: Thu, 22 Nov 2007 17:57:23 +0100 |
Hello list, I want to follow a path in a given source-document, which is a "light"-version of another source document. The used processor is xsltproc, but the stylesheet is intended to run on Xalan so I have to use XSLT 1.0. The input-file-size will be up to 5 MB. Example "light" input XML <root> <elem1 id="one"> <elem2 id="two"> <elem4 id="three_three" /> </elem2> <elem3 id="six"> <elem5 id="seven" /> </elem3> </elem1> </root> Example "large" input XML <root> <elem1 id="one"> <elem2 id="two"> <elem4 id="three_one" /> <elem4 id="three_two" /> <elem4 id="three_three"> Here is the data of three_three </elem4> <elem4 id="three_four" /> </elem2> <elem3 id="four"> <elem5 id="five" /> </elem3> <elem3 id="six"> <elem5 id="seven" > Here is the data of seven </elem5> </elem3> <elem3 id="eight"> <elem5 id="nine" /> </elem3> </elem1> </root> Desired output: Here is the data of three_three Here is the data of seven This is the stylesheet that I managed to write so far. But I have no idea if this is the XSL-way to perform such a task. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common"> <xsl:output method="xml" indent="yes"/> <xsl:param name="lightdoc" select="string('light.xml')" /> <xsl:template match="/" > <xsl:apply-templates select="root" > <xsl:with-param name="light" select="document($lightdoc)/root" /> </xsl:apply-templates> </xsl:template> <xsl:template match="node()" > <xsl:param name="light" /> <xsl:variable name="large" select="current()" /> <xsl:choose> <!-- We dont want to match textnodes or processing-instructions --> <xsl:when test="count($light/*) > 0" > <xsl:for-each select="$light/*"> <!-- not sure if I have to use node-set here --> <xsl:apply-templates select="exsl:node-set($large)/node()[@id = current()/@id]" > <xsl:with-param name="light" select="current()" /> </xsl:apply-templates> </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:value-of select="$large/text()" /> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> Any insight, eg. search items would be appreciated. Greetings Christoph Naber If you are not the addressee, please inform us immediately that you have received this e-mail by mistake, and delete it. We thank you for your support.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Re: Getting output from a, Keith Hughes | Thread | Re: [xsl] Follow path in source-xml, Mukul Gandhi |
Re: [xsl] Issue with repetition of , Mukul Gandhi | Date | [xsl] Re: Getting output from a dro, Keith Hughes |
Month |