Page 1 of 1

Using xsl Stylesheet - html view

Posted: Fri Nov 14, 2003 1:44 pm
by Marc
Hi @ all,

I still have a big problem. I want to use a stylesheet to view my xml in html. My xsl looks like that:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title> My Database </title>
</head>
<body>
<h2>
<xsl:value-of select="database/Patient/Name"/>
</h2>
<h1> My Database </h1>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

The following line is not working:
<xsl:value-of select="database/Patient/Name"/>
The html-doc does not show the "name", why?!?

My xsd looks like that:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:element name="database">
<xs:complexType>
<xs:sequence>
<xs:element name="Patient">
<xs:complexType>
<xs:sequence>
<xs:element name="Name">
<xs:simpleType>
...
Do you have an indea?
Thank you very much for help!
Marc

Posted: Fri Nov 14, 2003 6:31 pm
by george
Hi Marc,

Please note that the view embedded in oXygen is for XHTML and not for HTML therefore if you want to use that you might consider setting the output method to XML:

Code: Select all


<?xml version="1.0" encoding="ISO-8859-1" ?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/">
<html>
<head>
<title> My Database </title>
</head>
<body>
<h2>
<xsl:value-of select="database/Patient/Name"/>
</h2>
<h1> My Database </h1>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Applying this stylesheet on

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<database>
<Patient>
<Name>person</Name>
</Patient>
</database>
gives the expected result:

<?xml version="1.0" encoding="UTF-8"?>
<html><head><title> My Database </title></head><body><h2>person</h2><h1> My Database </h1></body></html>

If you still have problems then I guess the problem is your input document. In this case please post a cut down sample of that document to allow us to reproduce the problem.

Best Regards,
George