List of usage examples for org.dom4j DocumentHelper createDocument
public static Document createDocument()
From source file:eu.planets_project.pp.plato.action.ProjectExportAction.java
License:Open Source License
/** * Dumps binary data to provided file// w w w. j a v a 2 s . c o m * It results in an XML file with a single element: data, * @param id * @param data * @param f * @param encoder * @throws IOException */ private static void writeBinaryData(int id, ByteStream data, File f, BASE64Encoder encoder) throws IOException { Document streamDoc = DocumentHelper.createDocument(); Element d = streamDoc.addElement("data"); d.addAttribute("id", "" + id); d.setText(encoder.encode(data.getData())); XMLWriter writer = new XMLWriter(new BufferedWriter(new FileWriter(f)), ProjectExporter.prettyFormat); writer.write(streamDoc); writer.flush(); writer.close(); }
From source file:eu.planets_project.pp.plato.services.characterisation.xcl.Comparator.java
License:Open Source License
/** * Generates a PCR for all <param>mappedProperties</param> and their metrics. * Note: All possible metrics are included. * /*from w w w . j av a2 s. c om*/ * @param mappedProperties * @return */ private String generateConfig(Set<XCLObjectProperty> mappedProperties) { Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("pcRequest"); Namespace xsi = new Namespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); root.add(xsi); root.addAttribute(xsi.getPrefix() + ":schemaLocation", "http://www.planets-project.eu/xcl/schemas/xcl data/pp5/schemas/pcr/pcr.xsd"); Namespace xcl = new Namespace("", "http://www.planets-project.eu/xcl/schemas/xcl"); root.add(xcl); Element compSet = root.addElement("compSet", xcl.getURI()); compSet.addElement("source").addAttribute("name", "samplerecord"); compSet.addElement("target").addAttribute("name", "experimentresult"); /* Element root = doc.addElement("plans"); Namespace xsi = new Namespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); root.add(xsi); root.addAttribute(xsi.getPrefix()+":noNamespaceSchemaLocation", "http://www.ifs.tuwien.ac.at/dp/plato/schemas/plato-1.9.xsd"); */ for (XCLObjectProperty objectProperty : mappedProperties) { Element prop = compSet.addElement("property").addAttribute("id", objectProperty.getPropertyId()) .addAttribute("name", objectProperty.getName()); for (Metric metric : objectProperty.getMetrics()) { prop.addElement("metric").addAttribute("id", metric.getMetricId()).addAttribute("name", metric.getName()); } } return doc.asXML(); }
From source file:eu.planets_project.pp.plato.xml.LibraryExport.java
License:Open Source License
public Document exportToDocument(LibraryTree lib) { Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("library"); root.add(xsi);//from w w w . j a v a2 s. co m root.add(platoLibNS); // root.addAttribute(xsi.getPrefix()+":schemaLocation", "http://www.planets-project.eu/plato plato-2.1.xsd"); // root.addAttribute(xsi.getPrefix()+":noNamespaceSchemaLocation", "http://www.ifs.tuwien.ac.at/dp/plato/schemas/plato-2.1.xsd"); root.addAttribute("name", lib.getName()); Element rootReq = root.addElement(new QName("requirement", platoLibNS)); addRequirementProperties(rootReq, lib.getRoot()); return doc; }
From source file:eu.planets_project.pp.plato.xml.ProjectExporter.java
License:Open Source License
public Document createProjectDoc() { Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("plans"); root.add(xsi);//ww w . j av a 2 s.c o m root.add(platoNS); root.addAttribute(xsi.getPrefix() + ":schemaLocation", "http://www.planets-project.eu/plato plato-3.0.xsd"); root.add(excutablePlanNS); root.add(new Namespace("fits", "http://hul.harvard.edu/ois/xml/ns/fits/fits_output")); // set version of corresponding schema root.addAttribute("version", "3.0.0"); return doc; }
From source file:eu.planets_project.pp.plato.xml.ProjectExporter.java
License:Open Source License
public Document createTemplateDoc() { Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("templates"); root.add(xsi);/*from w ww .j ava 2s .co m*/ return doc; }
From source file:eu.planets_project.pp.plato.xml.ProjectExporter.java
License:Open Source License
public Document exportTemplates(List<TemplateTree> trees) { Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("templates"); for (TemplateTree template : trees) { addTemplateTree(template, root); }// w w w .j a va2s . c o m return doc; }
From source file:eu.planets_project.pp.plato.xml.ProjectExporter.java
License:Open Source License
public String exportTreeToFreemind(TreeNode treeRoot) { Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("map"); Namespace xsi = new Namespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); root.add(xsi);/*ww w . j av a 2 s . c o m*/ root.addAttribute("version", "0.8.1"); root.addComment( "To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net"); addSubTreeFreemind(root, treeRoot); String xml = doc.asXML(); //PlatoLogger.getLogger(ProjectExporter.class).debug(arg0) return xml; }
From source file:eu.scape_project.planning.criteria.bean.CriteriaHierarchyHelperBean.java
License:Apache License
/** * A function which exports all current criteria into a freemind xml string. * Used to ease creation of criteria-hierarchies (manual this is a hard * job).//w ww . j a v a 2 s .c om * * @return the criteria as XML string */ private String exportAllCriteriaToFreeMindXml() { Document doc = DocumentHelper.createDocument(); doc.setXMLEncoding("UTF-8"); Element root = doc.addElement("map"); Namespace xsi = new Namespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); root.add(xsi); root.addAttribute("version", "0.8.1"); root.addComment( "To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net"); Element baseNode = root.addElement("node"); baseNode.addAttribute("TEXT", "allCriteria"); Collection<Measure> allCriteria = criteriaManager.getAllMeasures(); ArrayList<Measure> allCriteriaSortable = new ArrayList<Measure>(allCriteria); Collections.sort(allCriteriaSortable); allCriteria = allCriteriaSortable; // each criterion should be added as simple node for (Measure measure : allCriteria) { // construct node text String nodeText = measure.getAttribute().getName() + "#" + measure.getName() + "|" + measure.getUri(); // add node Element node = baseNode.addElement("node"); node.addAttribute("TEXT", nodeText); } String xml = doc.asXML(); return xml; }
From source file:eu.scape_project.planning.criteria.xml.CriteriaHierarchyExporter.java
License:Apache License
/** * Method responsible for exporting a CriteriaHierarchy-TreeNode to freemind-xml format. * // ww w .j av a 2 s . c o m * @param criteriaTreeNode CriteriaHierarchy-Treenode to export * @return freemind-xml String. */ private String exportToFreemindXml(CriteriaTreeNode criteriaTreeNode) { Document doc = DocumentHelper.createDocument(); doc.setXMLEncoding("UTF-8"); Element root = doc.addElement("map"); Namespace xsi = new Namespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); root.add(xsi); root.addAttribute("version", "0.8.1"); root.addComment( "To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net"); addSubTreeFreemind(root, criteriaTreeNode); String xml = doc.asXML(); return xml; }
From source file:eu.scape_project.planning.xml.PreservationActionPlanGenerator.java
License:Apache License
/** * Creates a document for the preservation action plan. * /*from w w w . j a v a 2 s . c om*/ * @return the document */ private Document createPapDoc() { Document doc = DocumentHelper.createDocument(); Element root = doc.addElement(new QName("preservationActionPlan", platoNS)); root.add(xsi); root.add(platoNS); root.addAttribute(xsi.getPrefix() + ":schemaLocation", PlanXMLConstants.PLATO_NS + " " + PlanXMLConstants.PAP_SCHEMA); // Set version of corresponding schema root.addAttribute("version", "1.0"); return doc; }