...

View Full Version : XSL values not displaying



Tiney83
05-09-2009, 07:08 PM
Hi all, I was hoping someone could point me in the right direction. I am in the beginning stages of doing a school project using XML about Hawaii. Each island is an xml document and which an attatched xsl stylesheet. The website is basically about "fake" hotels in Hawaii. I am trying to get the costPerNight element to show up but it isnt and I cannot figure out why, because the table elements within the costs template show up.


<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="hawaii.xsl" ?>
<island>Kauai
<hotels>
<hotel>Kauai Beach Inn
<address>
<street>23 Boardwalk Road</street>
<city>Anahola</city>
<zip>96703</zip>
</address>
<phone>919-555-1234</phone>
<description>description here</description>
<costs>
<costPerNight>$75.00</costPerNight>
<specialCost></specialCost>
</costs>
</hotel>
</hotels>
</island>






<!-- DWXMLSource="kauai.xml" --><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/xSL/Transform">
<xsl:output method="html" version="4.0" />
<xsl:template match="/">
<html>
<head>
<title>Blue Dolphin Resorts</title>
<link href="hawaii.css" rel="stylesheet" type="text/css" />
</head>
<body>

<apply-templates select="island/hotels/hotel/costPerNight"/>

</body>
</html>
</xsl:template>


<xsl:template match="costs">
<table>
<tr>
<th>Usual Cost Per Night</th>
<th>Discounted Cost Per Night</th>
</tr>
<tr>
</tr>
</table>
</xsl:template>

<xsl:template match="costPerNight">
<h3><xsl:value-of select="."/>
</h3>
</xsl:template>


</xsl:stylesheet>

oesxyl
05-10-2009, 06:26 AM
<!-- DWXMLSource="kauai.xml" --><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/xSL/Transform">
<xsl:output method="html" version="4.0" />
<xsl:template match="/">
<html>
<head>
<title>Blue Dolphin Resorts</title>
<link href="hawaii.css" rel="stylesheet" type="text/css" />
</head>
<body>

<apply-templates select="island/hotels/hotel/costs/costPerNight"/>

</body>
</html>
</xsl:template>


<xsl:template match="costs">
<table>
<tr>
<th>Usual Cost Per Night</th>
<th>Discounted Cost Per Night</th>
</tr>
<tr>
</tr>
</table>
</xsl:template>

<xsl:template match="costPerNight">
<h3><xsl:value-of select="."/>
</h3>
</xsl:template>


</xsl:stylesheet>


I guess the xpath expression is incorrect.

best regards

Tiney83
05-10-2009, 11:02 AM
Thank you for the suggestion. I made that correction and the values still won't display. Is there anything else I am doing wrong?

oesxyl
05-10-2009, 11:07 AM
Thank you for the suggestion. I made that correction and the values still won't display. Is there anything else I am doing wrong?
yes, I didn't see until now, you miss the namespace for apply-templates, must be:


<xsl:apply-templates ...


also check if xml prolog start in first column of the first line, without spaces or something else
best regards

Tiney83
05-10-2009, 02:35 PM
I am going crazy. I have tried your suggestions and according to my textbook, all the code is all correct. I have no idea why it still won't display.

oesxyl
05-10-2009, 05:06 PM
I am going crazy. I have tried your suggestions and according to my textbook, all the code is all correct. I have no idea why it still won't display.



<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="hawaii.xsl"?>
<island>Kauai
<hotels>
<hotel>Kauai Beach Inn
<address>
<street>23 Boardwalk Road</street>
<city>Anahola</city>
<zip>96703</zip>
</address>
<phone>919-555-1234</phone>
<description>description here</description>
<costs>
<costPerNight>$75.00</costPerNight>
<specialCost></specialCost>
</costs>
</hotel>
</hotels>


hawaii.xsl:


<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html"
indent="yes" />

<xsl:template match="/">
<html>
<head>
<title>Blue Dolphin Resorts</title>
<link href="hawaii.css" rel="stylesheet" type="text/css" />
</head>
<body>
<xsl:apply-templates select="island/hotels/hotel/costs/costPerNight"/>
</body>
</html>
</xsl:template>


<xsl:template match="costs">
<table>
<tr>
<th>Usual Cost Per Night</th>
<th>Discounted Cost Per Night</th>
</tr>
<tr>
</tr>
</table>
</xsl:template>

<xsl:template match="costPerNight">
<h3><xsl:value-of select="."/>
</h3>
</xsl:template>


</xsl:stylesheet>


best regards

Tiney83
05-10-2009, 06:07 PM
this still wont display for me :(.

Thank you for your time.

oesxyl
05-10-2009, 11:36 PM
this still wont display for me :(.

Thank you for your time.
I test this and it work, both in a browser, ffox 2 and using xsltproc.
How do you display, what do you use?

best regards

Tiney83
05-11-2009, 01:25 AM
I test this and it work, both in a browser, ffox 2 and using xsltproc.
How do you display, what do you use?

best regards

I tried Explorer 7.0, and when viewing it in that the only thing it says is
"Usual Cost Per Night Discounted Cost Per Night" from the table in the template,Doesnt show the costPerNight value. I also tried Firefox 3.0 with the XSLT tools addon and when I try to run it tells me this "Error loading stylesheet: Parsing an XSLT stylesheet failed."

oesxyl
05-11-2009, 01:36 AM
I tried Explorer 7.0, and when viewing it in that the only thing it says is
"Usual Cost Per Night Discounted Cost Per Night" from the table in the template,Doesnt show the cost value. I also tried Firefox 3.0 with the XSLT tools addon and when I try to run it tells me this "Error loading stylesheet: Parsing an XSLT stylesheet failed."
both are garbage, :)
your original problems is solved, now you have another one if you insist to use a browser, but I can't help you with this because I don't use them, :)

best regards

Tiney83
05-11-2009, 02:39 AM
Thank you so much, I finally got it to work. I can't tell you how much I appreciate your help.:thumbsup:

oesxyl
05-11-2009, 02:55 AM
Thank you so much, I finally got it to work. I can't tell you how much I appreciate your help.:thumbsup:
you are welcome, :)
unfortunately I don't have access to ie because I don't use windows and I can't install ffox 3 because I must deinstall ffox 2 and reinstall and put all setings and extensions back after testing, which take a longer time than I can afford, :)

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum