On 30.03.2008 03:39, shai200 wrote:
I have a custom generator with a generate() method that looks like this:
public void generate() throws IOException, SAXException, ProcessingException
{
contentHandler.startDocument();
contentHandler.startElement("", "content", "content",
emptyAttr);
contentHandler.characters(xhtml_output.toCharArray(), 0,
xhtml_output.length());
contentHandler.endElement("","content","content");
contentHandler.endDocument();
}
where xhtml_output is some html code.
My sitemap entry looks like this:
<map:match pattern="xmlaction">
<map:generate type="skunk" />
<map:serialize type="xml"/>
</map:match>
The problem is that this returns HTML code with escaped characters ( i.e. &
lt; and & gt; instead of < and >, etc.)
You have to actually parse the XHTML, not pass its content as
characters. I came across a class today, StringXMLizable, that can help
you if you don't want to do the parsing yourself:
new StringXMLizable(xhtml_output).toSAX(contentHandler);
If you have a ServiceManager available (Serviceable) you can also do the
parsing yourself:
SAXParser parser = null;
try {
parser = (SAXParser) manager.lookup(SAXParser.ROLE);
InputSource is = new InputSource(new StringReader(xhtml_output));
parser.parse(is, contentHandler);
} finally {
manager.release(parser);
}
The second approach is definitely preferable, especially since
StringXMLizable has a questionable implementation [1] not using Cocoon's
infrastructure.
Joerg
[1] http://marc.info/?l=xml-cocoon-dev&m=120685987703854&w=4
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]