Problem converting XML to HTML using XSLT on Netscape 7.0

Discussion in 'XML' started by nanookfan, Jan 14, 2004.

  1. nanookfan

    nanookfan Guest

    Hi all,

    I'm having a bizarre problem converting XML files to HTML using an
    XSLT. The problem is only occuring in my Netscape 7.0 browser. What
    makes it more bizarre is that it is only happening when I put my XML
    files and the .xsl files on my ISP's system for my home page. If I
    try to open the XML files in Netscape 7.0 on my own machine (ie, not
    on the ISP's system), the pages convert file and the result is
    displayed in HTML.

    Under IE 6.0 there is no problem, both when the files are on the ISP's
    system or on my own machine.

    When I try to view the files from my ISP's system under Netscape 7.0,
    all I see is the XML code. There is no error message or anything like
    that, just the XML code.

    Something else that is bizarre...I went out to www.w3schools.com and
    was working through one of their tutorials on XSLT. I took a look at
    one of their examples converted XML to HTML by applying an XSLT. When
    I tried their example on their system using Netscape 7.0, it worked
    fine. However, when I took THEIR files and loaded them on my ISP's
    system and tried to view them using Netscape 7.0, again all I got to
    see was the XML code. Again, under IE 6.0 it worked fine in all
    cases.

    Below is one of the XML files:

    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="transcript.xsl"?>
    <transcript>
    <school>
    <name>University of Massachusetts - Lowell</name>
    <city>Lowell</city>
    <state abbreviation="MA">Massachusetts</state>
    <websiteurl>http://www.uml.edu/dce</websiteurl>
    <degree_program>None - Continuing Education Courses
    only</degree_program>
    </school>
    <courses>
    <course>
    <coursenumber>92.268</coursenumber>
    <coursename>C++ Programming</coursename>
    <semester>Spring</semester>
    <year>1993</year>
    <grade>A/B</grade>
    <credits>3.0</credits>
    <qualitypoints>3.5</qualitypoints>
    </course>
    <course>
    <coursenumber>92.270</coursenumber>
    <coursename>Visual C++ Programming</coursename>
    <semester>Spring</semester>
    <year>1998</year>
    <grade>A</grade>
    <credits>3.0</credits>
    <qualitypoints>4.0</qualitypoints>
    </course>
    <course>
    <coursenumber>90.301</coursenumber>
    <coursename>Java Programming</coursename>
    <semester>Spring</semester>
    <year>1999</year>
    <grade>A</grade>
    <credits>3.0</credits>
    <qualitypoints>4.0</qualitypoints>
    </course>
    <course>
    <coursenumber>91.373</coursenumber>
    <coursename>Dynamic HTML</coursename>
    <semester>Spring</semester>
    <year>1999</year>
    <grade>A/B</grade>
    <credits>3.0</credits>
    <qualitypoints>3.5</qualitypoints>
    </course>
    <course>
    <coursenumber>92.269</coursenumber>
    <coursename>Advanced C++ Programming</coursename>
    <semester>Summer</semester>
    <year>1999</year>
    <grade>A</grade>
    <credits>3.0</credits>
    <qualitypoints>4.0</qualitypoints>
    </course>
    <course>
    <coursenumber>90.303</coursenumber>
    <coursename>Advanced Java</coursename>
    <semester>Summer</semester>
    <year>2001</year>
    <grade>A</grade>
    <credits>3.0</credits>
    <qualitypoints>4.0</qualitypoints>
    </course>
    <course>
    <coursenumber>90.307</coursenumber>
    <coursename>Advanced Topics in Java and XML</coursename>
    <semester>Summer</semester>
    <year>2002</year>
    <grade>A</grade>
    <credits>3.0</credits>
    <qualitypoints>4.0</qualitypoints>
    </course>
    </courses>
    <totals>
    <gradepointaverage maximum="4.0">3.857</gradepointaverage>
    <credits>21</credits>
    </totals>
    <notes>
    <note>These courses were taken through the Universitys
    Department of Continuing Education, and are not part of a degree or
    certificate program.</note>
    <note>It is worth noting that these courses were not paid for by
    an employer, but out of my pocket, because I believe it is my
    responsibility to keep my skills as modern as possible.</note>
    </notes>
    </transcript>

    And here is the XSLT that is supposed to convert this into HTML:

    <?xml version="1.0"?>
    <xsl:stylesheet id="transcript"
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:eek:utput method="html"/>

    <xsl:template match="/">
    <xsl:element name="html">
    <xsl:element name="body">
    <xsl:apply-templates select="transcript/school"/>
    <xsl:element name="table">
    <xsl:attribute
    name="width"><xsl:text>100%</xsl:text></xsl:attribute>
    <xsl:apply-templates select="transcript/courses"/>
    <xsl:apply-templates select="transcript/totals"/>
    </xsl:element>
    <xsl:apply-templates select="transcript/notes"/>
    </xsl:element>
    </xsl:element>
    </xsl:template>

    <xsl:template match="school">
    <xsl:element name="title">
    <xsl:value-of select="./name"/><xsl:text>
    Transcripts</xsl:text>
    </xsl:element>
    <xsl:element name="h2">
    <xsl:attribute
    name="align"><xsl:text>center</xsl:text></xsl:attribute>
    <xsl:element name="a">
    <xsl:attribute name="href"><xsl:value-of
    select="./websiteurl"/></xsl:attribute>
    <xsl:value-of select="./name"/>
    </xsl:element>
    </xsl:element>
    <xsl:element name="h3">
    <xsl:attribute
    name="align"><xsl:text>center</xsl:text></xsl:attribute>
    <xsl:value-of select="./city"/><xsl:text>,
    </xsl:text><xsl:value-of select="./state/@abbreviation"/>
    <xsl:element name="br"/>
    </xsl:element>
    <xsl:element name="h4">
    <xsl:attribute
    name="align"><xsl:text>center</xsl:text></xsl:attribute>
    <xsl:element name="u"><xsl:text>DEGREE
    PROGRAM:</xsl:text></xsl:element>
    <xsl:text> </xsl:text><xsl:value-of
    select="./degree_program"/>
    </xsl:element>
    </xsl:template>

    <xsl:template match="courses">
    <xsl:element name="tr">
    <xsl:element name="th">Course Number</xsl:element>
    <xsl:element name="th">Course Name</xsl:element>
    <xsl:element name="th">Semester</xsl:element>
    <xsl:element name="th">Year</xsl:element>
    <xsl:element name="th">Grade</xsl:element>
    <xsl:element name="th">Credits</xsl:element>
    <xsl:element name="th">Quality Points</xsl:element>
    </xsl:element>
    <xsl:for-each select="./course">
    <xsl:apply-templates select="."/>
    </xsl:for-each>
    </xsl:template>

    <xsl:template match="course">
    <xsl:element name="tr">
    <xsl:element name="td"><xsl:value-of
    select="./coursenumber"/></xsl:element>
    <xsl:element name="td"><xsl:value-of
    select="./coursename"/></xsl:element>
    <xsl:element name="td"><xsl:value-of
    select="./semester"/></xsl:element>
    <xsl:element name="td"><xsl:value-of
    select="./year"/></xsl:element>
    <xsl:element name="td"><xsl:value-of
    select="./grade"/></xsl:element>
    <xsl:element name="td"><xsl:value-of
    select="./credits"/></xsl:element>
    <xsl:element name="td"><xsl:value-of
    select="./qualitypoints"/></xsl:element>
    </xsl:element>
    </xsl:template>

    <xsl:template match="totals">
    <xsl:element name="tr">
    <xsl:element name="td"><xsl:text> </xsl:text></xsl:element>
    <xsl:element name="td"><xsl:text> </xsl:text></xsl:element>
    <xsl:element name="td"><xsl:text> </xsl:text></xsl:element>
    <xsl:element name="td"><xsl:text> </xsl:text></xsl:element>
    <xsl:element name="td">
    <xsl:attribute
    name="align"><xsl:text>right</xsl:text></xsl:attribute>
    <xsl:element name="b"><xsl:text>TOTAL
    CREDITS:</xsl:text></xsl:element>
    </xsl:element>
    <xsl:element name="td"><xsl:value-of
    select="./credits"/></xsl:element>
    <xsl:element name="td"><xsl:text> </xsl:text></xsl:element>
    </xsl:element>
    <xsl:element name="tr">
    <xsl:element name="td"><xsl:text> </xsl:text></xsl:element>
    <xsl:element name="td"><xsl:text> </xsl:text></xsl:element>
    <xsl:element name="td"><xsl:text> </xsl:text></xsl:element>
    <xsl:element name="td"><xsl:text> </xsl:text></xsl:element>
    <xsl:element name="td">
    <xsl:attribute
    name="align"><xsl:text>right</xsl:text></xsl:attribute>
    <xsl:element name="b"><xsl:text>GPA:</xsl:text></xsl:element>
    </xsl:element>
    <xsl:element name="td"><xsl:value-of
    select="./gradepointaverage"/></xsl:element>
    <xsl:element name="td"><xsl:text> </xsl:text></xsl:element>
    </xsl:element>
    <xsl:element name="tr">
    <xsl:element name="td"><xsl:text> </xsl:text></xsl:element>
    <xsl:element name="td"><xsl:text> </xsl:text></xsl:element>
    <xsl:element name="td"><xsl:text> </xsl:text></xsl:element>
    <xsl:element name="td"><xsl:text> </xsl:text></xsl:element>
    <xsl:element name="td">
    <xsl:attribute
    name="align"><xsl:text>right</xsl:text></xsl:attribute>
    <xsl:element name="b"><xsl:text>MAX
    GPA:</xsl:text></xsl:element>
    </xsl:element>
    <xsl:element name="td">
    <xsl:value-of select="./gradepointaverage/@maximum"/>
    </xsl:element>
    <xsl:element name="td"><xsl:text> </xsl:text></xsl:element>
    </xsl:element>
    </xsl:template>

    <xsl:template match="notes">
    <xsl:for-each select="./note">
    <xsl:apply-templates select="."/>
    </xsl:for-each>
    </xsl:template>

    <xsl:template match="note">
    <xsl:element name="p">
    <xsl:value-of select="."/>
    </xsl:element>
    </xsl:template>

    </xsl:stylesheet>

    Does anyone see what might be causing the problem? Any help would be
    greatly appreciated.

    Thanks

    Kevin
    nanookfan, Jan 14, 2004
    #1
    1. Advertising

  2. nanookfan wrote:
    > Hi all,
    >
    > I'm having a bizarre problem converting XML files to HTML using an
    > XSLT. The problem is only occuring in my Netscape 7.0 browser. What
    > makes it more bizarre is that it is only happening when I put my XML
    > files and the .xsl files on my ISP's system for my home page. If I
    > try to open the XML files in Netscape 7.0 on my own machine (ie, not
    > on the ISP's system), the pages convert file and the result is
    > displayed in HTML.
    >
    > Under IE 6.0 there is no problem, both when the files are on the ISP's
    > system or on my own machine.


    Perhaps your IPS's web server serves the files with a wrong content-type
    header.
    --
    Johannes Koch
    In te domine speravi; non confundar in aeternum.
    (Te Deum, 4th cent.)
    Johannes Koch, Jan 14, 2004
    #2
    1. Advertising

  3. nanookfan wrote:


    > I'm having a bizarre problem converting XML files to HTML using an
    > XSLT. The problem is only occuring in my Netscape 7.0 browser. What
    > makes it more bizarre is that it is only happening when I put my XML
    > files and the .xsl files on my ISP's system for my home page. If I
    > try to open the XML files in Netscape 7.0 on my own machine (ie, not
    > on the ISP's system), the pages convert file and the result is
    > displayed in HTML.


    Please post a URL next time and not all that code. As already suggested
    the problem is usually the content type the web server sends, see
    http://www.mozilla.org/projects/xslt/faq.html

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jan 14, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom
    Replies:
    0
    Views:
    486
  2. RC
    Replies:
    6
    Views:
    633
    Martin Honnen
    Apr 22, 2005
  3. loveNUNO
    Replies:
    2
    Views:
    898
    loveNUNO
    Nov 20, 2003
  4. H. Kaya
    Replies:
    1
    Views:
    485
    Soren Kuula
    Feb 13, 2004
  5. jkflens
    Replies:
    2
    Views:
    1,450
    jkflens
    May 30, 2006
Loading...

Share This Page