0
如果與先前的房間無餘量值相等,我需要檢查特定酒店中每個可用房間的shrui值。其他值只有1。我曾嘗試過,它沒有奏效。以下是我的代碼。任何人都可以幫助我解決這個問題。檢查上一個節點值的值並將當前值增加一個
<xsl:for-each select="hm:AvailableRoom ">
<availableroom>
<hotelcode>
<xsl:value-of select="preceding-sibling::hm:HotelInfo/hm:Code"/>
</hotelcode>
<xsl:for-each select="hm:HotelOccupancy ">
<roomcount>
<xsl:value-of select="hm:RoomCount"/>
</roomcount>
<xsl:for-each select="hm:Occupancy ">
<guests>
<xsl:value-of select="sum((hm:AdultCount | hm:ChildCount)[number(.) = .])"/>
</guests>
<adults>
<xsl:value-of select="hm:AdultCount"/>
</adults>
<children>
<xsl:value-of select="hm:ChildCount"/>
</children>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="hm:HotelRoom ">
<shrui>
<xsl:value-of select="@SHRUI"/>
</shrui>
<xsl:choose>
<xsl:when test="preceding-sibling::hm:HotelRoom[1]/@[email protected]">
<noofroom>2</noofroom>
</xsl:when>
<xsl:otherwise>
<noofroom>1</noofroom>
</xsl:otherwise>
</xsl:choose>
<board>
<xsl:value-of select="hm:Board"/>
</board>
<roomtype>
<xsl:value-of select="hm:RoomType"/>
</roomtype>
<roomcode>
<xsl:value-of select="hm:RoomType/@code"/>
</roomcode>
<boardcode>
<xsl:value-of select="hm:Board/@code"/>
</boardcode>
<xsl:for-each select="hm:Price ">
<amount>
<xsl:value-of select="hm:Amount"/>
</amount>
</xsl:for-each>
</xsl:for-each>
</availableroom>
</xsl:for-each>
我的XML
<AvailableRoom>
<HotelOccupancy>
<RoomCount>1</RoomCount>
<Occupancy>
<AdultCount>1</AdultCount>
<ChildCount>0</ChildCount>
</Occupancy>
</HotelOccupancy>
<HotelRoom SHRUI="H6xFv7ejhSWcGuc+BCBYmg==" availCount="2" onRequest="N">
<Board type="SIMPLE" code="FB-E10" shortname="FB">FULL BOARD</Board>
<RoomType type="SIMPLE" code="SGL-E10" characteristic="ST">SINGLE STANDARD</RoomType>
<Price>
<Amount>269.580</Amount>
</Price>
</HotelRoom>
</AvailableRoom>
<AvailableRoom>
<HotelOccupancy>
<RoomCount>1</RoomCount>
<Occupancy>
<AdultCount>1</AdultCount>
<ChildCount>0</ChildCount>
</Occupancy>
</HotelOccupancy>
<HotelRoom SHRUI="H6xFv7ejhSWcGuc+BCBYmg==" availCount="2" onRequest="N">
<Board type="SIMPLE" code="FB-E10" shortname="FB">FULL BOARD</Board>
<RoomType type="SIMPLE" code="SGL-E10" characteristic="ST">SINGLE STANDARD</RoomType>
<Price>
<Amount>269.580</Amount>
</Price>
</HotelRoom>
</AvailableRoom>
我們需要查看XML結構的示例,以及您想要的結果和當前得到的結果。 –
嗨,我已經包含了我的XML。 –