Re: [xsl] Conditionally compare dates from two XML docs?

Subject: Re: [xsl] Conditionally compare dates from two XML docs?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 21 Feb 2003 08:32:24 +0000
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"/>

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" />

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


Jeni Tennison

 XSL-List info and archive:

Current Thread