List of usage examples for org.w3c.dom Document appendChild
public Node appendChild(Node newChild) throws DOMException;
newChild
to the end of the list of children of this node. From source file:hd3gtv.as5kpc.protocol.ProtocolHandler.java
public ServerResponseAbout getConfigInfo(ServerResponseAbout init_result) throws IOException { Document document = createDocument(); Element root_ams_element = document.createElement("AMS"); document.appendChild(root_ams_element); Element last_order_element = document.createElement("Configuration"); Element ci = document.createElement("GetConfigInfo"); last_order_element.appendChild(ci);/* ww w .jav a 2 s . co m*/ root_ams_element.appendChild(last_order_element); send(document, init_result); return init_result; }
From source file:hd3gtv.as5kpc.protocol.ProtocolHandler.java
public ServerResponseHWstatus getHardwareStatus() throws IOException { Document document = createDocument(); Element root_ams_element = document.createElement("AMS"); document.appendChild(root_ams_element); Element last_order_element = document.createElement("Configuration"); Element hs = document.createElement("GetHardwareStatus"); hs.setAttribute("Verbose", "true"); last_order_element.appendChild(hs);/*from ww w . j a v a2s .c o m*/ root_ams_element.appendChild(last_order_element); return (ServerResponseHWstatus) send(document, new ServerResponseHWstatus()); }
From source file:hd3gtv.as5kpc.protocol.ProtocolHandler.java
public ServerResponseStatus getStatus() throws IOException { Document document = createDocument(); Element root_ams_element = document.createElement("AMS"); document.appendChild(root_ams_element); Element last_order_element = document.createElement("TransportControl"); Element status = document.createElement("GetStatus"); status.setAttribute("InputStatus", "true"); last_order_element.appendChild(status); root_ams_element.appendChild(last_order_element); return (ServerResponseStatus) send(document, new ServerResponseStatus()); }
From source file:hd3gtv.as5kpc.protocol.ProtocolHandler.java
public ServerResponseClipdata getClipData(String id) throws IOException { Document document = createDocument(); Element root_ams_element = document.createElement("AMS"); document.appendChild(root_ams_element); Element last_order_element = document.createElement("DatabaseControl"); Element cd = document.createElement("GetClipData"); cd.setAttribute("ID", id); last_order_element.appendChild(cd);//from ww w .j a v a 2 s. c om root_ams_element.appendChild(last_order_element); return (ServerResponseClipdata) send(document, new ServerResponseClipdata()); }
From source file:hd3gtv.as5kpc.protocol.ProtocolHandler.java
public ServerResponseOk disconnect() throws IOException { Document document = createDocument(); Element root_ams_element = document.createElement("AMS"); document.appendChild(root_ams_element); Element last_order_element = document.createElement("Configuration"); Element init = document.createElement("Disconnect"); last_order_element.appendChild(init); root_ams_element.appendChild(last_order_element); ServerResponseOk result = (ServerResponseOk) send(document, new ServerResponseOk()); close();// w w w.j a va2 s. co m return result; }
From source file:hd3gtv.as5kpc.protocol.ProtocolHandler.java
public ServerResponseId recordCue(String id, String name) throws IOException { Document document = createDocument(); Element root_ams_element = document.createElement("AMS"); document.appendChild(root_ams_element); Element last_order_element = document.createElement("TransportControl"); Element rec = document.createElement("RecordCue"); rec.setAttribute("ID", id); rec.setAttribute("Name", name); rec.setAttribute("EjectFirst", "true"); last_order_element.appendChild(rec); root_ams_element.appendChild(last_order_element); return (ServerResponseId) send(document, new ServerResponseId()); }
From source file:com.graphhopper.http.GraphHopperServlet.java
String errorsToXML(List<Throwable> list) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.newDocument(); Element gpxElement = doc.createElement("gpx"); gpxElement.setAttribute("creator", "GraphHopper"); gpxElement.setAttribute("version", "1.1"); doc.appendChild(gpxElement); Element mdElement = doc.createElement("metadata"); gpxElement.appendChild(mdElement);// w ww. j a v a 2 s . c o m Element errorsElement = doc.createElement("extensions"); mdElement.appendChild(errorsElement); for (Throwable t : list) { Element error = doc.createElement("error"); errorsElement.appendChild(error); error.setAttribute("message", t.getMessage()); error.setAttribute("details", t.getClass().getName()); } TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); StringWriter writer = new StringWriter(); transformer.transform(new DOMSource(doc), new StreamResult(writer)); return writer.toString(); }
From source file:ddf.security.samlp.SimpleSign.java
/** * Forces a signature value to be added to a {@code SignableSAMLObject}. * * <p>This is needed in the case of a message wrapped in a SOAP Envelope where the {@code * org.opensaml.xmlsec.signature.support.Signer} will not be triggered. * * @param samlObject signable object to be signed * @param <T> instance of a class that extends {@code SignableSAMLObject} * @return copy of the input object with a valid signature value * @throws SignatureException/* w w w .j av a2 s . c o m*/ * @throws WSSecurityException * @throws XMLStreamException */ public <T extends SignableSAMLObject> T forceSignSamlObject(T samlObject) throws SignatureException, WSSecurityException, XMLStreamException { signSamlObject(samlObject); Document doc = DOMUtils.createDocument(); doc.appendChild(doc.createElement("root")); Element reqElem = OpenSAMLUtil.toDom(samlObject, doc); String nodeToString = DOM2Writer.nodeToString(reqElem); final Document responseDoc = StaxUtils .read(new ByteArrayInputStream(nodeToString.getBytes(StandardCharsets.UTF_8))); return (T) OpenSAMLUtil.fromDom(responseDoc.getDocumentElement()); }
From source file:com.enonic.esl.xml.XMLTool.java
/** * Create a new document with a top element in a specific namespace. * * @param namespaceURI The namespace URI. * @param qualifiedName The name of the top element. * @param docType DocumentType// www. java2s .c o m * @return Document */ private static Document createDocument(String namespaceURI, String qualifiedName, DocumentType docType) { Document doc = createDocument(); if (docType != null) { doc.appendChild(docType); } if (namespaceURI != null) { doc.appendChild(doc.createElementNS(namespaceURI, qualifiedName)); } else { doc.appendChild(doc.createElement(qualifiedName)); } return doc; }
From source file:hoot.services.controllers.osm.ChangesetDbWriter.java
/** * Writes a changeset upload response to an XML document * * @param changesetId// www .j a v a 2s .c o m * ID of the uploaded changeset * @param changesetDiffElements * Elements that have been modified in the corresponding * changeset request * @return a changeset upload response XML document */ private static Document writeResponse(long changesetId, List<XmlSerializable> changesetDiffElements) { logger.debug("Building response..."); Document responseDoc = null; try { responseDoc = XmlDocumentBuilder.create(); } catch (ParserConfigurationException e) { throw new RuntimeException("Error creating XmlDocumentBuilder!", e); } org.w3c.dom.Element osmElement = OsmResponseHeaderGenerator.getOsmDataHeader(responseDoc); org.w3c.dom.Element diffResultXmlElement = responseDoc.createElement("diffResult"); diffResultXmlElement.setAttribute("generator", GENERATOR); diffResultXmlElement.setAttribute("version", OSM_VERSION); for (XmlSerializable element : changesetDiffElements) { diffResultXmlElement.appendChild(element.toChangesetResponseXml(diffResultXmlElement)); } osmElement.appendChild(diffResultXmlElement); responseDoc.appendChild(osmElement); return responseDoc; }