public void outputPretty(PrintWriter out, Annotation annotation) throws ServletException { try { Document input = XMLOutputter.annotationToDoc(annotation, pipeline); Nodes output = corenlpTransformer.transform(input); for (int i = 0; i < output.size(); i++) { out.print(output.get(i).toXML()); } } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new ServletException(e); } }
/** * @see com.isotrol.impe3.idx.oc.IndexCommand#execute(nu.xom.Node) */ public String execute(Node value) { return value.toXML(); } /**
public static String getXmlDefinition(Document doc, String entityType, String entityName) { Node node = getNode(doc, entityType, entityName); if (node != null) { return node.toXML(); } else { return null; } }
public static String innerToString(Element elm) { StringBuilder sb = new StringBuilder(); for(int i = 0; i<elm.getChildCount(); i++) { Node child = elm.getChild(i); sb.append(child.toXML()); } return sb.toString(); }
public static Node skipNlTabWs(final Node oldDoc) throws CouldNotProcessException { Node copy = oldDoc.copy(); try { String oldString = oldDoc.toXML(); String newString = oldString.replace("\n", ""); newString = newString.replace("\t", ""); newString = newString.trim(); return createDocumentFromString(newString); } catch (Exception ex) { throw new CouldNotProcessException("Couldn't skipNlTabWs. Returning old document.", ex); } }
public String convertOutbound(Object data, String varname, OutboundContext outctx) throws ConversionException { try { // Using XSLT to convert to a stream. Setup the source if (!(data instanceof Node)) { throw new ConversionException("Data is not a DOM Node"); //$NON-NLS-1$ } Node node = (Node) data; String output = node.toXML(); StringBuffer buffer = new StringBuffer(); buffer.append("var "); //$NON-NLS-1$ buffer.append(varname); buffer.append("=DWREngine._unserializeDocument(\""); //$NON-NLS-1$ buffer.append(jsutil.escapeJavaScript(output)); buffer.append("\");"); //$NON-NLS-1$ return buffer.toString(); } catch (ConversionException ex) { throw ex; } catch (Exception ex) { throw new ConversionException(ex); } }
/** * <p> * Returns the first Attribute with name attrName from Document doc. Uses xPath "// * * @throws org.openbase.jul.extension.xml.exception.XMLParsingException * @param throwException flag set throw exception if no such Attribute can be found. <br> * @param attrName * @param doc * @return */ public static String extractAttributeValue(final String attrName, final Node doc, final boolean throwException) throws XMLParsingException { String xpath = "descendant-or-self::*/@" + attrName; Nodes nodes = doc.query(xpath); for (int i = 0; i < nodes.size(); i++) { if (nodes.get(i) instanceof Attribute) { return nodes.get(i).getValue(); } } if (throwException) { throw new XMLParsingException("No Attribute " + attrName + " in document:\n" + doc.toXML()); } else { return null; } }
return nodes.get(0).toXML();
public String process(String inputFragment) { return new TestRig() .withFixture(this) .processFragment(inputFragment) .getXOMDocument() .query("//table").get(0) .toXML() .replaceAll("\u00A0", " "); }}
public String getOutputFragment(String inputFragment) { return new TestRig() .withFixture(this) .processFragment(inputFragment) .getXOMDocument() .query("//table").get(0) .toXML() .replaceAll("\u00A0", " "); }
public String processFragment(String fragment, String actualData) throws Exception { users = parse(actualData); Document document = new TestRig() .withFixture(this) .withResource(new Resource("/spec/concordion/common/command/verifyRows/strategies/toggle_html.js"), "") .withResource(new Resource("/spec/concordion/common/command/verifyRows/strategies/toggle_html.css"), "") .processFragment(fragment) .getXOMDocument(); String xml = document.getRootElement().query("//table").get(0).toXML(); return xml; }