List of usage examples for org.dom4j Element add
void add(Namespace namespace);
Namespace
to this element. From source file:fr.gouv.culture.vitam.utils.XmlDom.java
License:Open Source License
public final static Element initializeCheck(VitamArgument argument, VitamResult result, File current_file) { Element root = null; AllTestsItems[] allTestsItems = AllTestsItems.values(); result.labels = new String[allTestsItems.length]; result.values = new int[allTestsItems.length]; for (int i = 0; i < allTestsItems.length; i++) { result.labels[i] = allTestsItems[i].name(); }/*from ww w. jav a 2 s . c o m*/ switch (argument.outputModel) { case TXT: System.out.println("XMLFILE: file = " + current_file.getAbsolutePath() + "\n"); break; case MultipleXML: result.multiples = new ArrayList<Document>(); case OneXML: root = factory.createElement("vitam"); result.unique = factory.createDocument(root); Element element = factory.createElement("xmlfile"); element.addAttribute("file", current_file.getAbsolutePath()); root.add(element); break; } return root; }
From source file:fr.gouv.culture.vitam.utils.XmlDom.java
License:Open Source License
/** * //from ww w. java2 s. c om * @param source * what we are going to add * @param target * where we are going to add */ public static void checkPresence(Element source, Element target) { if (target.selectSingleNode("./" + source.getName()) != null) { // node already there so checking sub node if any @SuppressWarnings("unchecked") List<Element> listElements = source.elements(); @SuppressWarnings("unchecked") List<Attribute> listAttributes = source.attributes(); Element newSource = (Element) target.selectSingleNode("./" + source.getName()); if (newSource != null) { for (Attribute attribute : listAttributes) { checkPresence(attribute, newSource); } for (Element element : listElements) { checkPresence(element, newSource); } } } else { source.detach(); target.add(source); } }
From source file:fr.gouv.culture.vitam.utils.XmlDom.java
License:Open Source License
/** * /*from w w w .ja v a2 s . c o m*/ * @param source * what we are going to add * @param target * where we are going to add */ public static void checkPresence(Attribute source, Element target) { if (target.selectSingleNode("./@" + source.getName()) != null) { // not ignoring this attribute source.detach(); target.add(source); } }
From source file:fr.gouv.culture.vitam.writer.XmlWriter.java
License:Open Source License
public static void loadDbTableDataFromFile(DbSchema schema, DbTable table, Element etable) throws WaarpDatabaseSqlException, IOException { int read = 0; VitamReader reader = schema.identifier.getReader(); Element erows = DocumentFactory.getInstance().createElement("rows"); switch (table.type) { case CSVTYPE: { String[] values = null;//from ww w. j av a2 s. c om // first row to ignore if (reader.readOneLine() != null) { int warning = 0; while ((values = reader.readOneLine()) != null) { read++; if (values.length != table.nbFields()) { logger.warn("Attention: nombre de champs insuffisant en ligne: " + (read + 1)); warning++; } addOneTableRow(table, values, read, 0, erows); } if (warning > 0) { logger.warn("Enregistrements lus: " + read + " Mal forms (CSV): " + warning); } } } break; case MULTIPLETYPE: { String[] values = null; while ((values = reader.readOneLine(table.rank)) != null) { read++; addOneTableRow(table, values, read, 1, erows); } } break; case UNIQUETYPE: { String[] values = null; while ((values = reader.readOneLine()) != null) { read++; addOneTableRow(table, values, read, 0, erows); } } break; } etable.add(erows); System.out.println("Enregistrements lues: " + read); }
From source file:fr.gouv.culture.vitam.writer.XmlWriter.java
License:Open Source License
protected static void addOneTableRow(DbTable table, String[] values, int rank, int startCol, Element erows) throws WaarpDatabaseSqlException { DbTableRow row = new DbTableRow(table, rank); for (int j = startCol; j < values.length; j++) { DbFieldValue value = new DbFieldValue(table.getField(j - startCol), values[j]); row.addValue(value);/* w ww. j ava 2s .c om*/ } Element erow = row.getElement(); erows.add(erow); }
From source file:fr.gouv.vitam.xml.XmlDom4jTools.java
License:Open Source License
public final static Element fillInformation(Element parent, String name, String attribut, String info) { Element element = null;/*www . j av a 2 s . co m*/ element = factory.createElement(name); element.addAttribute(attribut, info); parent.add(element); return element; }
From source file:fr.gouv.vitam.xml.XmlDom4jTools.java
License:Open Source License
public final static void addElement(XMLWriter writer, Element parent, Element sub) { if (sub != null) { parent.add(sub); }/*from w ww .jav a 2 s. c o m*/ }
From source file:fr.gouv.vitam.xml.XmlDom4jTools.java
License:Open Source License
public final static Element initializeCheck(VitamArgument argument, File current_file) { Element root = null; root = factory.createElement("vitam"); argument.setXmlInDom4J(factory.createDocument(root)); Element element = factory.createElement("xmlfile"); element.addAttribute("file", current_file.getAbsolutePath()); root.add(element); return root;//from w w w. j a va 2 s . co m }
From source file:fr.gouv.vitam.xml.XmlDom4jTools.java
License:Open Source License
/** * //from ww w . ja va2 s . co m * @param source * what we are going to add * @param target * where we are going to add */ public static final void checkPresence(Element source, Element target) { if (target.selectSingleNode("./" + source.getName()) != null) { // node already there so checking sub node if any @SuppressWarnings("unchecked") List<Element> listElements = source.elements(); @SuppressWarnings("unchecked") List<Attribute> listAttributes = source.attributes(); Element newSource = (Element) target.selectSingleNode("./" + source.getName()); if (newSource != null) { for (Attribute attribute : listAttributes) { checkPresence(attribute, newSource); } for (Element element : listElements) { checkPresence(element, newSource); } } } else { source.detach(); target.add(source); } }
From source file:fr.gouv.vitam.xml.XmlDom4jTools.java
License:Open Source License
/** * //from w w w. ja v a 2 s . co m * @param source * what we are going to add * @param target * where we are going to add */ public static final void checkPresence(Attribute source, Element target) { if (target.selectSingleNode("./@" + source.getName()) != null) { // not ignoring this attribute source.detach(); target.add(source); } }