我的XML文件:XSLT无法正常转化
<result>
<xml_acc>
<CheckInFrom>01:15</CheckInFrom>
<CheckInTo>00:30</CheckInTo>
<CheckOutFrom>00:45</CheckOutFrom>
<CheckOutTo>01:15</CheckOutTo>
<hotel_id>1</hotel_id>
<name>Tahir Hotel</name>
<hoteltype>Tahir Hotel</hoteltype>
<CityID>1</CityID>
<city>London</city>
<CountryID>26</CountryID>
<CurrencyId>26</CurrencyId>
<languagecode>1</languagecode>
<Latitude>13131313</Latitude>
<Longitude>11131131</Longitude>
<max_persons_in_reservation>1000</max_persons_in_reservation>
<ranking>1</ranking>
<url>123Testing</url>
<zip>W2 6DX</zip>
</xml_acc>
<xml_acc>
<CheckInFrom>01:15</CheckInFrom>
<CheckInTo>00:30</CheckInTo>
<CheckOutFrom>00:45</CheckOutFrom>
<CheckOutTo>01:15</CheckOutTo>
<hotel_id>1</hotel_id>
<name>Tahir Hotel</name>
<hoteltype>Tahir Hotel</hoteltype>
<CityID>1</CityID>
<city>London</city>
<CountryID>26</CountryID>
<CurrencyId>26</CurrencyId>
<languagecode>1</languagecode>
<Latitude>13131313</Latitude>
<Longitude>11131131</Longitude>
<max_persons_in_reservation>1000</max_persons_in_reservation>
<ranking>1</ranking>
<url>123Testing</url>
<zip>W2 6DX</zip>
</xml_acc>
</result>
我申请以下XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes" method="html" />
<xsl:strip-space elements="*"/>
<xsl:template match="xml_acc">
<result>
<!--<xsl:apply-templates select="node()[not(self::CheckInTo) and not(self::CheckInFrom)][not(self::CheckOutTo) and not(self::CheckOutFrom)]"/>-->
<Address>
<xsl:apply-templates select="Address"/>
</Address>
<checkin>
<from>
<xsl:apply-templates select="CheckInTo"/>
</from>
<to>
<xsl:apply-templates select="CheckInFrom"/>
</to>
</checkin>
<city>
<xsl:apply-templates select="city"/>
</city>
<city_id>
<xsl:apply-templates select="CityID"/>
</city_id>
<Location>
<Latitude>
<xsl:apply-templates select="Latitude"/>
</Latitude>
<Longitude>
<xsl:apply-templates select="Longitude"/>
</Longitude>
</Location>
<city_id>
<xsl:apply-templates select="CityID"/>
</city_id>
<max_persons_in_reservation>
<xsl:apply-templates select="max_persons_in_reservation"/>
</max_persons_in_reservation>
<name>
<xsl:apply-templates select="name"/>
</name>
<ranking>
<xsl:apply-templates select="ranking"/>
</ranking>
<url>
<xsl:apply-templates select="url"/>
</url>
<zip>
<xsl:apply-templates select="zip"/>
</zip>
</result>
</xsl:template>
</xsl:stylesheet>
而且我得到的结果:
<result>
<Address>
</Address>
<checkin>
<from>00:30</from>
<to>01:15</to>
</checkin>
<city>London</city>
<city_id>1</city_id>
<Location>
<Latitude>13131313</Latitude>
<Longitude>11131131</Longitude>
</Location>
<city_id>1</city_id>
<max_persons_in_reservation>1000</max_persons_in_reservation>
<name>Tahir Hotel</name>
<ranking>1</ranking>
<url>123Testing</url>
<zip>W2 6DX</zip>
</result>
<result>
<Address></Address>
<checkin>
<from>00:30</from>
<to>01:15</to>
</checkin>
<city>London</city>
<city_id>1</city_id>
<Location>
<Latitude>13131313</Latitude>
<Longitude>11131131</Longitude>
</Location>
<city_id>1</city_id>
<max_persons_in_reservation>1000</max_persons_in_reservation>
<name>Tahir Hotel</name>
<ranking>1</ranking>
<url>123Testing</url>
<zip>W2 6DX</zip>
</result>
我的XSLT与生成XML多个根标签。我希望应该有一个根元素,并且在这个标签中应该出现多个标签。 我想结果是这样的:
<hotels>
<result>
<Address>
</Address>
<checkin>
<from>00:30</from>
<to>01:15</to>
</checkin>
<city>London</city>
<city_id>1</city_id>
<Location>
<Latitude>13131313</Latitude>
<Longitude>11131131</Longitude>
</Location>
<city_id>1</city_id>
<max_persons_in_reservation>1000</max_persons_in_reservation>
<name>Tahir Hotel</name>
<ranking>1</ranking>
<url>123Testing</url>
<zip>W2 6DX</zip>
</result>
<result>
<Address></Address>
<checkin>
<from>00:30</from>
<to>01:15</to>
</checkin>
<city>London</city>
<city_id>1</city_id>
<Location>
<Latitude>13131313</Latitude>
<Longitude>11131131</Longitude>
</Location>
<city_id>1</city_id>
<max_persons_in_reservation>1000</max_persons_in_reservation>
<name>Tahir Hotel</name>
<ranking>1</ranking>
<url>123Testing</url>
<zip>W2 6DX</zip>
</result>
</hotels>
请帮我解决这个问题。我创建了一个测试页面,您可以通过从这里复制粘贴文本到我的页面来检查您的评论。下面是测试代码的链接:
http://shahbaz.somee.com/Default.aspx
它不工作,当我在我的XSLT文件中添加以下代码,结果如下图所示: –
user2069823
2013-02-13 21:06:07
对不起 - 看到更新 – Goran 2013-02-13 21:11:44