Package org.apache.xml.serialize

Examples of org.apache.xml.serialize.XMLSerializer


          if (extractFormat.equals(TEXT_FORMAT)) {
            serializer = new TextSerializer();
            serializer.setOutputCharStream(writer);
            serializer.setOutputFormat(new OutputFormat("Text", "UTF-8", true));
          } else {
            serializer = new XMLSerializer(writer, new OutputFormat("XML", "UTF-8", true));
          }
          if (xpathExpr != null) {
            Matcher matcher =
                    PARSER.parse(xpathExpr);
            serializer.startDocument();//The MatchingContentHandler does not invoke startDocument.  See http://tika.markmail.org/message/kknu3hw7argwiqin
View Full Code Here


      OutputFormat format = new OutputFormat(document);
      format.setLineWidth(65);
      format.setIndenting(true);
      format.setIndent(2);
      Writer out = new StringWriter();
      XMLSerializer serializer = new XMLSerializer(out, format);
      serializer.serialize(document);
      return out.toString();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

        return  printXML(doc, outFormat);    
      }

      public static String printXML(Document doc,OutputFormat outFormat) {
          StringWriter  strWriter    = new StringWriter();
          XMLSerializer serializer   = new XMLSerializer(strWriter,outFormat);
              try {
                  serializer.serialize(doc);
                  strWriter.close();
              } catch (IOException e) {
                  return "";
              }           
         return  strWriter.toString();    
View Full Code Here

        OutputFormat format = new OutputFormat(e.getOwnerDocument());
        format.setLineWidth(65);
        format.setIndenting(true);
        format.setIndent(2);
        StringWriter out = new StringWriter();
        XMLSerializer serializer = new XMLSerializer(out, format);
        serializer.serialize(e);

        return out.toString();
    }
View Full Code Here

        OutputFormat format = new OutputFormat(e.getOwnerDocument());
        format.setLineWidth(65);
        format.setIndenting(true);
        format.setIndent(2);
        StringWriter out = new StringWriter();
        XMLSerializer serializer = new XMLSerializer(out, format);
        serializer.serialize(e);

        return out.toString();
    }
View Full Code Here

        OutputFormat format = new OutputFormat(e.getOwnerDocument());
        format.setLineWidth(65);
        format.setIndenting(true);
        format.setIndent(2);
        StringWriter out = new StringWriter();
        XMLSerializer serializer = new XMLSerializer(out, format);
        serializer.serialize(e);

        return out.toString();
    }
View Full Code Here

    protected Document domToFom(org.w3c.dom.Document dom, SecurityOptions options) {
        Document doc = null;
        if (dom != null) {
            try {
                Serializer ser = new XMLSerializer();
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                ser.setOutputByteStream(out);
                ser.asDOMSerializer().serialize(dom);
                ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
                doc = options.getParser().parse(in);
            } catch (Exception e) {
            }
        }
View Full Code Here

    protected Element domToFom(org.w3c.dom.Element element, SecurityOptions options) {
        Element el = null;
        if (element != null) {
            try {
                Serializer ser = new XMLSerializer();
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                ser.setOutputByteStream(out);
                ser.asDOMSerializer().serialize(element);
                ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
                el = options.getParser().parse(in).getRoot();
            } catch (Exception e) {
            }
        }
View Full Code Here

 
 
  private static OMElement convertToOMelement(Element elem, SOAPConstants constants) throws WSSecurityException {

    try {
      XMLSerializer xmlSer = new XMLSerializer();
     
      /*
       *When we extract the wsse:Security header by serializing it
       *The namespaces declared globally will not be copied into the
       *serialized element. Therefore we have to add the missing namespaces
       *in to the element before DOm serialization
       */
      elem.setAttribute("xmlns:soapenv",constants.getEnvelopeURI());
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
     
      xmlSer.setOutputByteStream(baos);
     
      xmlSer.serialize(elem);
     
      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
      XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(bais);
      StAXOMBuilder builder = new StAXOMBuilder(reader);
      builder.setCache(true);
View Full Code Here

        OutputFormat format = new OutputFormat(e.getOwnerDocument());
        format.setLineWidth(65);
        format.setIndenting(true);
        format.setIndent(2);
        StringWriter out = new StringWriter();
        XMLSerializer serializer = new XMLSerializer(out, format);
        serializer.serialize(e);

        return out.toString();
    }
View Full Code Here

TOP

Related Classes of org.apache.xml.serialize.XMLSerializer

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.