2013-10-28 117 views
0

我的xslt仅适用于XMl的第一条记录,但不适用于其他记录。我不知道如何获得通过xslt填充的其他记录。我确信它与酒店有关订单=但我是XMl的新东西,所以请帮助。xslt中xml的第二条记录

请帮我

XML的代码如下:

<?xml version="1.0" encoding="ISO-8859-1"?> 
<DestinationResults size="1"> 
    <Destination name="Paris, FRA" order="1"> 
    <HotelAvailabilityListResults size="10"> 
     <Hotel order="1"> 
     <hotelId>188139</hotelId> 
     <name> 
      <![CDATA[ Hotel Magenta Paris ]]> 
     </name> 
     <address1>38 Boulevard De Magenta</address1> 
     <address2/> 
     <address3/> 
     <city>Paris</city> 
     <stateProvince/> 
     <country>FR</country> 
     <postalCode>75010</postalCode> 
     <latitude>48.87203</latitude> 
     <longitude>2.35995</longitude> 
     <tripAdvisorRating>4.0</tripAdvisorRating> 
     <fromDate>10/11/2013</fromDate> 
     <toDate>10/12/2013</toDate> 
     <shortDescription> 
      <![CDATA[&lt;p&gt;&lt;b&gt;Property Location&lt;/b&gt; &lt;br /&gt;With a stay at Hotel Magenta Paris in Paris (Gare du Nord - Gare de L&apos;Est), you&apos;ll be minutes from Porte Saint-Martin and close to Louvre Museum. This]]> 
     </shortDescription> 
     <thumbNailUrl> 
http://origin-images.ian.com/hotels/1000000/890000/889000/888903/888903_22_t.jpg 
     </thumbNailUrl> 
     <propertyRating>3.0</propertyRating> 
     <referenceProximityDistance>-1.0</referenceProximityDistance> 
     <referenceProximityUnit/> 
     <HotelProperty> 
      <promoDescription>Stay 1 nights and save 10% off your stay!</promoDescription> 
      <ValueAdds> 
      <valueAdd id="2048">Free Wireless Internet</valueAdd> 
      </ValueAdds> 
      <PromoRateInfo> 
      <displayCurrencyCode>USD</displayCurrencyCode> 
      <DisplayNightlyRates size="1"> 
       <displayNightlyRate>152.02</displayNightlyRate> 
      </DisplayNightlyRates> 
      <displayRoomRate>168.68</displayRoomRate> 
      <chargeableRoomRateTotal>168.68</chargeableRoomRateTotal> 
      <chargeableRoomRateTaxesAndFees>16.66</chargeableRoomRateTaxesAndFees> 
      <taxesOnly>16.66</taxesOnly> 
      <salesTax>0</salesTax> 
      <hotelOccupancyTax>0</hotelOccupancyTax> 
      <nativeCurrencyCode>USD</nativeCurrencyCode> 
      <NativeNightlyRates size="1"> 
       <nativeNightlyRate>152.02</nativeNightlyRate> 
      </NativeNightlyRates> 
      <nativeRoomRate>168.68</nativeRoomRate> 
      <rateFrequency>B</rateFrequency> 
      </PromoRateInfo> 
      <RateInfo> 
      <displayCurrencyCode>USD</displayCurrencyCode> 
      <DisplayNightlyRates size="1"> 
       <displayNightlyRate>168.91</displayNightlyRate> 
      </DisplayNightlyRates> 
      <displayRoomRate>185.57</displayRoomRate> 
      <chargeableRoomRateTotal>185.57</chargeableRoomRateTotal> 
      <chargeableRoomRateTaxesAndFees>16.66</chargeableRoomRateTaxesAndFees> 
      <taxesOnly>16.66</taxesOnly> 
      <salesTax>0</salesTax> 
      <hotelOccupancyTax>0</hotelOccupancyTax> 
      <nativeCurrencyCode>USD</nativeCurrencyCode> 
      <NativeNightlyRates size="1"> 
       <nativeNightlyRate>168.91</nativeNightlyRate> 
      </NativeNightlyRates> 
      <nativeRoomRate>185.57</nativeRoomRate> 
      <rateFrequency>B</rateFrequency> 
      </RateInfo> 
     </HotelProperty> 
     <hotelUrl> 
http://booking.rated-hotels.co.uk/index.jsp?pageName=hotAvail&cid=409870&hotelID=188139&mode=2&numberOfRooms=1&room-0-adult-total=2&room-0-child-total=0&arrivalMonth=9&arrivalDay=11&departureMonth=9&departureDay=12&showInfo=true&locale=en_US&currencyCode=USD&mcicid=409870.HOTEL.XML.85419 
     </hotelUrl> 
     </Hotel> 

    </HotelAvailabilityListResults> 
    </Destination> 
</DestinationResults> 

和我的XSLT是如下:

<?xml version="1.0" encoding="ISO-8859-1"?> 
<!-- Edited by XMLSpy® --> 
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"> 
    <body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE"> 

    <xsl:for-each select="DestinationResults"> 
    <xsl:for-each select="Destination"> 
    <xsl:for-each select="HotelAvailabilityListResults"> 
    <xsl:for-each select="Hotel"> 

     <div style="background-color:teal;color:white;padding:4px"> 
     <span style="font-weight:bold"><xsl:value-of select="name"/></span> 
     - <xsl:value-of select="city"/> 
     </div> 
     <div style="margin-left:20px;margin-bottom:1em;font-size:10pt"> 
     <p><xsl:value-of select="shortDescription"/>. 
     <span style="font-style:italic"> 
      <xsl:value-of select="address1"/> 
     </span>.</p> 
     </div> 
    </xsl:for-each> 
    </xsl:for-each> 
    </xsl:for-each> 
    </xsl:for-each> 

    </body> 
</html> 
+3

这个xml示例有一个酒店 –

+1

,并且您有格式错误(hotelUrl中的非转义&符号)。我不确定CDATA块;为什么CDATA中的某些数据会阻塞,有些则不?它看起来很随意。 –

+0

将URL中的&符号更改为'%26“也是一个很好的开始。 – GMasucci

回答

0

我刚才测试了XML和XSL出渔隐的在线测试人员在http://xslttest.appspot.com/,大部分似乎没问题,一旦你删除了你的xslt的前两行,并且将&标志改为%26(对于urls re成员URL编码任何特殊字符,XML字段记得XML编码)

2项XML文件here

和修改的XSL文件是here

XSL转换返回这两个项目对我来说,但是您仍然需要更正某些格式值以确保其正确显示。