Resulta que tengo un xml dinámico que es la respuesta de un http request, al aplicarle una hoja de estilo XSL, no funciona, pero descubrí que cambiando:
xmlns="http://www.yahoo.com/schemas/messages"
por:
xmlnsi="http://www.yahoo.com/schemas/messages"
el script funciona, pero no encuentro explicación alguna, podrían ayudarme a encontrar una solución sin tener que hacer el cambio al xmlns. Gracias de antemano.
Este es mi XML:
<?xml version="1.0" encoding="UTF-8"?>
<availabilityRS
xmlnsi="http://www.yahoo.com/schemas/messages"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://www.yahoo.com/schemas/messages">
<auditData processTime="134" timestamp="2017-05-22 20:15:33.233" requestHost="65.44.252.333" serverId="sa37AUX3R23332.env" environment="[int]" release="09748902233322333222337b" token="332233233-2233-2233-3322-2233322233b1" internal="0|2233223322332233233444433433|MX|01|8|42|5,5|||||||||||83||1~2~2~2||0||0|2emmxkmta34a7gan9f4xdqq7||"/>
<hotels checkIn="2017-05-24" total="8" checkOut="2017-05-25">
<hotel code="20078" name="Las Brisas Acapulco" categoryCode="5EST" categoryName="5 STARS" destinationCode="ACA" destinationName="Acapulco" zoneCode="20" zoneName="Bahia" latitude="16.8263934714721" longitude="-99.8623721580134" minRate="4059.90" maxRate="4772.52" currency="MXN">
<rooms>
<room code="DBL.ST-1" name="DOUBLE STANDARD">
<rates>
<rate rateKey="20170524|20170525|W|71|20078|DBL.ST-1|CGW-MEXB2BMXN|RO||2~2~2|4~8|N@952F0BCE487A4AC3AC73918BCE4C7814" rateClass="NOR" rateType="BOOKABLE" net="4059.90" allotment="9" rateCommentsId="71|33975|0" paymentType="AT_WEB" packaging="false" boardCode="RO" boardName="ROOM ONLY" rooms="2" adults="2" children="2" childrenAges="4,8">
<cancellationPolicies>
<cancellationPolicy amount="4059.90" from="2017-05-21T23:59:00-05:00"/>
</cancellationPolicies>
<promotions>
<promotion code="044" name="15% Special Discount applied" remark="*** special discount rates ***"/>
</promotions>
<offers>
<offer code="9002" name="Early Booking discount" amount="-716.46"/>
<offer code="9001" name="Child discount" amount="-4776.36"/>
</offers>
</rate>
</rates>
</room>
<room code="DBL.PP" name="DOUBLE WITH PRIVATE POOL">
<rates>
<rate rateKey="20170524|20170525|W|71|20078|DBL.PP|CGW-MEXB2BMXN|RO||2~2~2|4~8|N@952F0BCE487A4AC3AC73918BCE4C7814" rateClass="NOR" rateType="BOOKABLE" net="4772.52" allotment="9" rateCommentsId="71|33975|0" paymentType="AT_WEB" packaging="false" boardCode="RO" boardName="ROOM ONLY" rooms="2" adults="2" children="2" childrenAges="4,8">
<cancellationPolicies>
<cancellationPolicy amount="4772.52" from="2017-05-21T23:59:00-05:00"/>
</cancellationPolicies>
<promotions>
<promotion code="044" name="15% Special Discount applied" remark="*** special discount rates ***"/>
</promotions>
<offers>
<offer code="9002" name="Early Booking discount" amount="-842.22"/>
<offer code="9001" name="Child discount" amount="-5614.76"/>
</offers>
</rate>
</rates>
</room>
</rooms>
</hotel>
</hotels>
</availabilityRS>
Y este es mi XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="*">
<html>
<body>
<h2>Búsqueda en Acapulco</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="color:blue;text-align:center">Hotel</th>
<th style="color:blue;text-align:center">Destino</th>
<th style="color:blue;text-align:center">Categoría</th>
</tr>
<xsl:for-each select="hotels/hotel">
<tr>
<td><xsl:value-of select="@name"/></td>
<td><xsl:value-of select="@destinationName"/></td>
<td><xsl:value-of select="@categoryName"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>