Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14)
2005-05-06 14:45:50
David, I found a bug.
Supported software has bugs.
Free software picked up off mailing lists only has unexpected features.
Given:
<A>
<B period_begin="1" period_end="5"/>
<B period_begin="2" period_end="7"/>
<B period_begin="3" period_end="10"/>
<B period_begin="4" period_end="12"/>
<B period_begin="14" period_end="16"/>
<B period_begin="15" period_end="16"/>
<B period_begin="52" period_end="62"/>
</A>
Expected Result is:
<result>
<period begins="1" ends="12" />
<period begins="14" ends="16" />
<period begins="52" ends="62" />
<period begins="63" ends="150" />
</result>
Any ideas?
I wouldn't expect that last group from that input:-)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output indent="yes"/>
<xsl:template match="A">
<result>
<xsl:apply-templates select="B[1]"/>
</result>
</xsl:template>
<xsl:template match="B">
<xsl:param name="b" select="@period_begin"/>
<xsl:param name="e" select="@period_end"/>
<xsl:param name="g" select="/.."/>
<xsl:variable name="e2" select="@period_end[. > $e]|$e[. >=
current()/@period_end]"/>
<xsl:choose>
<xsl:when test="following-sibling::B[(_at_)period_begin <=$e2 and
@period_end >= $e2]">
<xsl:apply-templates select="following-sibling::B[1]">
<xsl:with-param name="b" select="$b"/>
<xsl:with-param name="e" select="$e2"/>
<xsl:with-param name="g" select="$g|."/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<period begins="{$b}" ends="{$e2}">
<xsl:copy-of select="$g|."/>
</period>
<xsl:apply-templates select="following-sibling::B[1]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
$ saxon period.xml period.xsl
<?xml version="1.0" encoding="utf-8"?>
<result>
<period begins="1" ends="12">
<B period_begin="1" period_end="5"/>
<B period_begin="2" period_end="7"/>
<B period_begin="3" period_end="10"/>
<B period_begin="4" period_end="12"/>
</period>
<period begins="14" ends="16">
<B period_begin="14" period_end="16"/>
<B period_begin="15" period_end="16"/>
</period>
<period begins="52" ends="62">
<B period_begin="52" period_end="62"/>
</period>
</result>
________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
--~------------------------------------------------------------------
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>
--~--
<Prev in Thread] |
Current Thread |
[Next in Thread>
|
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14), (continued)
- Message not available
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14), Karl Stubsjoen
- RE: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14), Michael Kay
- Message not available
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14), Karl Stubsjoen
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14), David Carlisle
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14), Karl Stubsjoen
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14), David Carlisle
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14), Karl Stubsjoen
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14), David Carlisle
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14), Wendell Piez
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14), Karl Stubsjoen
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14),
David Carlisle <=
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14), Karl Stubsjoen
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14, Aron Bock
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14, Aron Bock
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14), David Carlisle
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14, Aron Bock
- Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14), Wendell Piez
Re: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14), Dimitre Novatchev
RE: A challenge.. Group Periods of Data (1..5, 2..8, 4..9) (10..12; 10..14), Andrew Welch
|
|
|