use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class NodeWriter method writeAttributesGenerateContent.
private void writeAttributesGenerateContent(final ITreeWriter writer, final NodeModel node) {
/**
* fc, 12.6.2005: XML must not contain any zero characters.
*/
xmlNode = new XMLElement();
EncryptionModel encryptionModel = EncryptionModel.getModel(node);
mayWriteChildren = true;
final Object mode = mode(writer);
final boolean isNodeAlreadyWritten = isAlreadyWritten(node);
if (encryptionModel != null && !(encryptionModel.isAccessible() && Mode.EXPORT.equals(mode)) && !isNodeAlreadyWritten) {
final String enctyptedContent = encryptionModel.calculateEncryptedContent(mapController);
if (enctyptedContent != null) {
writer.addAttribute(NodeBuilder.XML_NODE_ENCRYPTED_CONTENT, enctyptedContent);
mayWriteChildren = false;
}
}
if (mayWriteChildren && (writeFolded || !mode(writer).equals(Mode.FILE))) {
if (mapController.isFolded(node) && !isNodeAlreadyWritten) {
writer.addAttribute("FOLDED", "true");
} else if (node.isRoot() && !Mode.STYLE.equals(mode)) {
writer.addAttribute("FOLDED", "false");
}
}
final NodeModel parentNode = node.getParentNode();
if (parentNode != null && parentNode.isRoot()) {
writer.addAttribute("POSITION", node.isLeft() ? "left" : "right");
}
final boolean saveID = !mode.equals(Mode.STYLE);
if (saveID) {
final String id = node.createID();
writer.addAttribute("ID", id);
writeReferenceNodeId(writer, node);
}
if (!isNodeAlreadyWritten) {
if (!mode.equals(Mode.STYLE) && node.getHistoryInformation() != null && ResourceController.getResourceController().getBooleanProperty(NodeBuilder.RESOURCES_SAVE_MODIFICATION_TIMES)) {
writer.addAttribute(NodeBuilder.XML_NODE_HISTORY_CREATED_AT, TreeXmlWriter.dateToString(node.getHistoryInformation().getCreatedAt()));
writer.addAttribute(NodeBuilder.XML_NODE_HISTORY_LAST_MODIFIED_AT, TreeXmlWriter.dateToString(node.getHistoryInformation().getLastModifiedAt()));
}
}
if (!isNodeAlreadyWritten || Mode.EXPORT.equals(mode)) {
writeIconSize(writer, node);
linkBuilder.writeAttributes(writer, node);
writer.addExtensionAttributes(node, node.getSharedExtensions().values());
}
writer.addExtensionAttributes(node, node.getIndividualExtensionValues());
}
use of org.freeplane.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;
}
Aggregations