xsl:output and DOCTYPE declaration

Having trouble installing Oxygen? Got a bug to report? Post it all here.
marty

xsl:output and DOCTYPE declaration

Post by marty »

Please tell me if this has already been answered - i have been trying to figure this out for days, and i have look through the forum briefly but not spotted what i need.

I wish to output (valid) xhtml

in my xsl stylesheet i have an xsl:output statement like this:

<xsl:output encoding="iso-8859-1" method="xhtml" indent="yes" doctype-public="-//W3C//DTD XHTML 1.1//EN"
/>

oxygen gives the following output instead above my <html> element:

<?xml version="1.0" encoding="iso-8859-1"?>

obviously, this doesn't make for valid xhtml


### so the question is: is this a problem with oxygen or me?

any advice greatly appreciated

regards

Marty[/b]
martinrowland
Posts: 1
Joined: Tue Sep 30, 2003 8:37 am

xsl:output to xhtml solution

Post by martinrowland »

that was me before. i have a solution - seems the problem was me!

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">

<xsl:output
omit-xml-declaration="no" method="xml"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system=
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
indent="no" encoding="iso-8859-1"/>

<xsl:template match="/webpage">
<html xml:lang="en" >
<xsl:apply-templates/>
</html>
</xsl:template>
.
.
.
while produce

Code: Select all


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
.
.
.
and the good news (for me at least) is that it all validates against
http://validator.w3.org/

but if anyone has a better way to do this, by all means let me know

cheers

marty
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi Martin,

I was about to reply on your first post, so here it is:
Doctype declarations need also a system ID when you specify a public ID, therefore you will need to specify both doctype-public and doctype-system attributes in your xsl:output element.

See:
http://www.w3.org/TR/REC-xml#sec-external-ent
[75] ExternalID ::= 'SYSTEM' S SystemLiteral
| 'PUBLIC' S PubidLiteral S SystemLiteral
Also use method="xml" as both Xalan and Saxon that are integrated with oXygen do not know xhtml as output method.

Best Regards,
George
Post Reply