cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Pietschmann <>
Subject Re: Problems removing meta tag from the html output in Cocoon
Date Wed, 01 Jan 2003 15:23:37 GMT
On Wednesday 01 January 2003 09:19, you wrote:
> I have a small xsl stylesheet that takes in xml and outputs html.
> Since the output method is html, xsl puts in the output the following meta
> tag: <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
> thus making the whole output file invalid xml!

No surprise: if you serialize stuff as HTML, you can't expect it to be
valid XML in general. This is not restricted to the <meta > element,
there's also <br>, <hr>, <input> and such. See below.

> I want to remove this line from the output.
> I found a saxon extension thing that does it, if put into the xsl:output
> element: <xsl:output method="html" indent="yes" saxon:omit-meta-tag="yes"
> />
> Now here is my problem:
> If I execute this xsl through the batch file using saxon, everything is
> fine, the meta tag is absent. But when I try to use it through Cocoon, the
> meta tag is still there.

You fell to one of the more common confusions among newbies.
XSLT defines several aspects:
- a transformation from a source tree to a result tree
- some controls about the serialized output, *if* the output is serialized
  by the processor  controlled by this style sheet.
If you read the XSLT spec carefully, you'll see that xsl:output and
disable-output-escaping are explicitely marked as optional and dependent
on the serialization step. You'll have to keep the distinction between the
tree-to-tree transformation and the serialization always in mind. A
transformation *doesn't* write "tags" to the output like e.g. JSPs do.

In a Cocoon pipeline, the XSL transformation and the serialization of the
result tree to the byte stream the client recieves are performed by different
components (look into your sitemap). This means xsl:output and any
extensions influencing the serialized result don't have any effect.

Your problem can almost be solved by serializing as XML instead of HTML,
the only problems being some odd characters in <a href...> URLs and for
example that <br> is usually serialized as <br/> which older browsers don't
understand properly. There are workarounds, look into the Cocoon FAQ or
the XSL FAQ reachable from

BTW you probably *want* to keep the META element, otherwise using an
UTF-8 encoding has potential to confuse quite a few browsers, in particular
IEx including IEx 6 (as usual :-/).

As a side point, both the XML and HTML serializer are implemented as an
identity XSL transformer. Now Saxon has an XHTML output method, which
does not have the problems mentioned above. It would be interesting to 
leverage this to provide a proper XHTML serializer. I vaguely remember Xalan
has a similar feature. Can someone of the Cocoon devs comment on this?


Please check that your question  has not already been answered in the
FAQ before posting.     <>

To unsubscribe, e-mail:     <>
For additional commands, e-mail:   <>

View raw message