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?

有帮助吗?

解决方案

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]" />  
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top