Subject: [xsl] current() - referring to top in nested predicates From: Michael Ludwig <mlu@xxxxxxxxxxxxx> Date: Wed, 06 Aug 2008 13:48:29 +0200 |
<Urmel> <T>0</T> <T>6</T> <T>12</T> <T>18</T> <T>24</T> <B>15</B> <B>6</B> <B>7</B> <B>12</B> <B>9</B> <B>10</B> </Urmel>
A <T> indicates a point in time. <T>s are ordered numerically. Direct siblings define an interval starting at the earlier <T> and ending before the later <T>.
I want to find all <T>s that start an interval which includes at least one event. All <T>s except the last one start an interval. The next following sibling ends the interval. This is easy. If the count of <B>s for the interval is zero, the interval is empty and I'm not interested; else I want it in the output. Determining emptiness isn't easy - yet.
The following produces empty output and hence doesn't work, but you probably can see my intention. Using the current() function, I'm trying to refer to the current <T> to find out if the current <B> contained in $b falls within the bounds of the interval, but without success.
This may fail because I'm nesting predicates and would need another variable instead of the current() function, but I can't figure out how to solve this, and maybe the problem can be reframed more intelligently.
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:variable name="b" select="//B"/> <xsl:apply-templates select=" //T [ position() != last() ] [ count( $b[. >= current() and . < current()/following-sibling::T[1]]) > 0]"/> </xsl:template> <xsl:template match="T"> <xsl:value-of select="."/> <xsl:text> </xsl:text> </xsl:template> </xsl:transform>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] matching question, Garvin Riensche | Thread | Re: [xsl] current() - referring to , Martin Honnen |
Re: [xsl] matching question, Garvin Riensche | Date | Re: [xsl] current() - referring to , Martin Honnen |
Month |