[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: A challenge.. Group Periods of Data (1..5, 2..8,
David, WOW! ... i'm still trying to figure out how it works ... So, can you explain? This is like magic.. I've been trying to figure it out, but can't. Things I don't get: 1) Variable e2 select. select="@period_end[. > $e]|$e[. >= current()/@period_end]" How does the pipe work here and is this only evaluating the current B element, or evaluating all @period_end(s)? 2) Right off the bat (first iteration), I don't understand how you determine the period attribute "ends" value. 3) Variable g select, what does this get you, the ancestor record? select="/.." 4) The copy of within the element period within the otherwise then the apply templates rule, it obviously creates the new <period/> element, but I don't see how your recursive template call inserts the "members", I don't get how you are preserving the member element of period. Thanks again. Karl On 5/4/05, David Carlisle <davidc@xxxxxxxxx> wrote: > > > using Dimitre's test file (which has sorted input) here's a simplish > pure xslt1 solution, no node set or other extensions. > > > <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="../B[@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> > > </xsl:stylesheet> > > > <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="16" period_end="20"/> > <B period_begin="16" period_end="30"/> > <B period_begin="32" period_end="33"/> > <B period_begin="33" period_end="38"/> > </A> > > $ 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="30"> > <B period_begin="14" period_end="16"/> > <B period_begin="16" period_end="20"/> > <B period_begin="16" period_end="30"/> > </period> > <period begins="32" ends="38"> > <B period_begin="32" period_end="33"/> > <B period_begin="33" period_end="38"/> > </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 > ________________________________________________________________________
|
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
|