Package org.apache.xml.serialize

Examples of org.apache.xml.serialize.Serializer


     * @return A suitable serializer
     */
    public DocumentHandler getSerializer( OutputStream output )
        throws IOException
    {
        Serializer      serializer;
        DocumentHandler docHandler;

        serializer = getSerializer();
        serializer.setOutputByteStream( output );
        docHandler = serializer.asDocumentHandler();
        if ( docHandler == null )
            throw new RuntimeException( Messages.format( "conf.serializerNotSaxCapable",
                                                         serializer.getClass().getName() ) );
        return docHandler;
    }
View Full Code Here


     * @return A suitable serializer
     */
    public DocumentHandler getSerializer( Writer output )
        throws IOException
    {
        Serializer      serializer;
        DocumentHandler docHandler;

        serializer = getSerializer();
        serializer.setOutputCharStream( output );
        docHandler = serializer.asDocumentHandler();
        if ( docHandler == null )
            throw new RuntimeException( Messages.format( "conf.serializerNotSaxCapable",
                                                         serializer.getClass().getName() ) );
        return docHandler;
    }
View Full Code Here

      * The String representation is a xml well-formed fragment corresponding
      * to the representation of this node.
      */
     public String toString() {

        Serializer serializer = LocalConfiguration.getInstance().getSerializer();
        if (serializer == null)
            throw new RuntimeException("Unable to obtain serializer");

        StringWriter writer = new StringWriter();

        serializer.setOutputCharStream( writer );

        try {
            AnyNode2SAX.fireEvents(this,serializer.asDocumentHandler());
        } catch (java.io.IOException ioe) {
            return privateToString();
        } catch (org.xml.sax.SAXException saxe) {
            throw new RuntimeException(saxe.getMessage());
        }
View Full Code Here

            // DOM is complete, now serialize it.
            Writer writer = new StringWriter();
            OutputFormat format = new OutputFormat();
            format.setEncoding("utf-8");
            Serializer serializer = SerializerFactory.getSerializerFactory("xml").makeSerializer(writer, format);
            try {
                  serializer.asDOMSerializer().serialize(document);
            } catch (IOException exception) {
                  exception.printStackTrace();
                  System.exit(1);
            }
View Full Code Here

          "Unable to generate C++ BuilderX project when gcc or bcc is not used.");
    }

    OutputStream outStream = new FileOutputStream(projectFile);
    OutputFormat format = new OutputFormat("xml", "UTF-8", true);
    Serializer serializer = new XMLSerializer(outStream, format);
    ContentHandler content = serializer.asContentHandler();
    content.startDocument();
    AttributesImpl emptyAttrs = new AttributesImpl();
    content.startElement(null, "project", "project", emptyAttrs);
    PropertyWriter propertyWriter = new PropertyWriter(content);
    propertyWriter.write("build.config", "active", "0");
View Full Code Here

            // marshal: use SAX I handler to filter document XML for
            // page and folder menu definition menu elements ordered
            // polymorphic collection to strip artifical <menu-element>
            // tags enabling Castor XML binding; see JETSPEED-INF/castor/page-mapping.xml
            writer = new OutputStreamWriter(new FileOutputStream(f), PSML_DOCUMENT_ENCODING);
            Serializer serializer = new XMLSerializer(writer, this.format);
            final DocumentHandler handler = serializer.asDocumentHandler();
            Marshaller marshaller = new Marshaller(new DocumentHandler()
                {
                    private int menuDepth = 0;

                    public void characters(char[] ch, int start, int length) throws SAXException
View Full Code Here

                _format = new OutputFormat( Method.XML, _response.getCharacterEncoding(), false );
                ser = new XMLSerializer( _format );
                ser.setOutputCharStream( getWriter() );
                _resultHandler = new ResultHandlerAdapter(ser.asDocumentHandler());
            } else {
                Serializer ser;
               
                _format.setEncoding( _response.getCharacterEncoding() );
                ser = SerializerFactory.getSerializerFactory( _format.getMethod() ).makeSerializer( _format );
                ser.setOutputCharStream( getWriter() );
                _resultHandler = new ResultHandlerAdapter(ser.asDocumentHandler());
            }
            _response.setContentType( "text/" + _format.getMethod() );

            if ( _stylesheet != null ) {
                SAXInput saxInput = new SAXInput();
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

            writer = new FileWriter(f);
            // create the serializer output format
            OutputFormat format = new OutputFormat();
            format.setIndenting(true);
            format.setIndent(4);
            Serializer serializer = new XMLSerializer(writer,format);
            Marshaller marshaller = new Marshaller(serializer.asDocumentHandler());
            marshaller.setMapping(this.loadMapping());
            marshaller.marshal(doc.getPortlets());

            success = true;
        }
View Full Code Here

TOP

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

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.