[xsl] Thorny select: getting surrounding years

Subject: [xsl] Thorny select: getting surrounding years
From: Brooks Talley <brooks@xxxxxxxxxxxxx>
Date: Thu, 21 Oct 2010 10:12:46 -1000
I've been wresting with this, and my brain is melting. I need to get a
list of the surrounding years for an item -- zero to two years before,
the item itself, zero to two years after. There may be gaps in the
sequence, in which case I still need two items before and after (if
available).

Sample xml:

<root>
   <item>
      <id>12345</id>
      <year>2005</year>
   </item>
   <otherYears>
     <item>
        <id>56789</id>
        <year>2001<year>
     </item>
     <item>
        <id>67890</id>
        <year>2002<year>
     </item>
     <item>
        <id>78901</id>
        <year>2003<year>
     </item>
     <item>
        <id>12345</id>
        <year>2005<year>
     </item>
     <item>
        <id>89012</id>
        <year>2006<year>
     </item>
     <item>
        <id>90123</id>
        <year>2008<year>
     </item>
   </otherYears>
</root>

Desired output (or similar, the select is the hard part):

2002 = 67890
2003 = 78901
2005 = 12345
2006 = 89012
2008 = 90123

Many thanks!
-Brooks

Current Thread