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

Re: Conditionally compare dates from two XML docs?

Subject: Re: Conditionally compare dates from two XML docs?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 21 Feb 2003 08:32:24 +0000
xsl compare dates
Hi Damian,

> How do I access the 'date1' from the original source tree, now that
> I'm processing the external document 'AddNews.xml'? i.e, change
> context from one document to another?

Store it in a variable before you change the context:

  <xsl:variable name="date1" select="date1" />
  <xsl:for-each select="document('AddNews.xml')/newsindex/entry">
    <xsl:if test="number($date1) = number(date2)">
      <xsl:value-of select="headline"/>
    </xsl:if>
  </xsl:for-each>

Or, if that's the totality of your <xsl:for-each>, you could use a
predicate and the current() function instead, and do:

  <xsl:for-each select="document('AddNews.xml')/newsindex/entry
                          [date2 = current()/date1]">
    <xsl:value-of select="headline" />
  </xsl:for-each>

In an XPath predicate, the current() function gets you the current
node -- the node that you're processing outside the XPath.
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.