Stephan Daratha: preceding-sibling mit Bedingung

Beitrag lesen

Hi

Ich habe ein Problem

Ich habe folgene Struktur:

<prices>
<priceObject date="20070824" weekday="Fri" adults="4" childs="0" minLength="1" status="R">
<price day="1" date="2007-08-25" weekday="Sat">447</price>
<price day="2" date="2007-08-26" regular="447" weekday="Sun">324</price>
<price day="3" date="2007-08-27" regular="447" weekday="Mon">353</price>
<price day="7" date="2007-08-31" weekday="Fri">447</price>
<price day="14" date="2007-09-07" weekday="Fri">863</price>
<price day="21" date="2007-09-14" weekday="Fri">1280</price>
</priceObject>
<priceObject date="20070831" weekday="Fri" adults="4" childs="0" minLength="1">
<price day="1" date="2007-09-01" weekday="Sat">447</price>
<price day="2" date="2007-09-02" regular="447" weekday="Sun">324</price>
<price day="3" date="2007-09-03" regular="447" weekday="Mon">353</price>
<price day="7" date="2007-09-07" weekday="Fri">447</price>
<price day="14" date="2007-09-14" weekday="Fri">863</price>
<price day="21" date="2007-09-21" weekday="Fri">1280</price>
</priceObject>
</prices>

Dort stehen halt zu einem Objekt zu verschiedenen Zeiten verschiede Preis.

Man übergibt halt ein Datum und eine Dauer und er soll die passende Daten raussuchen.

<xsl:for-each select="/prices/priceObject[(($only = 1 and price/@day = $difference) or ($only = '' and price/@day &gt;= $difference)) and @adults = $firstAdult]">
<xsl:sort select="@adults"/>
<xsl:sort select="@date" order="descending"/>
<xsl:if test="(@date &gt;= $date and ($date &gt; preceding-sibling::priceObject[1]/@date) or (position() = count(/prices/priceObject[(($only = 1 and price/@day = $difference) or ($only = '' and price/@day &gt;= $difference)) and @adults = $firstAdult]) and @date &lt; $date))">     xsl:choose
  <xsl:when test="position() = count(/prices/priceObject[(($only = 1 and price/@day = $difference) or ($only = '' and price/@day &gt;= $difference)) and @adults = $firstAdult])">    <xsl:value-of select="@date"/>     </xsl:when>      xsl:otherwise       <xsl:value-of select="preceding-sibling::priceObject[1]/@date"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>

Das Problem ist das im preceding-sibling::priceObject[1] immer das vorherige drin steht und nicht das vorherige der for-eac schleife.
Gibt es da noch etwas anderes? Oder hat da jemand nen anderen Tip?

Danke