Esempio n. 1
0
  public static org.dom4j.Document createDocument(DebugXML debugXML) {
    final TransformerXMLReceiver identity = TransformerUtils.getIdentityTransformerHandler();
    final LocationDocumentResult result = new LocationDocumentResult();
    identity.setResult(result);

    final ContentHandlerHelper helper =
        new ContentHandlerHelper(
            new ForwardingXMLReceiver(identity) {
              @Override
              public void startDocument() {}

              @Override
              public void endDocument() {}
            });

    try {
      identity.startDocument();
      debugXML.toXML(helper);
      identity.endDocument();
    } catch (SAXException e) {
      throw new OXFException(e);
    }

    return result.getDocument();
  }
Esempio n. 2
0
  public static String domToString(Node node) {
    try {
      Transformer transformer = TransformerUtils.getXMLIdentityTransformer();
      DOMSource source = new DOMSource(node);

      StringBuilderWriter writer = new StringBuilderWriter();
      transformer.transform(source, new StreamResult(writer));
      return writer.toString();
    } catch (TransformerException e) {
      throw new OXFException(e);
    }
  }
Esempio n. 3
0
 /** Compute a digest for a SAX source. */
 public static byte[] getDigest(Source source) {
   final DigestContentHandler digester = new DigestContentHandler();
   TransformerUtils.sourceToSAX(source, digester);
   return digester.getResult();
 }