Package org.apache.xml.serialize

Examples of org.apache.xml.serialize.Serializer


                    fSerializerFactory = SerializerFactory.getSerializerFactory(Method.XML);
                }

                // there doesn't seem to be a way to reset a serializer, so we need to make
                // a new one each time.
                Serializer ser;
                if (streamResult.getWriter() != null) {
                    ser = fSerializerFactory.makeSerializer(streamResult.getWriter(), new OutputFormat());
                }
                else if (streamResult.getOutputStream() != null) {
                    ser = fSerializerFactory.makeSerializer(streamResult.getOutputStream(), new OutputFormat());
                }
                else if (streamResult.getSystemId() != null) {
                    String uri = streamResult.getSystemId();
                    OutputStream out = XMLEntityManager.createOutputStream(uri);
                    ser = fSerializerFactory.makeSerializer(out, new OutputFormat());
                }
                else {
                    throw new IllegalArgumentException(JAXPValidationMessageFormatter.formatMessage(fComponentManager.getLocale(),
                        "StreamResultNotInitialized", null));
                }

                // we're using the parser only as an XNI-to-SAX converter,
                // so that we can use the SAX-based serializer
                SAXParser parser = (SAXParser) fParser.get();
                if (newConfig || parser == null) {
                    parser = new SAXParser(config);
                    fParser = new SoftReference(parser);
                }
                else {
                    parser.reset();
                }
                config.setDocumentHandler(fSchemaValidator);
                fSchemaValidator.setDocumentHandler(parser);
                parser.setContentHandler(ser.asContentHandler());
            }
            else {
                fSchemaValidator.setDocumentHandler(null);
            }
           
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

            // marshal: use SAX II 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 ContentHandler handler = serializer.asContentHandler();
           
            Marshaller marshaller = new Marshaller(new ContentHandler()
                {
                    private int menuDepth = 0;
                   
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

    **/
    public SchemaWriter(Writer writer)
        throws IOException
    {

        Serializer serializer = LocalConfiguration.getInstance().getSerializer();

        if (serializer == null)
            throw new IOException("Unable to obtain serailizer");

        serializer.setOutputCharStream( writer );

        DocumentHandler handler = serializer.asDocumentHandler();

        if ( handler == null ) {
            String err = "The following serializer is not SAX capable: ";
            err += serializer.getClass().getName();
            err += "; cannot proceed.";
            throw new IOException( err );
        }

        _handler = handler;
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

          "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

                    fSerializerFactory = SerializerFactory.getSerializerFactory(Method.XML);
                }

                // there doesn't seem to be a way to reset a serializer, so we need to make
                // a new one each time.
                Serializer ser;
                if (streamResult.getWriter() != null) {
                    ser = fSerializerFactory.makeSerializer(streamResult.getWriter(), new OutputFormat());
                }
                else if (streamResult.getOutputStream() != null) {
                    ser = fSerializerFactory.makeSerializer(streamResult.getOutputStream(), new OutputFormat());
                }
                else if (streamResult.getSystemId() != null) {
                    String uri = streamResult.getSystemId();
                    OutputStream out = XMLEntityManager.createOutputStream(uri);
                    ser = fSerializerFactory.makeSerializer(out, new OutputFormat());
                }
                else {
                    throw new IllegalArgumentException(JAXPValidationMessageFormatter.formatMessage(fComponentManager.getLocale(),
                        "StreamResultNotInitialized", null));
                }

                // we're using the parser only as an XNI-to-SAX converter,
                // so that we can use the SAX-based serializer
                SAXParser parser = (SAXParser) fParser.get();
                if (newConfig || parser == null) {
                    parser = new SAXParser(config);
                    fParser = new SoftReference(parser);
                }
                else {
                    parser.reset();
                }
                config.setDocumentHandler(fSchemaValidator);
                fSchemaValidator.setDocumentHandler(parser);
                parser.setContentHandler(ser.asContentHandler());
            }
            else {
                fSchemaValidator.setDocumentHandler(null);
            }
           
View Full Code Here

     * @return A suitable serializer
     */
    public Serializer getSerializer()
    {
        String     prop;
        Serializer serializer;

        prop = _props.getProperty( Property.Serializer );
        if ( prop == null || prop.equalsIgnoreCase( "xerces" ) ) {
            // If no parser class was specified, we default to Xerces.
            serializer = new org.apache.xml.serialize.XMLSerializer();
        } else {
            try {
                serializer = (Serializer) Class.forName( prop ).newInstance();
            } catch ( Exception except ) {
                throw new RuntimeException( Messages.format( "conf.failedInstantiateSerializer",
                                                             prop, except ) );
            }
        }
        serializer.setOutputFormat( getOutputFormat() );
        return serializer;
    }
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.