Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts

    XSL values not displaying

    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.

    Code:
     <?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>

    Code:
    <!-- 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>

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Code:
    <!-- 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

  • #3
    New to the CF scene
    Join Date
    May 2009
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thank you for the suggestion. I made that correction and the values still won't display. Is there anything else I am doing wrong?

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Tiney83 View Post
    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:
    Code:
    <xsl:apply-templates ...
    Edit: also check if xml prolog start in first column of the first line, without spaces or something else

    best regards
    Last edited by oesxyl; 05-10-2009 at 11:10 AM.

  • #5
    New to the CF scene
    Join Date
    May 2009
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Tiney83 View Post
    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.
    Code:
    <?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:
    Code:
    <?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

  • Users who have thanked oesxyl for this post:

    Tiney83 (05-10-2009)

  • #7
    New to the CF scene
    Join Date
    May 2009
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    this still wont display for me .

    Thank you for your time.

  • #8
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Tiney83 View Post
    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

  • #9
    New to the CF scene
    Join Date
    May 2009
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oesxyl View Post
    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."
    Last edited by Tiney83; 05-11-2009 at 01:32 AM.

  • #10
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Tiney83 View Post
    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

  • Users who have thanked oesxyl for this post:

    Tiney83 (05-11-2009)

  • #11
    New to the CF scene
    Join Date
    May 2009
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thank you so much, I finally got it to work. I can't tell you how much I appreciate your help.

  • #12
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Tiney83 View Post
    Thank you so much, I finally got it to work. I can't tell you how much I appreciate your help.
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •