Hello:
Below is my XML and XSLT codes. I use Altova XMLSpy application. I am having problem pulling out the informatoins from XML as I want them to be arrange in a suitable order, meaning, I want to process the nodes/element at random. The desire output should be in below format:
------------------------------
[Ref, Hotelname, Type]
[resort,region,country]
[start-date, end-date]
[Price]
[Layout information]
-----------------------------
How do I get the desire output above with my below XML and XSLT codes???, Please help me out.
----------------------------------------
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="hotel.xslt"?>
<hotel-availability-list xmlns:xsi="
<hotel name="Hotel Rwanda" reference="AP021" class="apartment" occupants="9">
<availability>
<time-period>
<start-date>2005-08-01</start-date>
<end-date>2005-08-15</end-date>
</time-period>
<price>300</price>
</availability>
<location>
<country>Rwanda</country>
<region> Kukues</region>
<resort>Kigali</resort>
<address>Kigali Lusiada 8500-801 </address>
</location>
<description>
<text> Hotel is divided and linked</text>
<image>pria.jpeg</image>
</description>
<layout>
<room class="bedroom" id="bed-1">Twin bed, sink </room>
<room class="bedroom" id="bed-2">Twin bed </room>
<room class="bathroom">Sink, WC, shower</room>
<room class="kitchen">Small kitchenette and fridge</room>
</layout>
<features>
<pool length="30" max-depth="160" min-depth="30"
indoor="false"/>
<DVD/>
<beds twin="2" sofa-bed="1"/>
</features>
</hotel></hotel-availability-list>
XSLT Codes (not running properly):
-----------------------------------
<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet xmlns:xsl=" version="1.0">
<xsl
utput method="xml"/>
<!-- ************* HOTEL **************** -->
<xsl:template match="hotel">
<table border="1" width="45%" >
<tr>
<td colspan="2" align="left" ><b>
<xsl:text>[</xsl:text><xsl:value-of select="@reference"/><xsl:text>]
</xsl:text><xsl:text> </xsl:text> <xsl:text>[</xsl:text><xsl:value-of select="@name"/><xsl:text>]</xsl:text></b></td>
<td><xsl:value-of select="@class"/></td>
<td ><xsl:value-of select="@occupants"/></td>
</tr>
</table>
<xsl:apply-templates/>
</xsl:template>
<!-- ********* LOCATION *************** -->
<xsl:template match="location">
<table border="1" width="45%">
<tr>
<td colspan="3" align="left" >
<b><xsl:text>Location:</xsl:text></b>
<!-- text as location-->
<xsl:text> </xsl:text> <!-- space-->
<xsl:text>[</xsl:text>
<xsl:value-of select="resort"/><xsl:text>]</xsl:text>
<xsl:text>[</xsl:text>
<xsl:value-of select="region"/><xsl:text>]</xsl:text>
<xsl:text>[</xsl:text>
<xsl:value-of select="country"/><xsl:text>]</xsl:text>
<br></br>
<xsl:value-of select="address"/>
</td>
</tr>
</table>
<xsl:apply-templates/>
</xsl:template>
<!-- ****** TIME PERIOD ************* -->
<xsl:template match="availability/time-period">
<table border="1" width="45%" >
<td>
<b><xsl:text>Availability:</xsl:text></b><br></br>
<xsl:text>[</xsl:text>
<xsl:value-of select="start-date"/>
<xsl:text>]</xsl:text>
<xsl:text>-to-</xsl:text>
<xsl:text>[</xsl:text>
<xsl:value-of select="end-date"/>
<xsl:text>]</xsl:text>
</td>
</table>
<xsl:apply-templates/>
</xsl:template>
<!-- *************** LAYOUT ***************** -->
<xsl:template match="room">
<td border="1" width="35%" >
<tr><xsl:value-of select="@class"/><xsl:text>, </xsl:text></tr>
<xsl:value-of select="@id"/><xsl:text>, </xsl:text>
<xsl:apply-templates/>
</td>
</xsl:template>
<!-- *********** FEATURES ************** -->
<xsl:template match="pool">
<p>
<b><xsl:text> Pool:- </xsl:text></b>
<td>length:<xsl:value-of select="@length"/>
<xsl:text>, </xsl:text></td>
<td>max-depth:<xsl:value-of select="@max-depth"/>
<xsl:text>, </xsl:text>
</td>
<td>min-depth: <xsl:value-of select="@min-depth"/>
<xsl:text>, </xsl:text>
</td>
<td>indoor: <xsl:value-of select="@indoor"/><xsl:text>, </xsl:text></td>
</p>
<xsl:apply-templates/>
</xsl:template>
<!-- ******* Bed*********** -->
<xsl:template match="beds">
<p><b><xsl:text> Beds:- </xsl:text></b>
<td>Twin: <xsl:value-of select="@twin"/><xsl:text>, </xsl:text></td>
<td>Sofa-bed: <xsl:value-of select="@sofa-bed"/><xsl:text>, </xsl:text></td></p>
<xsl:apply-templates/>
</xsl:template>
<!-- ******END OF STYLESHEET *********** -->
</xsl:stylesheet>
Below is my XML and XSLT codes. I use Altova XMLSpy application. I am having problem pulling out the informatoins from XML as I want them to be arrange in a suitable order, meaning, I want to process the nodes/element at random. The desire output should be in below format:
------------------------------
[Ref, Hotelname, Type]
[resort,region,country]
[start-date, end-date]
[Price]
[Layout information]
-----------------------------
How do I get the desire output above with my below XML and XSLT codes???, Please help me out.
----------------------------------------
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="hotel.xslt"?>
<hotel-availability-list xmlns:xsi="
<hotel name="Hotel Rwanda" reference="AP021" class="apartment" occupants="9">
<availability>
<time-period>
<start-date>2005-08-01</start-date>
<end-date>2005-08-15</end-date>
</time-period>
<price>300</price>
</availability>
<location>
<country>Rwanda</country>
<region> Kukues</region>
<resort>Kigali</resort>
<address>Kigali Lusiada 8500-801 </address>
</location>
<description>
<text> Hotel is divided and linked</text>
<image>pria.jpeg</image>
</description>
<layout>
<room class="bedroom" id="bed-1">Twin bed, sink </room>
<room class="bedroom" id="bed-2">Twin bed </room>
<room class="bathroom">Sink, WC, shower</room>
<room class="kitchen">Small kitchenette and fridge</room>
</layout>
<features>
<pool length="30" max-depth="160" min-depth="30"
indoor="false"/>
<DVD/>
<beds twin="2" sofa-bed="1"/>
</features>
</hotel></hotel-availability-list>
XSLT Codes (not running properly):
-----------------------------------
<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet xmlns:xsl=" version="1.0">
<xsl
<!-- ************* HOTEL **************** -->
<xsl:template match="hotel">
<table border="1" width="45%" >
<tr>
<td colspan="2" align="left" ><b>
<xsl:text>[</xsl:text><xsl:value-of select="@reference"/><xsl:text>]
</xsl:text><xsl:text> </xsl:text> <xsl:text>[</xsl:text><xsl:value-of select="@name"/><xsl:text>]</xsl:text></b></td>
<td><xsl:value-of select="@class"/></td>
<td ><xsl:value-of select="@occupants"/></td>
</tr>
</table>
<xsl:apply-templates/>
</xsl:template>
<!-- ********* LOCATION *************** -->
<xsl:template match="location">
<table border="1" width="45%">
<tr>
<td colspan="3" align="left" >
<b><xsl:text>Location:</xsl:text></b>
<!-- text as location-->
<xsl:text> </xsl:text> <!-- space-->
<xsl:text>[</xsl:text>
<xsl:value-of select="resort"/><xsl:text>]</xsl:text>
<xsl:text>[</xsl:text>
<xsl:value-of select="region"/><xsl:text>]</xsl:text>
<xsl:text>[</xsl:text>
<xsl:value-of select="country"/><xsl:text>]</xsl:text>
<br></br>
<xsl:value-of select="address"/>
</td>
</tr>
</table>
<xsl:apply-templates/>
</xsl:template>
<!-- ****** TIME PERIOD ************* -->
<xsl:template match="availability/time-period">
<table border="1" width="45%" >
<td>
<b><xsl:text>Availability:</xsl:text></b><br></br>
<xsl:text>[</xsl:text>
<xsl:value-of select="start-date"/>
<xsl:text>]</xsl:text>
<xsl:text>-to-</xsl:text>
<xsl:text>[</xsl:text>
<xsl:value-of select="end-date"/>
<xsl:text>]</xsl:text>
</td>
</table>
<xsl:apply-templates/>
</xsl:template>
<!-- *************** LAYOUT ***************** -->
<xsl:template match="room">
<td border="1" width="35%" >
<tr><xsl:value-of select="@class"/><xsl:text>, </xsl:text></tr>
<xsl:value-of select="@id"/><xsl:text>, </xsl:text>
<xsl:apply-templates/>
</td>
</xsl:template>
<!-- *********** FEATURES ************** -->
<xsl:template match="pool">
<p>
<b><xsl:text> Pool:- </xsl:text></b>
<td>length:<xsl:value-of select="@length"/>
<xsl:text>, </xsl:text></td>
<td>max-depth:<xsl:value-of select="@max-depth"/>
<xsl:text>, </xsl:text>
</td>
<td>min-depth: <xsl:value-of select="@min-depth"/>
<xsl:text>, </xsl:text>
</td>
<td>indoor: <xsl:value-of select="@indoor"/><xsl:text>, </xsl:text></td>
</p>
<xsl:apply-templates/>
</xsl:template>
<!-- ******* Bed*********** -->
<xsl:template match="beds">
<p><b><xsl:text> Beds:- </xsl:text></b>
<td>Twin: <xsl:value-of select="@twin"/><xsl:text>, </xsl:text></td>
<td>Sofa-bed: <xsl:value-of select="@sofa-bed"/><xsl:text>, </xsl:text></td></p>
<xsl:apply-templates/>
</xsl:template>
<!-- ******END OF STYLESHEET *********** -->
</xsl:stylesheet>