On Tue, 2004-11-23 at 15:09 +0100, [EMAIL PROTECTED] wrote:
> Derek,
>
> I'm currently working on updating the HTMLarea sample to
> 1. work in tables in IE6
> 2. use Bruno's HtmlCleanerConvertor
> 3. output html-ized data, rather than raw (i.e. as string)
>
> for 3. I currently use a simple XSL stylesheet that matches <htmlarea> tags
> and displays them with disable-output-escaping="yes". If anyone can come up
> with a better solution or modifies Ugo's HTMLparser, please do so.
Again and again, if you have XML as a string and want to push it over
the pipeline, and have it recognized as 'XML' (SAX events), you need to
parse it, using an XML parser. Using disable-output-escaping is a trick
of which I'm very suprised it even works inside Cocoon, and certainly
wouldn't like to see used in the Cocoon samples.
There are various solutions:
* parse the XML in the flowscript and pass the result as a DOM or a
SaxBuffer to the view
* embed (x/c)include statements in the template that address the
to-be-embedded XML using the module source
* or use a class like the StringXMLizable attached with this message,
and use it like this in the template:
#{mypackage.StringXMLizable.new(/myobject/mystring)}
this essentially wraps a string (here addressed as /myobject/mystring)
and turns it into an XMLizable object. This of course supposes that the
string contains well-formed XML.
--
Bruno Dumon http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
[EMAIL PROTECTED] [EMAIL PROTECTED]
package mypackage;
import org.apache.excalibur.xml.sax.XMLizable;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.InputSource;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.io.StringReader;
public class StringXMLizable implements XMLizable {
private String data;
public StringXMLizable(String data) {
this.data = data;
}
public void toSAX(ContentHandler contentHandler) throws SAXException {
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
parserFactory.setNamespaceAware(true);
SAXParser parser = null;
try {
parser = parserFactory.newSAXParser();
} catch (ParserConfigurationException e) {
throw new SAXException("Error creating SAX parser.", e);
}
parser.getXMLReader().setContentHandler(contentHandler);
InputSource is = new InputSource(new StringReader(data));
try {
parser.getXMLReader().parse(is);
} catch (IOException e) {
throw new SAXException(e);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]