Re: [xsl] Hello World

Subject: Re: [xsl] Hello World
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Wed, 19 Jun 2002 18:58:25 +0200
Hello Ingo,

I don't want to post another shortest stylesheet. I want to give you some hints with mozilla:

XML:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<test>test works</test>

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


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

</xsl:stylesheet>

The above stylesheet works at least in the Mozilla windows version 1.0. I don't know why it shouldn't work on a Mac. With the stylesheet Jim sent you will have problems with mozilla. You are not creating a root element. So Mozilla does not react on this stylesheet - it seems to be a bug. But what's worse: If you change it to a stylesheet which produces valid xml output, Mozilla crashes - at least on my system.

So the first point is to add a <test> like in the above example.

A first stylesheet producing While IE thinks every output is HTML, you get nice looking output quite easy. But in my eyes IE should not think to much and therefore allow more than only HTML. Mozilla explicitely needs to be switched to HTML-output. You can reach this by adding a <xsl:output method="html"/>.html can look like this:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html"/>


<xsl:template match="test">
  <html>
    <head><title>test</title></head>
    <body><h1><xsl:value-of select="."/></h1></body>
  </html>
</xsl:template>

</xsl:stylesheet>

This works on my system too. Have a test with thos two stylesheets. It should work.

Joerg

xml file
<?xml version="1.0"?>
<test>test worked</test>

xslt file
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 <xsl:template match="/"><xsl:value-of select="test"/></xsl:template>
</xsl:stylesheet>

cheers, jim fuller


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread