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(_dot_)schubert(_at_)gmail(_dot_)com> wrote:
Imagine XML data, where continuous selection of data - randomly made by
the user - is being marked by using a <start/> and <end/> element.
For example:
<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>
The desired nodes would be
<ex:span>
Some text C..
<ex:span>
Some text D..
Is there an easy way to process this kind of selection with XSLT?
Best regards,
Svante
--
Regards,
Mukul Gandhi
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--