Re: [xsl] Open Meta Tag problem
Subject: Re: [xsl] Open Meta Tag problem|
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 20 May 2010 15:52:42 -0400
At 03:31 PM 5/20/2010, you wrote:
This seems like such an ancient topic, but here it goes...
I have the following:
<xsl:output indent="yes" doctype-public="-//W3C//DTD HTML 4.01//EN"
The resulting HTML document has a bad content-type meta tag:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
(It is not closed)
This is not "bad" unless by "bad" you mean "not XML". And HTML is not XML.
HTML -- more to the point, the variant of HTML your stylesheet
believes it should produce -- is an application of SGML, in which
this particular tag (and indeed, any other tags for elements declared
in its DTD as EMPTY, such as 'img' and 'br' and 'hr') need not be
matched with a corresponding close tag.
I've tried various doctypes and the results seem to be the same. How
do I solve this?
If you want XML syntax, you need to configure your XSLT processor to
give it to you.
This can generally be done quite easily:
<xsl:output indent="yes" method="xml"/>
Also, while on the subject, what doctype do you use, and why?
This very much depends on the local requirements.
If using the doctype that you have cited (PUBLIC -//W3C//DTD HTML
4.01//EN), however, I probably would *not* use method="xml", but
instead method="html" (which is what you are getting, probably
because your processor infers from the name of the document element
of your result, 'html', that this is what you want). This is because
the HTML 4.01 DTD is an SGML DTD not an XML DTD, and W3C-conformant
HTML 4.01 processors do not expect those particular tags to be closed.
If I knew, on the other hand, that I needed the output to be
well-formed XML, I would probably use method="xml" to ensure as much,
along with an XHTML doctype.
I hope this helps --
Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
Mulberry Technologies: A Consultancy Specializing in SGML and XML