[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

current() - referring to top in nested predicates

Subject: current() - referring to top in nested predicates
From: Michael Ludwig <mlu@xxxxxxxxxxxxx>
Date: Wed, 06 Aug 2008 13:48:29 +0200
 current() - referring to top in nested predicates
<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>.

A <B> is an event scheduled for a point in time.

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 1.0 is required.

<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
                      . &lt; current()/following-sibling::T[1]]) > 0]"/>
  </xsl:template>
  <xsl:template match="T">
    <xsl:value-of select="."/>
    <xsl:text>&#10;</xsl:text>
  </xsl:template>
</xsl:transform>

Michael Ludwig

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.