Package org.apache.xml.serialize

Examples of org.apache.xml.serialize.XMLSerializer


  public static String serializeXML(Document document) throws GUIException {
    try {
      StringWriter stringWriter = new StringWriter();
      OutputFormat format = new OutputFormat("XML", "ISO-8859-1", true);
      format.setLineWidth(0);
      XMLSerializer serializer = new XMLSerializer(stringWriter, format);
      serializer.asDOMSerializer().serialize(document);
      /* We don't want the newline character at the end */
      String string = stringWriter.toString();
      return string.substring(0, string.length() - 1);
    } catch (Exception e) {
      throw new GUIException("Could not serialize XML", e);
View Full Code Here


                format.setLineSeparator(LINE_SEP);
            } else {
                format.setLineSeparator("");
            }
            StringWriter writer = new StringWriter(1000);
            XMLSerializer serial = new XMLSerializer(writer, format);
            serial.asDOMSerializer();
            if (node instanceof Document) {
                serial.serialize((Document) node);
            } else if (node instanceof Element) {
                format.setOmitXMLDeclaration(true);
                serial.serialize((Element) node);
            } else if (node instanceof DocumentFragment) {
                format.setOmitXMLDeclaration(true);
                serial.serialize((DocumentFragment) node);
            } else if (node instanceof Text) {
                Text text = (Text) node;
                return text.getData();
            } else if (node instanceof Attr) {
                Attr attr = (Attr) node;
View Full Code Here

        try
        {
            // a serializer
            OutputFormat outputFormat = new OutputFormat( mXMLDocument, null, true );   //@XERCES
            outputFormat.setEncoding(mEncoding);                                        //@XERCES
            XMLSerializer ser = new XMLSerializer( tXMLWriter, outputFormat );          //@XERCES
            ser.serialize( mXMLDocument );                                              //@XERCES
            return tXMLWriter.toString();
        }
        catch( IOException e )
        {
            throw new ProgrammerException("XMLwithDOMBuilder: getXML returns exception: " + e.getMessage());
View Full Code Here

        try
        {
            // a serializer
            OutputFormat outputFormat = new OutputFormat( mXMLDocument, null, true );   //@XERCES
            outputFormat.setEncoding(mEncoding);                                        //@XERCES
            XMLSerializer ser = new XMLSerializer( tXMLWriter, outputFormat );          //@XERCES
            ser.serialize( mXMLDocument );                                              //@XERCES
        }
        catch( IOException e )
        {
            mLog.error("getXML returns IOException", e);
        }
View Full Code Here

  }
 
  public static void write(Document doc, Writer writer) throws IOException {
    OutputFormat format = new OutputFormat();
    format.setIndenting(INDENTING);
    XMLSerializer serializer = new XMLSerializer(format);
    serializer.setNamespaces(true);
    serializer.setOutputCharStream(writer);
    serializer.serialize(doc);
  }
View Full Code Here

  }

  public static void write(Element elem, Writer writer) throws IOException {
    OutputFormat format = new OutputFormat();
    format.setIndenting(INDENTING);
    XMLSerializer serializer = new XMLSerializer(format);
    serializer.setNamespaces(true);
    serializer.setOutputCharStream(writer);
    serializer.serialize(elem);
  }
View Full Code Here

      StringWriter out = new StringWriter();
      OutputFormat format = new OutputFormat(updatedJobDoc);
      format.setEncoding("ISO-8859-1");
      format.setIndenting(true);
      format.setIndent(2);
          XMLSerializer serializer = new XMLSerializer(out, format);
          serializer.serialize(updatedJobDoc);
          logger.debug3("submitting job... ");
          logger.debug9(out.toString());
          String answer = spooler.execute_xml(out.toString());
          logger.debug3("answer from scheduler: "+answer);
View Full Code Here

          OutputStreamWriter out = new OutputStreamWriter(fout, "UTF-8");
      OutputFormat format = new OutputFormat(updatedJobDoc);
      format.setEncoding("UTF-8");
      format.setIndenting(true);
      format.setIndent(2);
          XMLSerializer serializer = new XMLSerializer(out, format);
          logger.debug3("Writing file "+jobFile.getAbsolutePath());
          serializer.serialize(updatedJobDoc);
          out.close();
    } catch (Exception e){
      if (jobFile!=null){
        throw new Exception("Error occured updating job file \""+jobFile.getAbsolutePath()+"\": "+e,e);
      }else throw new Exception("Error occured updating file for job \""+jobName+"\": "+e,e);
View Full Code Here

          OutputStreamWriter out = new OutputStreamWriter(fout, "UTF-8");
      OutputFormat format = new OutputFormat(configurationDocument);
      format.setEncoding("UTF-8");
      format.setIndenting(true);
      format.setIndent(2);
          XMLSerializer serializer = new XMLSerializer(out, format);
          serializer.serialize(configurationDocument);
          out.close();
    } catch (Exception e){
      throw new Exception ("Error writing Job Scheduler configuration file: "+e,e);
    }
  } 
View Full Code Here

        StringWriter out = new StringWriter();
        OutputFormat format = new OutputFormat(runTimeDocument);   
        format.setIndenting(true);
        format.setIndent(2);
        format.setOmitXMLDeclaration(true);
            XMLSerializer serializer = new XMLSerializer(out, format);
            serializer.serialize(runTimeDocument);
            Comment runTimeComment = jobDoc.createComment("This run_time is currently not supported:\n"+out.toString());
            jobElement.appendChild(runTimeComment);
      } else{
        jobElement.appendChild(runTimeElement);
      }
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.