Question

I am using XSLT to generate some webpages and I need to create links for the next and previous day. The structure is roughly as follows:

year
  month
    day
    day
    ...
  month
    day *
    day
    ...
  ...
...

Tried using the preceding-sibling and following-sibling axis, but then discovered they of course won't work for the first and last day of a month. For example preceding-sibling would return nothing for the day marked with *.

How can I get the previous and next day for a given day, across the year and month "barriers", using XSLT 1.0?

Était-ce utile?

La solution

The axis operators you are looking for in this case are preceding and following, which gets the preceding or following node regardless of the level in the hierarchy.

<xsl:copy-of select="following::day[1]" />

<xsl:copy-of select="preceding::day[1]" />  
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top