In principle you can do this as:
<xsl:template match="BREAK" priority="3"/>
<xsl:template match="*[not(preceding::BREAK)]" priority="2">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="*" priority="1"/>
But the performance might be very poor.
Faster solutions might be possible if you know where the BREAK element
can legitimately occur.
One way of speeding it up might be to do a pre-pass in which the
"top-level" elements (<level2>) are annotated with a BREAK attribute if
they contain a descendant BREAK element; you can then do the top-level
processing (in the second pass) as
<xsl:apply-templates
select="level2[not(preceding-sibling::*[(_at_)BREAK])]"/>
of if the BREAK is expected to appear near the start, process the level2
siblings recursively.
Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com
-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of
Chandra -
Sent: 03 January 2003 02:26
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] BreakPoint in an xml document
Hi all,
First of all, WISH YOU ALL A VERY HAPPY AND PROSPEROUS NEW
YEAR. Heres my question:
I am currently converting one xml file into another using a
XSL stylesheet. However, the original xml file contains a
tag which is like a
"break point". Anything tag below this breakpoint shouldn't
be processed.
For eg:
<level1>
<level2>
.....
</level2>
<level2>
...
</level2>
<level2>
...<BREAK>BreakPoint</BREAK>
</level2>
<level2
....
</level2>
<level2>
.....
</level2>
</level1>
In the above example, any tag below <BREAK> shouldn't be
processed i.e all <level2> tags and their children that come
below <BREAK> shouldn't be
processed.When I say "shouldn't be processed", I mean that
the tags or their
contents shouldn't be displayed in the final transformed
document. Is this
possible using a XSL stylesheet? I am guessing its not and
the only solution
is parse it using DOM in java?
Thanks in advance
Regards,
Chandra
_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*
http://join.msn.com/?page=features/virus
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list