|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: start-stopping xml output
Please try this stylesheet(tested with Saxon 8.5.1)
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/root">
<root>
<xsl:apply-templates select="item" />
</root>
</xsl:template>
<xsl:template match="item" />
<xsl:template match="item[. = 'C'][preceding-sibling::item[1] =
'B'][preceding-sibling::item[2] = 'A']">
<xsl:call-template name="printvalues">
<xsl:with-param name="nodeset" select="following-sibling::item" />
</xsl:call-template>
</xsl:template>
<xsl:template name="printvalues">
<xsl:param name="nodeset" />
<xsl:if test="not($nodeset[1] = 'D')">
<item><xsl:value-of select="$nodeset[1]" /></item>
<xsl:call-template name="printvalues">
<xsl:with-param name="nodeset" select="$nodeset[position() > 1]" />
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Regards,
Mukul
On 9/22/05, geoff hopkins <geoffhopkins123@xxxxxxxxx> wrote:
> Thanks spot on!
>
> In addition a similar concept is that if 'A' then 'B'
> then 'C' is found in consecutive nodes then start
> reading and stop reading when 'D' is found.
>
> <root>
> <item>Z</item>
> <item>A</item>
> <item>B</item>
> <item>C</item>
> <item>BOB1</item>
> <item>BOB2</item>
> <item>BOB3</item>
> <item>BOB4</item>
> <item>D</item>
> <item>BOB5</item>
> <item>BOB6</item>
> <item>A</item>
> <item>BOB7</item>
> <item>B</item>
> <item>BOB8</item>
> <item>C</item>
> <item>BOB9</item>
> <item>B</item>
> <item>BOB10</item>
> </root>
>
> output would look something like this
>
> <root>
> <item>BOB1</item>
> <item>BOB2</item>
> <item>BOB3</item>
> <item>BOB4</item>
> </root>
|
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








