Package javax.xml.transform.dom

Examples of javax.xml.transform.dom.DOMSource


*/
public class XmlUtil {

    public static void prettyPrintXml(Document doc, Writer writer) throws IOException {
        try {
            DOMSource domSource = new DOMSource(doc);
            StreamResult streamResult = new StreamResult(writer);
            TransformerFactory tf = TransformerFactory.newInstance();
            Transformer serializer = tf.newTransformer();
            serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
            serializer.setOutputProperty(OutputKeys.METHOD, "xml");
View Full Code Here


     * @param document the Document representing the SQLXML value
     * @throws java.sql.SQLException if the argument does not represent a
     *      valid SQLXML value
     */
    protected JDBCSQLXML(Document document) throws SQLException {
        this(new DOMSource(document));
    }
View Full Code Here

        if (bytes != null) {
            return bytes;
        }

        if (this.domResult != null) {
            DOMSource source = new DOMSource(
                    domResult.getNode(),
                    domResult.getSystemId());
            OutputStream os = setBinaryStreamImpl();
            StreamResult result = new StreamResult(os);
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    protected <T extends Source>T createDOMSource(
            Class<T> sourceClass) throws SQLException {

        DOMSource source = null;

        try {
            source = (sourceClass == null) ? new DOMSource()
                    : (DOMSource) sourceClass.newInstance();
        } catch (SecurityException ex) {
            throw Exceptions.sourceInstantiation(ex);
        } catch (IllegalAccessException ex) {
            throw Exceptions.sourceInstantiation(ex);
        } catch (InstantiationException ex) {
            throw Exceptions.sourceInstantiation(ex);
        } catch (ClassCastException ex) {
            throw Exceptions.sourceInstantiation(ex);
        }

        Transformer  transformer  = JDBCSQLXML.getIdentityTransformer();
        InputStream  stream       = this.getBinaryStreamImpl();
        StreamSource streamSource = new StreamSource();
        DOMResult    result       = new DOMResult();

        streamSource.setInputStream(stream);

        try {
            transformer.transform(streamSource, result);
        } catch (TransformerException ex) {
            throw Exceptions.transformFailed(ex);
        }
        source.setNode(result.getNode());
        source.setSystemId(result.getSystemId());

        return (T) source;
    }
View Full Code Here

                trans.setOutputProperty(OutputKeys.INDENT, "yes");

                //create string from xml tree
                StringWriter sw = new StringWriter();
                StreamResult result = new StreamResult(sw);
                DOMSource source = new DOMSource(jobDocument);
                trans.transform(source, result);
                String xmlString = sw.toString();

                try {
                    // Job ist evtl. in vorigem Job-Lauf angelegt worden
View Full Code Here

    public static void writeXmlTo(Node n, Writer w) {
        try {
            Transformer transformer = TransformerFactory.newInstance().newTransformer();
            transformer.setOutputProperty("omit-xml-declaration", "false");   //TODO Funktioniert nur mit org.jdom?
            transformer.transform(new DOMSource(n), new StreamResult(w));
        } catch (TransformerException x) { throw new XmlException(x); }
    }
View Full Code Here

        if (!xmlFile.createNewFile()) throw new Exception("Failed to create "+xmlFile.getAbsolutePath());
      }
      FileOutputStream fos = new FileOutputStream(xmlFile);
      DOMResult domResult = new DOMResult();
      StreamResult result = new StreamResult(fos);
      DOMSource source = new DOMSource(xpath.document);
      getLog().debug9("managed2liveTransformer: "+managed2liveTransformer);
     
      managed2liveTransformer.transform(source, result);
      /*getLog().debug9("Nodename: "+result.getNode().getNodeName());
      getLog().debug9("ChildNodes: "+result.getNode().getChildNodes());
View Full Code Here

          trans.setOutputProperty(OutputKeys.INDENT, "yes");
   
          //create string from xml tree
          StringWriter sw = new StringWriter();
          StreamResult result = new StreamResult(sw);
          DOMSource source = new DOMSource(dom);
          trans.transform(source, result);
          String xmlString = sw.toString();
    return xmlString;
  }
View Full Code Here

    public XHTMLDocument(Document xml, String xsl) throws WebMailException {
        StringWriter writer = new StringWriter();

        long start_t=System.currentTimeMillis();
        try {
            DOMSource msg_xml=new DOMSource((Node)xml);
            StreamSource msg_xsl=new StreamSource("file://"+xsl);
            StreamResult msg_result=new StreamResult(writer);

            TransformerFactory factory = TransformerFactory.newInstance();
View Full Code Here

    public XHTMLDocument(Document xml, Templates stylesheet) throws WebMailException {
        StringWriter writer = new StringWriter();

        long start_t=System.currentTimeMillis();
        try {
            DOMSource msg_xml=new DOMSource((Node)xml);
            StreamResult msg_result=new StreamResult(writer);

            Transformer processor = stylesheet.newTransformer();
            processor.transform(msg_xml,msg_result);
        } catch(Exception ex) {
View Full Code Here

TOP

Related Classes of javax.xml.transform.dom.DOMSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.