从父节点值xslt增加一个当前值

时间:2013-07-30 05:28:04

标签: xml xslt xpath xhtml

如果条件为真,我需要将当前节点值从先前的节点值增加1。我在下面附加了My XSLT和XML。如果板和房间类型相同,我想从之前的noofroom值增加noofroom的值。否则noofroom应该是one.currently我手动设置为2。任何人都可以帮助我。 我的XML ......

 <AvailableRoom>
                <HotelOccupancy>
                  <RoomCount>1</RoomCount>
                  <Occupancy>
                    <AdultCount>1</AdultCount>
                    <ChildCount>0</ChildCount>
                  </Occupancy>
                </HotelOccupancy>
                <HotelRoom SHRUI="DVB8XS0PRiyGagcJUhDETw==" availCount="2" onRequest="N">
                  <Board type="SIMPLE" code="RO-E10" shortname="RO">ROOM ONLY</Board>
                  <RoomType type="SIMPLE" code="SGL-E10" characteristic="DX">SINGLE DELUXE</RoomType>
                  <Price>
                    <Amount>178.020</Amount>
                  </Price>
                </HotelRoom>
              </AvailableRoom>
              <AvailableRoom>
                <HotelOccupancy>
                  <RoomCount>1</RoomCount>
                  <Occupancy>
                    <AdultCount>1</AdultCount>
                    <ChildCount>1</ChildCount>
                  </Occupancy>
                </HotelOccupancy>
                <HotelRoom SHRUI="yrfO/b/aFGqxZ9ks6Lu2Tg==" availCount="2" onRequest="N">
                  <Board type="SIMPLE" code="RO-E10" shortname="RO">ROOM ONLY</Board>
                  <RoomType type="SIMPLE" code="DBL-E10" characteristic="DX">DOUBLE DELUXE</RoomType>
                  <Price>
                    <Amount>186.480</Amount>
                  </Price>
                </HotelRoom>
              </AvailableRoom>

我的XSLT。

<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="parent::hm:AvailableRoom/preceding-sibling::hm:AvailableRoom[1]/hm:HotelRoom/hm:RoomType=hm:RoomType and parent::hm:AvailableRoom/preceding-sibling::hm:AvailableRoom[1]/hm:HotelRoom/hm:Board=hm:Board">
                    <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>

0 个答案:

没有答案