Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Problem converting XML to HTML using XSLT on Netscape 7.0

Reply
Thread Tools

Problem converting XML to HTML using XSLT on Netscape 7.0

 
 
nanookfan
Guest
Posts: n/a
 
      01-14-2004
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"
xmlnssl="http://www.w3.org/1999/XSL/Transform">

<xslutput 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
 
Reply With Quote
 
 
 
 
Johannes Koch
Guest
Posts: n/a
 
      01-14-2004
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.)

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      01-14-2004


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/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Html to xml to my custom xml with xslt ??!? asd Java 0 12-09-2006 07:50 PM
Problem to insert an XML-element by XSLT-converting from one XML-file into another XML-file jkflens XML 2 05-30-2006 09:41 AM
Apache Project Xalan XML/XSLT Processor Is Good, But Its ExtensionNot Work on Netscape/IE RC Java 6 04-22-2005 02:31 PM
Problem converting XML with XSLT to another XML H. Kaya XML 1 02-13-2004 10:16 AM
Using One XSLT and multiple XML Problem (One is XML and another one is XBRL) loveNUNO XML 2 11-20-2003 06:47 AM



Advertisments