user3629892
user3629892

Reputation: 3046

xslt to html: link and meta tag never closed

I am transforming XML to HTML with XSLT 2.0 and Saxon9he. The problem I am having is that the link and meta tags in the head are not closed in the output, causing an error when opening the files in Chrome.

In my stylesheet:

<xsl:result-document method="html" href="HTML/index.html" encoding="utf-8">
            <xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html&gt;</xsl:text>
            <html>
                <head>
                    <title>cat</title>
                    <link rel="stylesheet" type="text/css" href="styles.css"/>
                </head>
                <body>
...
</xsl:result-document>

But in the output:

   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
 <title>cat</title>   <link rel="stylesheet" type="text/css"
 href="styles.css">

Why aren't these tags closed?

Upvotes: 0

Views: 991

Answers (1)

dret
dret

Reputation: 549

by saying

<xsl:result-document method="html"

you are requesting for the result to be HTML, and not XML. if you want the output to be XML (or XHTML, as an XML-compliant variant of HTML), then you have to select output methods xml or xhtml. if you choose either of those, your output document will be well-formed XML.

Upvotes: 1

Related Questions