[Home] [By Thread] [By Date] [Recent Entries]
Please try the following.
The input XML is: <?xml version="1.0"?>
<ex:x xmlns:ex="http://dummy-ns">
<ex:paragraph>
<ex:START/>
<ex:span>
Some text C..
</ex:span>
</ex:paragraph>
<ex:paragraph>
Some text D..
<ex:END/>
<ex:span>
Some text F..
</ex:span>
</ex:paragraph>
</ex:x>The XSLT stylesheet is: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ex="http://dummy-ns"
version="1.0"><xsl:output method="xml" indent="yes" /> <xsl:template match="/"> <ex:result> <xsl:apply-templates select="//ex:START" /> </ex:result> </xsl:template> <xsl:template match="ex:START"> <xsl:call-template name="OutputContent"> <xsl:with-param name="node-set" select="following-sibling::node()[not(self::text() and normalize-space(.) = '')] | ../following-sibling::*/node()[not(self::text() and normalize-space(.) = '')]" /> </xsl:call-template> </xsl:template> <xsl:template name="OutputContent"> <xsl:param name="node-set" /> <xsl:if test="not($node-set[1]/self::ex:END)">
<xsl:copy-of select="$node-set[1]" />
<xsl:call-template name="OutputContent">
<xsl:with-param name="node-set" select="$node-set[position() > 1]" />
</xsl:call-template>
</xsl:if>
</xsl:template></xsl:stylesheet> The output produced is: <ex:result xmlns:ex="http://dummy-ns">
<ex:span>
Some text C..
</ex:span>
Some text D..
</ex:result>The stylesheet is not rigorously tested. But I feel, you could use this as it is, or perhaps adapt it. On 2/17/07, Svante Schubert <svante.schubert@xxxxxxxxx> wrote: Imagine XML data, where continuous selection of data - randomly made by the user - is being marked by using a <start/> and <end/> element. -- Regards, Mukul Gandhi
|

Cart



