Search in sources :

Example 66 with XMLElement

use of net.n3.nanoxml.XMLElement in project jwt by emweb.

the class RenderUtils method parseXHTML.

// private static void printXmlTree(XMLElement e, int level) {
// for (Object o : e.getChildren()) {
// XMLElement c = ((XMLElement)o);
// for (int i = 0; i < level; ++i)
// System.err.print("\t");
// System.err.print(c.getName() + " : " + c.getContent());
// System.err.print("\n");
// 
// if (c.getChildren().size() > 0)
// printXmlTree(c, level + 1);
// }
// }
static XMLElement parseXHTML(String xhtml) {
    IXMLParser parser;
    try {
        xhtml = "<div>" + xhtml + "</div>";
        parser = XMLParserFactory.createDefaultXMLParser();
        IXMLReader reader = StdXMLReader.stringReader(xhtml);
        parser.setReader(reader);
        parser.setResolver(new XHtmlFilter(true));
        XMLElement xml = (XMLElement) parser.parse();
        extractTextNodes(xml);
        return xml;
    } catch (ClassNotFoundException e) {
        logger.info("Exception while parsing xhtml", e);
        logger.trace("xhtml was: {}", xhtml);
    } catch (InstantiationException e) {
        logger.info("Exception while parsing xhtml", e);
        logger.trace("xhtml was: {}", xhtml);
    } catch (IllegalAccessException e) {
        logger.info("Exception while parsing xhtml", e);
        logger.trace("xhtml was: {}", xhtml);
    } catch (XMLException e) {
        logger.info("Exception while parsing xhtml: {}", e.toString(), e);
        logger.trace("xhtml was: {}", xhtml);
    }
    return null;
}
Also used : XMLException(net.n3.nanoxml.XMLException) IXMLReader(net.n3.nanoxml.IXMLReader) IXMLParser(net.n3.nanoxml.IXMLParser) XMLElement(net.n3.nanoxml.XMLElement) IXMLElement(net.n3.nanoxml.IXMLElement) XHtmlFilter(eu.webtoolkit.jwt.XHtmlFilter)

Aggregations

XMLElement (org.freeplane.n3.nanoxml.XMLElement)63 IOException (java.io.IOException)8 IXMLParser (org.freeplane.n3.nanoxml.IXMLParser)6 IXMLReader (org.freeplane.n3.nanoxml.IXMLReader)6 StdXMLReader (org.freeplane.n3.nanoxml.StdXMLReader)6 ASelectableCondition (org.freeplane.features.filter.condition.ASelectableCondition)5 NodeModel (org.freeplane.features.map.NodeModel)5 BufferedInputStream (java.io.BufferedInputStream)4 File (java.io.File)4 FileInputStream (java.io.FileInputStream)4 XMLWriter (org.freeplane.n3.nanoxml.XMLWriter)4 Color (java.awt.Color)3 FileWriter (java.io.FileWriter)3 Writer (java.io.Writer)3 IXMLElement (net.n3.nanoxml.IXMLElement)3 XMLElement (net.n3.nanoxml.XMLElement)3 XMLException (org.freeplane.n3.nanoxml.XMLException)3 Point (java.awt.Point)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2