List of usage examples for org.w3c.dom Element getOwnerDocument
public Document getOwnerDocument();
Document
object associated with this node. From source file:de.elatePortal.autotool.SubTasklet_AutotoolImpl.java
private void setText(Element memento, String nodeName, String text) { Element element = getElement(memento, nodeName); if (element == null) { element = memento.getOwnerDocument().createElement(nodeName); memento.appendChild(element);/*from www .j ava 2s . c o m*/ } element.setTextContent(text);//setTextContent() laesst sich mit maven nicht kompilieren??? dom3 nicht im classpath? }
From source file:edu.duke.cabig.c3pr.web.security.SecureWebServiceHandler.java
/** * @param msg/*from ww w . j a v a 2s . c om*/ * @param reason */ private void generateSecurityFault(Throwable ex) { Fault fault = new Fault(ex); fault.setMessage(ex.getMessage()); Element detail = fault.getOrCreateDetail(); final Element detailEntry = detail.getOwnerDocument().createElementNS(NS_COMMON, SecurityExceptionFault.class.getSimpleName()); detail.appendChild(detailEntry); final Element detailMsg = detail.getOwnerDocument().createElementNS(NS_COMMON, "message"); detailMsg.setTextContent(ex.getMessage()); detailEntry.appendChild(detailMsg); throw fault; }
From source file:marytts.unitselection.analysis.ProsodyAnalyzer.java
/** * For the first phone with a MaryXMLElement we encounter, return that Element's Document * //from w ww.ja va 2 s . c o m * @return the Document containing the {@link #phones} or null if no phone is able to provide a MaryXMLElement */ private Document getDocument() { for (Phone phone : phones) { Element phoneElement = phone.getMaryXMLElement(); if (phoneElement != null) { return phoneElement.getOwnerDocument(); } } return null; }
From source file:com.enonic.vertical.adminweb.AdminHandlerBaseServlet.java
public static final Document buildAccessRightsXML(Element rootElem, String key, ExtendedMap formItems, int accessrightsType) { // Handle this in calling methods instead //if (!formItems.containsKey("updateaccessrights")) // return null; Document doc;/* ww w. j ava 2 s. co m*/ Element elmAccessRights; if (rootElem != null) { doc = rootElem.getOwnerDocument(); elmAccessRights = XMLTool.createElement(doc, rootElem, "accessrights"); } else { doc = XMLTool.createDocument("accessrights"); elmAccessRights = doc.getDocumentElement(); } if (key != null) { elmAccessRights.setAttribute("key", key); } if (accessrightsType != Integer.MIN_VALUE) { elmAccessRights.setAttribute("type", String.valueOf(accessrightsType)); } for (Object parameterKey : formItems.keySet()) { String paramName = (String) parameterKey; if (paramName.startsWith("accessright[key=")) { String paramValue = formItems.getString(paramName); ExtendedMap paramsInName = ParamsInTextParser.parseParamsInText(paramName, "[", "]", ";"); ExtendedMap paramsInValue = ParamsInTextParser.parseParamsInText(paramValue, "[", "]", ";"); buildAccessRightElement(doc, elmAccessRights, paramsInName.getString("key"), paramsInValue); } } return doc; }
From source file:com.enonic.esl.xml.XMLTool.java
public static void mergeDocuments(Element destDocElem, Document srcDoc, boolean copyRoot) { if (copyRoot) { Element element = srcDoc.getDocumentElement(); destDocElem.appendChild(destDocElem.getOwnerDocument().importNode(element, true)); } else {/*from w ww . ja v a 2 s . c o m*/ NodeList nodes = srcDoc.getDocumentElement().getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { destDocElem.appendChild(destDocElem.getOwnerDocument().importNode(nodes.item(i), true)); } } }
From source file:com.evolveum.midpoint.util.DOMUtil.java
public static Element getOrCreateAsFirstElement(Element parentElement, QName elementQName) { Element element = getChildElement(parentElement, elementQName); if (element != null) { return element; }/*from www .ja va2 s. c o m*/ Document doc = parentElement.getOwnerDocument(); element = doc.createElementNS(elementQName.getNamespaceURI(), elementQName.getLocalPart()); parentElement.insertBefore(element, getFirstChildElement(parentElement)); return element; }
From source file:net.sourceforge.dita4publishers.impl.dita.InMemoryDitaKeySpace.java
protected void registerKeyDefinition(Element mapElement, Element keydefElem, String key) throws DitaApiException { DitaKeyDefinition keyDef = new DitaKeyDefinitionImpl(mapElement.getOwnerDocument(), key, keydefElem); List<DitaKeyDefinition> keyDefs = allKeyDefinitionsByKey.get(key); if (keyDefs == null) { keyDefs = new ArrayList<DitaKeyDefinition>(); allKeyDefinitionsByKey.put(key, keyDefs); }//from w w w . j av a 2 s .c o m keyDefs.add(keyDef); allKeyDefinitions.add(keyDef); }
From source file:Main.java
/** * For compatibility reasons the following is required: * If the value of a text node is to be changed, but a CDATA section with this name * already exists, the CDATA section is removed an a text node is created or changed. * * If the value of a CDATA section is to be changed, but a text node with this name * already exists, the text node is removed an a CDATA section is created or changed. * *///from w ww. j ava 2 s. com public static void setElementText(Element e, String newValue, boolean cdata) { if (e == null) { return; } Node node = null; NodeList children = e.getChildNodes(); if (children != null) { Node childToRemove = null; boolean changed = false; int listLength = children.getLength(); for (int i = 0; i < listLength; i++) { node = children.item(i); int nodeType = node.getNodeType(); if (nodeType == Node.TEXT_NODE) { if (cdata) { childToRemove = node; } else { node.setNodeValue(newValue); changed = true; } } if (nodeType == Node.CDATA_SECTION_NODE) { if (!cdata) { childToRemove = node; } else { node.setNodeValue(newValue); changed = true; } } } if (childToRemove != null) { // System.out.println("removing child " + childToRemove.getNodeValue()); childToRemove.setNodeValue(""); e.removeChild(childToRemove); } if (changed) { return; } } Document doc = e.getOwnerDocument(); if (cdata) { node = doc.createCDATASection(newValue); } else { node = doc.createTextNode(newValue); } e.appendChild(node); }
From source file:com.enonic.vertical.userservices.OrderHandlerController.java
@Override protected void buildContentTypeXML(UserServicesService userServices, Element contentdataElem, ExtendedMap formItems, boolean skipElements) throws VerticalUserServicesException { Document doc = contentdataElem.getOwnerDocument(); contentdataElem.setAttribute("version", "1.0"); // guid// w ww. j av a 2s . c o m XMLTool.createElement(doc, contentdataElem, "guid", formItems.getString("_guid")); // Status XMLTool.createElement(doc, contentdataElem, "status", "Submitted"); // Order reference if (formItems.containsKey("order_reference")) { String ref = (String) formItems.get("order_reference"); XMLTool.createElement(doc, contentdataElem, "orderreference", ref); } // Customer Element customer = XMLTool.createElement(doc, contentdataElem, "customer"); XMLTool.createElement(doc, customer, "firstname", formItems.getString("customer_firstname", "")); XMLTool.createElement(doc, customer, "surname", formItems.getString("customer_surname", "")); XMLTool.createElement(doc, customer, "company", formItems.getString("customer_company", "")); XMLTool.createElement(doc, customer, "email", formItems.getString("customer_email", "")); XMLTool.createElement(doc, customer, "telephone", formItems.getString("customer_telephone", "")); XMLTool.createElement(doc, customer, "mobile", formItems.getString("customer_mobile", "")); XMLTool.createElement(doc, customer, "fax", formItems.getString("customer_fax", "")); if (formItems.containsKey("customer_refno")) { String ref = (String) formItems.get("customer_refno"); customer.setAttribute("refno", ref); } // Customer - billing address Element billingaddress = XMLTool.createElement(doc, customer, "billingaddress"); XMLTool.createElement(doc, billingaddress, "postaladdress", formItems.getString("billing_postaladdress", "")); XMLTool.createElement(doc, billingaddress, "postalcode", formItems.getString("billing_postalcode", "")); XMLTool.createElement(doc, billingaddress, "location", formItems.getString("billing_location", "")); if (formItems.containsKey("billing_state")) { String state = (String) formItems.get("billing_state"); XMLTool.createElement(doc, billingaddress, "state", state); } XMLTool.createElement(doc, billingaddress, "country", formItems.getString("billing_country", "")); // Customer - shipping address Element shippingaddress = XMLTool.createElement(doc, customer, "shippingaddress"); XMLTool.createElement(doc, shippingaddress, "postaladdress", formItems.getString("shipping_postaladdress", "")); XMLTool.createElement(doc, shippingaddress, "postalcode", formItems.getString("shipping_postalcode", "")); XMLTool.createElement(doc, shippingaddress, "location", formItems.getString("shipping_location", "")); if (formItems.containsKey("shipping_state")) { String state = (String) formItems.get("shipping_state"); XMLTool.createElement(doc, shippingaddress, "state", state); } XMLTool.createElement(doc, shippingaddress, "country", formItems.getString("shipping_country", "")); // Details Element details = XMLTool.createElement(doc, contentdataElem, "details"); if (formItems.containsKey("details_comments")) { String comments = (String) formItems.get("details_comments"); XMLTool.createElement(doc, details, "comments", comments); } if (formItems.containsKey("details_shippingoptions")) { String shippingoptions = (String) formItems.get("details_shippingoptions"); XMLTool.createElement(doc, details, "shippingoptions", shippingoptions); } ShoppingCart cart = (ShoppingCart) formItems.get("_shoppingcart"); cart.toDoc(doc, contentdataElem, false); }
From source file:org.gvnix.dynamic.configuration.roo.addon.ConfigurationsImpl.java
/** * Add new component element containing id and name elements on * configuration.// w w w . ja v a 2 s .c o m * * @param conf Configuration where add component * @param id Component identificator * @param name Component name */ private Element addComponent(Element conf, String id, String name) { // Add new component element Document doc = conf.getOwnerDocument(); Element comp = doc.createElement(COMPONENT_ELEMENT_NAME); comp.setAttribute(ID_ATTRIBUTE_NAME, id); comp.setAttribute(NAME_ATTRIBUTE_NAME, name); conf.appendChild(comp); return comp; }