Package org.apache.xml.serialize

Examples of org.apache.xml.serialize.XMLSerializer


   * return XML String
   */
  public String xmlElementToString(Element element) throws Exception {
    try {
      StringWriter out = new StringWriter();
      XMLSerializer serializer = new XMLSerializer(out, new OutputFormat());
      serializer.serialize(element);
      return out.toString();
    }
    catch (Exception e) {
      throw new Exception("error occurred transforming document: " + e.getMessage());
    }
View Full Code Here


        File tempFile = new File(inFileName);
        OutputFormat    format  = new OutputFormat( tempDocument );   //Serialize DOM
        format.setIndenting(true);
        format.setLineSeparator("\n");
        FileWriter  fout = new FileWriter(tempFile);        //Writer will be a String
        XMLSerializer    serial = new XMLSerializer( fout, format );
        serial.asDOMSerializer();                            // As a DOM Serializer
        serial.serialize( tempDocument.getDocumentElement() );
        fout.close();
    }
View Full Code Here

        File tempFile = new File(inFileName);
        OutputFormat    format  = new OutputFormat( tempDocument );   //Serialize DOM
        format.setIndenting(true);
        format.setLineSeparator("\n");
        FileWriter  fout = new FileWriter(tempFile);        //Writer will be a String
        XMLSerializer    serial = new XMLSerializer( fout, format );
        serial.asDOMSerializer();                            // As a DOM Serializer
        serial.serialize( tempDocument.getDocumentElement() );
        fout.close();
    }
View Full Code Here

        File tempFile = new File(inFileName);
        OutputFormat    format  = new OutputFormat( tempDocument );   //Serialize DOM
        format.setIndenting(true);
        format.setLineSeparator("\n");
        FileWriter  fout = new FileWriter(tempFile);        //Writer will be a String
        XMLSerializer    serial = new XMLSerializer( fout, format );
        serial.asDOMSerializer();                            // As a DOM Serializer
        serial.serialize( tempDocument.getDocumentElement() );
        fout.close();
    }
View Full Code Here

            if (out != null && exists()) {
                if (isMultiple()) {
                    Document doc = DomUtil.BUILDER_FACTORY.newDocumentBuilder().newDocument();
                    doc.appendChild(getProperty(JCR_VALUES).toXml(doc));
                    OutputFormat format = new OutputFormat("xml", "UTF-8", false);
                    XMLSerializer serializer = new XMLSerializer(out, format);
                    serializer.setNamespaces(true);
                    serializer.asDOMSerializer().serialize(doc);
                } else {
                    in = ((Property)item).getStream();
                    if (in != null) {
                        IOUtil.spool(in, out);
                    }
View Full Code Here

        Document     document   = parser.getDocument(); //Our Grammar

        OutputFormat    format  = new OutputFormat( document );
        java.io.StringWriter outWriter = new java.io.StringWriter();
        XMLSerializer    serial = new XMLSerializer( outWriter,format);

        TraverseSchema tst = null;
        try {
            Element root   = document.getDocumentElement();// This is what we pass to TraverserSchema
            //serial.serialize( root );
View Full Code Here

    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) {}
      }
      return doc;
View Full Code Here

    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) {}
    }
    return el;
View Full Code Here

        try
        {
            generateXML();
            log(xmlSchema);
            xmlSerializer = new XMLSerializer(
                    new PrintWriter(
                    new FileOutputStream(xmlSchema)),
                    new OutputFormat(Method.XML, null, true));
            xmlSerializer.serialize(doc);
        }
View Full Code Here

      System.exit(1);
    }
   
    try {
      Writer out = new FileWriter(filename);
      XMLSerializer serializer = new XMLSerializer(out, format);
      serializer.serialize(xmlConfig.getDocument());
      out.close();
    } catch (IOException e) {
      logger.error(e);
      e.printStackTrace();
      System.exit(1);
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.