protected Document request2XML(final Request bean) throws XMLException { Element reqRootElement = getRootElement(); reqRootElement.appendChild(getRequestElement(bean)); Document xomDocument = new Document(reqRootElement); return xomDocument; }
protected Document response2XML(final Response bean) throws XMLException { Element respRootElement = getRootElement(); respRootElement.appendChild(getResponseElement(bean)); Document xomDocument = new Document(respRootElement); return xomDocument; }
public static void writeRequestCollectionXML(final List<Request> requests, final File f) throws IOException, XMLException { XmlPersistenceWrite xUtl = new XmlPersistenceWrite(); Element eRoot = new Element("request-collection"); eRoot.addAttribute(new Attribute("version", Versions.CURRENT)); for(Request req: requests) { Element e = xUtl.getRequestElement(req); eRoot.appendChild(e); } Document doc = new Document(eRoot); xUtl.writeXML(doc, f); }
Document xmlDoc = new Document(root); ProcessingInstruction pi = new ProcessingInstruction("xml-stylesheet", "href=\"" + STYLESHEET_NAME + "\" type=\"text/xsl\"");
nu.xom.Document xomDoc = new nu.xom.Document((nu.xom.Element) nodes.get(0));
Document document = new Document(permissionsElement); try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) { final NiceSerializer serializer = new NiceSerializer(stream);
public static Document ensureDocument(Element rootElement) { Document doc = null; if (rootElement != null) { doc = rootElement.getDocument(); if (doc == null) { doc = new Document(rootElement); } } return doc; }
private Source convertResponse(Element responseElement) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); Serializer serializer = createSerializer(os); Document document = responseElement.getDocument(); if (document == null) { document = new Document(responseElement); } serializer.write(document); byte[] bytes = os.toByteArray(); return new StreamSource(new ByteArrayInputStream(bytes)); }
private Source convertResponse(Element responseElement) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); Serializer serializer = createSerializer(os); Document document = responseElement.getDocument(); if (document == null) { document = new Document(responseElement); } serializer.write(document); byte[] bytes = os.toByteArray(); return new StreamSource(new ByteArrayInputStream(bytes)); }
private Source convertResponse(Element responseElement) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); Serializer serializer = createSerializer(os); Document document = responseElement.getDocument(); if (document == null) { document = new Document(responseElement); } serializer.write(document); byte[] bytes = os.toByteArray(); return new StreamSource(new ByteArrayInputStream(bytes)); }
private Source convertResponse(Element responseElement) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); Serializer serializer = createSerializer(os); Document document = responseElement.getDocument(); if (document == null) { document = new Document(responseElement); } serializer.write(document); byte[] bytes = os.toByteArray(); return new StreamSource(new ByteArrayInputStream(bytes)); }
public static String xmlToString(Element elm) { // TODO ugly hack to retain namespaces return new Document((Element) elm.copy()).toXML().replaceFirst("<.+>", ""); }
@Override protected Source createResponsePayload(MethodParameter returnType, Object returnValue) throws ParserConfigurationException { Element returnedElement = (Element) returnValue; Document document = returnedElement.getDocument(); if (document == null) { document = new Document(returnedElement); } DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); DOMImplementation domImplementation = documentBuilder.getDOMImplementation(); org.w3c.dom.Document w3cDocument = DOMConverter.convert(document, domImplementation); return new DOMSource(w3cDocument); }
public Document startMakingDocument() { buffer = null; try { serializer.writeXMLDeclaration(); } catch (IOException e) { throw new RuntimeException(e); } return new Document(new Element("dummy")); // unused dummy }
static Document newDocument() { final DocType dt = new DocType( "html", "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"); final Element root = new Element("html", SXHTML.XHTML_URI.toString()); final Document d = new Document(root); d.setDocType(dt); return d; }
/** Wraps each item in the result sequence into a decorated element wrapper. */ private static Document wrapSequence(Nodes nodes) { // make a copy of the template for sequences: Element items = (Element) TEMPLATES.get(Nodes.class.getName()); items = new Element(items); int size = nodes.size(); for (int i=0; i < size; i++) { items.appendChild(wrap(nodes.get(i))); } return new Document(items); }
/** convenience method to serialize the element. * * @param os * @param indent to indent lines by (non-zero may muck up whitespace) * @throws IOException */ public void serialize(OutputStream os, int indent) throws IOException { Document doc = new Document((CMLElement)this.copy()); Serializer serializer = new Serializer(os); serializer.write(doc); }
/** Wraps each item in the result sequence into a decorated element wrapper. */ private static Document wrapSequence(Nodes nodes) { // make a copy of the template for sequences: Element items = (Element) TEMPLATES.get(Nodes.class.getName()); items = new Element(items); int size = nodes.size(); for (int i=0; i < size; i++) { items.appendChild(wrap(nodes.get(i))); } return new Document(items); }
public void shouldConvertToXml() { JsonObject object = sampleJson(); Element element = JsonXmlConverter.getElement(object, "r"); Document document = new Document(element); String xml = document.toXML(); Assert.assertTrue(xml.contains("<r>"), "should contain the opening tag <r>"); }
public static ParsedBroadcastMessage createFromPlaintext(String plaintextBroadcastMessage, String languageCode, IdentityStore identityStore, long timeCreated){ Element rootElement = new Element(TrConstants.FormatInfo.ROOT); Document broadcastMessageDocument = new Document(rootElement); //For checking purposes, implementation should be changed. broadcastMessageDocument.setBaseURI(""); Element plainText = generatePlainTextElement(plaintextBroadcastMessage, identityStore, languageCode); rootElement.appendChild(plainText); return new ParsedBroadcastMessage(broadcastMessageDocument, timeCreated); }