List of usage examples for org.w3c.dom Element getOwnerDocument
public Document getOwnerDocument();
Document
object associated with this node. From source file:org.eclipse.smila.datamodel.xml.DOMRecordWriter.java
/** * Append a Record element describing the given record to the given parent element. The record element is appended as * a new last child to the parent element. * /*from w ww . java 2 s . co m*/ * @param parent * the parent element to append to. * @param record * the record to transform. * * @return the appended element */ public Element appendRecord(final Element parent, final Record record) { final Document factory = parent.getOwnerDocument(); newline(factory, parent); final Element recordElement = buildRecord(factory, record); recordElement.setAttribute(XmlConstants.ATTRIBUTE_XMLNSREC, XmlConstants.NAMESPACE_RECORD); parent.appendChild(recordElement); newline(factory, parent); return recordElement; }
From source file:org.eclipse.smila.datamodel.xml.DOMRecordWriter.java
/** * Append a RecordList element describing the given record list to the given parent element. The record list element * is appended as a new last child to the parent element. * //from w ww . j a v a 2s. c o m * @param parent * the parent element to append to. * @param records * the record list to transform. * * @return the appended element */ public Element appendRecordList(final Element parent, final Iterable<Record> records) { final Document factory = parent.getOwnerDocument(); newline(factory, parent); final Element recordListElement = appendElement(factory, parent, XmlConstants.TAG_RECORDLIST); for (final Record record : records) { final Element recordElement = buildRecord(factory, record); recordListElement.appendChild(recordElement); newline(factory, parent); } return recordListElement; }
From source file:org.eclipse.smila.datamodel.xml.DOMRecordWriter.java
/** * Append a RecordList element describing the given record list to the given parent element. The record list element * is appended as a new last child to the parent element. * /*from ww w. j av a 2 s .c om*/ * @param parent * the parent element to append to. * @param records * the record list to transform. * * @return the appended element */ public Element appendRecordList(final Element parent, final Record[] records) { final Document factory = parent.getOwnerDocument(); newline(factory, parent); final Element recordListElement = appendElement(factory, parent, XmlConstants.TAG_RECORDLIST); for (final Record record : records) { final Element recordElement = buildRecord(factory, record); recordListElement.appendChild(recordElement); newline(factory, parent); } return recordListElement; }
From source file:org.eclipse.smila.processing.bpel.MessageHelper.java
/** * add request id part as first child element of message. * // ww w . ja v a2 s . c om * @param message * a message variable * @param requestId * request id. * @param varType * type of variable. currently necessary to decide where to put the Id. */ public void addRequestId(final Element message, final String requestId, final QName varType) { Element idNode = createRequestIdNode(requestId, message.getOwnerDocument()); final Element idPart = message.getOwnerDocument().createElementNS(null, BPELConstants.PART_ID); idPart.appendChild(idNode); idNode = idPart; if (DOMUtils.isEmptyElement(message)) { message.appendChild(idNode); } else { message.insertBefore(idNode, DOMUtils.getFirstChildElement(message)); } }
From source file:org.eclipse.smila.search.datadictionary.messages.ddconfig.DHighlightingTransformerCodec.java
public static Element encode(DHighlightingTransformer dHighlightingTransformer, Element element) throws ConfigurationException { final Log log = LogFactory.getLog(DHighlightingTransformerCodec.class); final Document doc = element.getOwnerDocument(); final Element el = doc.createElementNS(DConfigurationCodec.NS, "HighlightingTransformer"); el.setAttribute("Name", dHighlightingTransformer.getName()); try {/*from w ww. j a v a 2 s.c om*/ DParameterSetCodec.encode(dHighlightingTransformer.getParameterSet(), el); } catch (final ParameterException e) { log.error("Unable to encode parameters for HighlightingTransformer: " + e.getMessage(), e); throw new ConfigurationException( "Unable to encode parameters for HighlightingTransformer: " + e.getMessage()); } element.appendChild(el); return el; }
From source file:org.eclipse.smila.search.lucene.messages.indexstructure.DParameterCodec.java
/** * @param dParameter -/*from w w w . j a va 2 s . co m*/ * @param parent - * @return Element */ public static Element encode(DParameter dParameter, Element parent) { // prepare final Document doc = parent.getOwnerDocument(); final Element me = (Element) parent.appendChild(doc.createElementNS(DIndexStructureCodec.NS, "Parameter")); Element child = null; child = (Element) me.appendChild(doc.createElementNS(DIndexStructureCodec.NS, "Name")); child.appendChild(doc.createTextNode(dParameter.getName())); child = (Element) me.appendChild(doc.createElementNS(DIndexStructureCodec.NS, "Value")); child.appendChild(doc.createTextNode(dParameter.getValue())); return me; }
From source file:org.eclipse.smila.search.templates.messages.nodetransformerregistry.DNodeTransformerCodec.java
/** * @param dNodeTransformer -//from w w w .ja v a 2s .co m * @param element - * @return Element * @throws DNodeTransformerRegistryException - */ protected static Element encode(DNodeTransformer dNodeTransformer, Element element) throws DNodeTransformerRegistryException { final Log log = LogFactory.getLog(DNodeTransformerCodec.class); final Document doc = element.getOwnerDocument(); final Element el = (Element) element .appendChild(doc.createElementNS(DNodeTransformerRegistryCodec.NS, "NodeTransformer")); el.setAttribute("Name", dNodeTransformer.getName()); Element elTemp = null; elTemp = doc.createElementNS(DNodeTransformerRegistryCodec.NS, "ClassName"); elTemp.appendChild(doc.createTextNode(dNodeTransformer.getClassName())); el.appendChild(elTemp); elTemp = doc.createElementNS(DNodeTransformerRegistryCodec.NS, "Description"); elTemp.appendChild(doc.createTextNode(dNodeTransformer.getDescription())); el.appendChild(elTemp); try { DParameterDefinitionCodec.encode(dNodeTransformer.getParameterDefinition(), el); } catch (ParameterException e) { log.error("Unable to encode parameters for NodeTransformer [" + dNodeTransformer.getName() + "]: " + e.getMessage(), e); throw new DNodeTransformerRegistryException("Unable to encode parameters for NodeTransformer [" + dNodeTransformer.getName() + "]: " + e.getMessage()); } return el; }
From source file:org.eclipse.swordfish.p2.internal.deploy.server.MetadataProcessor.java
/** * Add an instruction to the bundle IU metadata * This creates all possibly missing nodes and appends the instruction to the * node designated for the phase.//from w ww . j a v a2s. c o m * * @param bundle - the bundle node * @param phase - the phase where the instruction should be added. * @param instructionCode - the instruction to be added * @return the modified bundle node */ private final Node addInstruction(Node bundle, String phase, String instructionCode) { Element touchPointDataElem = getOrCreateChild(bundle, TOUCHPOINT_DATA); Element instructionsElem = getOrCreateChild(touchPointDataElem, INSTRUCTIONS); String instructionQuery = INSTRUCTION + "[@" + KEY + " = '" + phase + "']"; NodeList instrucList = query(instructionsElem, instructionQuery); Element instruction; if (instrucList.getLength() == 0) { instruction = appendChild(instructionsElem, INSTRUCTION); instruction.setAttribute(KEY, phase); instruction.appendChild(instruction.getOwnerDocument().createTextNode("")); } else { instruction = (Element) instrucList.item(0); } Node instructionTextNode = getTextNode(instruction); if (instructionTextNode == null) { instructionTextNode = instruction.appendChild(instruction.getOwnerDocument().createTextNode("")); } String val = instructionTextNode.getNodeValue(); if ("".equals(val) || val == null) { instructionTextNode.setNodeValue(instructionCode); } else { String delimiter = val.replaceAll(" ", "").replaceAll(CR, "").endsWith(";") ? "" : ";"; instructionTextNode.setNodeValue(val + delimiter + instructionCode); } int iCounter = query(instructionsElem, INSTRUCTION).getLength(); instructionsElem.setAttribute(SIZE, "" + iCounter); int tdCounter = query(touchPointDataElem, INSTRUCTIONS).getLength(); touchPointDataElem.setAttribute(SIZE, "" + tdCounter); return bundle; }
From source file:org.eclipse.thym.core.plugin.CordovaPluginManager.java
private List<IPluginInstallationAction> collectHeaderFileActions(Element node, AbstractPluginInstallationActionsFactory factory) { ArrayList<IPluginInstallationAction> list = new ArrayList<IPluginInstallationAction>(); List<Element> headerFiles = CordovaPluginXMLHelper.getHeaderFileNodes(node); for (Element current : headerFiles) { String src = getAttributeValue(current, "src"); String targetDir = getAttributeValue(current, "target-dir"); String id = CordovaPluginXMLHelper.getAttributeValue(node.getOwnerDocument().getDocumentElement(), "id"); IPluginInstallationAction action = factory.getHeaderFileAction(src, targetDir, id); list.add(action);//from w w w . j a v a 2s . c om } return list; }
From source file:org.eclipse.thym.core.plugin.CordovaPluginManager.java
private List<IPluginInstallationAction> collectSourceFilesActions(Element node, AbstractPluginInstallationActionsFactory factory) { ArrayList<IPluginInstallationAction> list = new ArrayList<IPluginInstallationAction>(); List<Element> sourceFiles = getSourceFileNodes(node); for (Element current : sourceFiles) { String src = getAttributeValue(current, "src"); String targetDir = getAttributeValue(current, "target-dir"); String framework = getAttributeValue(current, "framework"); String compilerFlags = getAttributeValue(current, "compiler-flags"); String id = CordovaPluginXMLHelper.getAttributeValue(node.getOwnerDocument().getDocumentElement(), "id"); IPluginInstallationAction action = factory.getSourceFileAction(src, targetDir, framework, id, compilerFlags);/*w w w.j a va 2 s .c o m*/ list.add(action); } return list; }