use of org.freeplane.n3.nanoxml.StdXMLReader in project jwt by emweb.
the class WXmlLocalizedStrings method readXmlResource.
private void readXmlResource(String bundleName) {
WApplication app = WApplication.getInstance();
InputStream stream = null;
for (String path : StringUtils.expandLocales(bundleName, app.getLocale().toString())) {
try {
stream = FileUtils.getResourceAsStream(path + ".xml");
} catch (IOException e) {
}
if (stream != null)
break;
}
if (stream == null) {
logger.warn("Could not find resource \"" + bundleName + "\"");
return;
}
try {
XmlMessageParser xmlParser = new XmlMessageParser();
IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
parser.setBuilder(xmlParser);
parser.setResolver(xmlParser);
IXMLReader reader = new StdXMLReader(stream);
parser.setReader(reader);
parser.parse();
keyValues.putAll(xmlParser.getKeyValues());
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (XMLException e) {
e.printStackTrace();
}
}
use of org.freeplane.n3.nanoxml.StdXMLReader in project freeplane by freeplane.
the class TreeXmlReader method load.
/*
* (non-Javadoc)
* @see freeplane.persistence.Reader#load()
*/
public void load(final Reader reader) throws XMLException {
parser = new XMLParser();
final IXMLReader nanoxmlReader = new StdXMLReader(reader);
parser.setReader(nanoxmlReader);
parser.setBuilder(this);
parser.setValidator(new NonValidator());
parser.parse();
}
use of org.freeplane.n3.nanoxml.StdXMLReader 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 = XMLParserFactory.createDefaultXMLParser();
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.StdXMLReader in project freeplane by freeplane.
the class ExportController method createXSLTExportActions.
private void createXSLTExportActions(final String xmlDescriptorFile) {
InputStream xmlDescriptorStream = null;
try {
final IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
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.StdXMLReader in project freeplane by freeplane.
the class ScriptingRegistration method registerScriptAddOns.
private void registerScriptAddOns() {
File[] addonXmlFiles = AddOnsController.getController().getAddOnsDir().listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".script.xml");
}
});
final IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
for (File file : addonXmlFiles) {
BufferedInputStream inputStream = null;
try {
inputStream = new BufferedInputStream(new FileInputStream(file));
final IXMLReader reader = new StdXMLReader(inputStream);
parser.setReader(reader);
final ScriptAddOnProperties addOn = new ScriptAddOnProperties((XMLElement) parser.parse());
addOn.setAddOnPropertiesFile(file);
AddOnsController.getController().registerInstalledAddOn(addOn);
} catch (final Exception e) {
LogUtils.warn("error parsing " + file, e);
} finally {
FileUtils.silentlyClose(inputStream);
}
}
}
Aggregations