You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Sc...@lotus.com on 2000/03/18 00:28:42 UTC
Re: change the !DOCUMENT type/mime type
You shouldn't normally get the DOCTYPE decl unless you specify it via
xsl:output doctype-public & doctype-system in normal xsl processing.
However...
...I see in the Cocoon code, in HTMLFormatter.java, they are doing:
public void format(Document document, Writer writer, Dictionary p)
throws Exception {
OutputFormat format = super.getFormat(p);
format.setMethod(Method.HTML);
format.setOmitXMLDeclaration(true);
format.setPreserveSpace(true);
format.setDoctype("-//W3C//DTD HTML 4.0//EN",
"http://www.w3.org/TR/REC-html40/strict.dtd");
format.setVersion("4.0");
Serializer serializer = factory.makeSerializer(writer, format);
serializer.asDOMSerializer().serialize(document);
}
In Cocoon 1.7.x the xsl:output information is not being passed to the
formatter, so you can't really control this. Perhaps someone on the Cocoon
list could give you some suggestions?
BTW, Cocoon people, you can get the proper OutputFormat object from Xalan's
StylesheetRoot by calling it's getOutputFormat() method. In
XalanTransformer.java you could supply:
/**
* Get the output properties for the given stylesheet.
*/
OutputFormat getOutputFormat(Document sheet, String sheetBase)
{
XSLTInputSource s = new XSLTInputSource(sheet);
s.setSystemId(sheetBase);
StylesheetRoot stylesheet = processor.processStylesheet(s);
outputFormat = stylesheet.getOutputFormat();
return stylesheet.getOutputFormat();
}
Which would be kind of slow since you don't have a stylesheet pool, but
then you need to get the information from the transformer to the formatter.
This is probably a moot point for Cocoon 1.7.x since I don't think Stefano
wants to be adding features, but Pier should probably take note, if he
doesn't do this already.
> also can i explicitly
> specify the mime type as well?
Again, you can from XSLT, but the information won't get to the
Formatter/Serializer.
Someone from the Cocoon list should be better able to help you accomplish
what you need to do. I don't think this is an XSLT/Xalan issue.
-scott
"K. Rumman
Akhter" To: "Xalan" <xa...@xml.apache.org>
<kakhter@sput cc: (bcc: Scott Boag/CAM/Lotus)
nik7.com> Subject: change the !DOCUMENT type/mime type
03/17/00
05:53 PM
Please
respond to
xalan-dev
an xslt transformation always yields the line:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
in the resulting xml doc. however i am trying to user cocoon to dynamically
generate *.smi files (which are welformed xml) and i do not want that line
in the xalan output. is there anyway to change that. also can i explicitly
specify the mime type as well?
as usual, any suggestion will be helpful.
thanx
***
K h o n d k e r RUmman A k h t e r
Programmer
sputnik7.com
kakhter@sputnik7.com
Re: change the !DOCUMENT type/mime type
Posted by Stefano Mazzocchi <st...@apache.org>.
Scott_Boag@lotus.com wrote:
>
> You shouldn't normally get the DOCTYPE decl unless you specify it via
> xsl:output doctype-public & doctype-system in normal xsl processing.
> However...
>
> ...I see in the Cocoon code, in HTMLFormatter.java, they are doing:
>
> public void format(Document document, Writer writer, Dictionary p)
> throws Exception {
> OutputFormat format = super.getFormat(p);
> format.setMethod(Method.HTML);
> format.setOmitXMLDeclaration(true);
> format.setPreserveSpace(true);
> format.setDoctype("-//W3C//DTD HTML 4.0//EN",
> "http://www.w3.org/TR/REC-html40/strict.dtd");
> format.setVersion("4.0");
> Serializer serializer = factory.makeSerializer(writer, format);
> serializer.asDOMSerializer().serialize(document);
> }
>
> In Cocoon 1.7.x the xsl:output information is not being passed to the
> formatter, so you can't really control this. Perhaps someone on the Cocoon
> list could give you some suggestions?
>
> BTW, Cocoon people, you can get the proper OutputFormat object from Xalan's
> StylesheetRoot by calling it's getOutputFormat() method. In
> XalanTransformer.java you could supply:
>
> /**
> * Get the output properties for the given stylesheet.
> */
> OutputFormat getOutputFormat(Document sheet, String sheetBase)
> {
> XSLTInputSource s = new XSLTInputSource(sheet);
> s.setSystemId(sheetBase);
> StylesheetRoot stylesheet = processor.processStylesheet(s);
> outputFormat = stylesheet.getOutputFormat();
> return stylesheet.getOutputFormat();
> }
>
> Which would be kind of slow since you don't have a stylesheet pool, but
> then you need to get the information from the transformer to the formatter.
> This is probably a moot point for Cocoon 1.7.x since I don't think Stefano
> wants to be adding features, but Pier should probably take note, if he
> doesn't do this already.
We may or may not add support for xsl:output... but if present, the XSLT
processor cannot be considered a filter anymore, but a serializer. So,
we'll have both the XSLTFilter and XSLTSerializer.
Why? think about it: you can't futher process your pipeline after you
output text out of xslt transformations, don't you think?
Anyway, I see no problems in the Cocoon2 architecture for adding it.
> > also can i explicitly
> > specify the mime type as well?
>
> Again, you can from XSLT, but the information won't get to the
> Formatter/Serializer.
>
> Someone from the Cocoon list should be better able to help you accomplish
> what you need to do. I don't think this is an XSLT/Xalan issue.
No, it's not. We currently don't have a way to match xsl:output
capabilities because of architectural problems. For now, you can patch
the cocoon formatters to achieve what you want to do (the code is _very_
easy).
Look, we know this is a problem and we already have solutions... just
wait more time for them to stabilize.
--
Stefano Mazzocchi One must still have chaos in oneself to be
able to give birth to a dancing star.
<st...@apache.org> Friedrich Nietzsche
--------------------------------------------------------------------
Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------