use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class TreeXmlReader method elementAttributesProcessed.
/*
* (non-Javadoc)
* @see
* freeplane.persistence.xml.n3.nanoxml.IXMLBuilder#elementAttributesProcessed
* (java.lang.String, java.lang.String, java.lang.String)
*/
public void elementAttributesProcessed(final String name, final String nsPrefix, final String nsURI) throws Exception {
xmlBuilder.elementAttributesProcessed(name, nsPrefix, nsURI);
if (saveAsXmlUntil != null || nodeCreator != null) {
return;
}
final Iterator<IElementHandler> iterator = getElementHandlers().iterator(tag);
final XMLElement lastBuiltElement = xmlBuilder.getLastBuiltElement();
while (iterator.hasNext() && currentElement == null) {
nodeCreator = iterator.next();
try {
currentElement = nodeCreator.createElement(parentElement, name, lastBuiltElement);
} catch (Exception e) {
LogUtils.severe("Can not process element" + name, e);
}
}
if (currentElement != null) {
if (nodeCreator instanceof IElementContentHandler) {
parser.notParseNextElementContent();
}
attributeHandlersForTag = getAttributeLoaders().get(tag);
if (attributeHandlersForTag == null) {
return;
}
final Enumeration<String> attributeNames = lastBuiltElement.enumerateAttributeNames();
while (attributeNames.hasMoreElements()) {
final String atName = (String) attributeNames.nextElement();
if (addAttribute(atName, lastBuiltElement.getAttribute(atName, null))) {
lastBuiltElement.removeAttribute(atName);
}
}
} else {
currentElement = null;
nodeCreator = null;
saveAsXmlUntil = lastBuiltElement;
}
}
use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class TreeXmlWriter method addElement.
public void addElement(final Object userObject, final String name) throws IOException {
final XMLElement element = new XMLElement(name);
addElement(userObject, element);
}
use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class FilterController method loadConditions.
void loadConditions(final DefaultComboBoxModel filterConditionModel, final String pathToFilterFile, final boolean showPopupOnError) throws IOException {
try {
final IXMLParser parser = XMLLocalParserFactory.createLocalXMLParser();
File filterFile = new File(pathToFilterFile);
final IXMLReader reader = new StdXMLReader(new BufferedInputStream(new FileInputStream(filterFile)));
parser.setReader(reader);
reader.setSystemID(filterFile.toURL().toString());
final XMLElement loader = (XMLElement) parser.parse();
final Vector<XMLElement> conditions = loader.getChildren();
for (int i = 0; i < conditions.size(); i++) {
final ASelectableCondition condition = getConditionFactory().loadCondition(conditions.get(i));
if (condition != null) {
filterConditionModel.addElement(condition);
}
}
} catch (final FileNotFoundException e) {
} catch (final AccessControlException e) {
} catch (final Exception e) {
LogUtils.warn(e);
if (showPopupOnError) {
UITools.errorMessage(TextUtils.getText("filters_not_loaded"));
}
}
}
use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class ExportController method createXSLTExportActions.
private void createXSLTExportActions(final String xmlDescriptorFile) {
InputStream xmlDescriptorStream = null;
try {
final IXMLParser parser = XMLLocalParserFactory.createLocalXMLParser();
final URL resource = ResourceController.getResourceController().getResource(xmlDescriptorFile);
xmlDescriptorStream = resource.openStream();
final IXMLReader reader = new StdXMLReader(xmlDescriptorStream);
parser.setReader(reader);
final XMLElement xml = (XMLElement) parser.parse();
final Enumeration<XMLElement> actionDescriptors = xml.enumerateChildren();
while (actionDescriptors.hasMoreElements()) {
final XMLElement descriptor = actionDescriptors.nextElement();
final String name = descriptor.getAttribute("name", null);
final XMLElement xmlProperties = descriptor.getFirstChildNamed("properties");
final Properties properties = xmlProperties.getAttributes();
final ExportWithXSLT action = new ExportWithXSLT(name, properties);
addExportEngine(action.getFileFilter(), action);
}
} catch (final Exception e) {
LogUtils.severe(e);
} finally {
FileUtils.silentlyClose(xmlDescriptorStream);
}
}
use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class MapStyle method saveConditionalStyles.
private void saveConditionalStyles(ConditionalStyleModel conditionalStyleModel, XMLElement parent, boolean createRoot) {
final int styleCount = conditionalStyleModel.getStyleCount();
if (styleCount == 0) {
return;
}
final XMLElement conditionalStylesRoot;
if (createRoot) {
conditionalStylesRoot = parent.createElement("conditional_styles");
parent.addChild(conditionalStylesRoot);
} else
conditionalStylesRoot = parent;
for (final Item item : conditionalStyleModel) {
item.toXml(conditionalStylesRoot);
}
}
Aggregations