Package org.apache.xml.serializer

Examples of org.apache.xml.serializer.Serializer


        StreamResult sresult = (StreamResult) outputTarget;
        String method = m_outputFormat.getProperty(OutputKeys.METHOD);

        try
        {
          Serializer serializer =
            SerializerFactory.getSerializer(m_outputFormat.getProperties());

          m_serializer = serializer;

          if (null != sresult.getWriter())
            serializer.setWriter(sresult.getWriter());
          else if (null != sresult.getOutputStream())
            serializer.setOutputStream(sresult.getOutputStream());
          else if (null != sresult.getSystemId())
          {

            // FIX FOR http://issues.apache.org/jira/browse/XALANJ-1978
            /* REMOVING THIS
            String fileURL = sresult.getSystemId();

            if (fileURL.startsWith("file:///"))
            {
              if (fileURL.substring(8).indexOf(":") >0)
                fileURL = fileURL.substring(8);
              else
                fileURL = fileURL.substring(7);
            }
            */
            /* REPLACING WITH THIS LINE: */
            String fileURL = new URL(sresult.getSystemId()).getFile();

            m_outputStream = new java.io.FileOutputStream(fileURL);
            serializer.setOutputStream(m_outputStream);
          }
          else
            throw new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_NO_OUTPUT_SPECIFIED, null)); //"No output specified!");

          m_resultContentHandler = serializer.asContentHandler();
        }
        catch (IOException ioe)
        {
          throw new TransformerException(ioe);
        }
View Full Code Here


      if (!m_foundFirstElement && null != m_serializer)
      {
        m_foundFirstElement = true;

        Serializer newSerializer;

        try
        {
          newSerializer = SerializerSwitcher.switchSerializerIfHTML(uri,
                  localName, m_outputFormat.getProperties(), m_serializer);
        }
        catch (TransformerException te)
        {
          throw new SAXException(te);
        }

        if (newSerializer != m_serializer)
        {
          try
          {
            m_resultContentHandler = newSerializer.asContentHandler();
          }
          catch (IOException ioe// why?
          {
            throw new SAXException(ioe);
          }
View Full Code Here

        response.setContentType("text/xml; charset=\"utf-8\"");
        Writer writer = response.getWriter();
        // borrow xalan's serializer to let us use SAX choice menu generator
        Properties props =
           OutputPropertiesFactory.getDefaultMethodProperties(Method.XML);
        Serializer ser = SerializerFactory.getSerializer(props);
        ser.setWriter(writer);
        try
        {
            ChoicesXMLGenerator.generate(result, format, ser.asContentHandler());
        }
        catch(SAXException e)
        {
            throw new IOException(e.toString());
        }
        finally
        {
            ser.reset();
        }
        writer.flush();
    }
View Full Code Here

        // Notar que las clases deben estar en:
        // org.apache.xml.serializer (con r al final)
        // el mismo sin "r" al final tiene la mayor�a de clases
        // despreciadas

        Serializer serializer = SerializerFactory.getSerializer(defaultProps);
        serializer.setWriter(out);
        try
        {
            return serializer.asDOMSerializer();
        }
        catch(IOException ex)
        {
            throw new ItsNatException(ex);
        }
View Full Code Here

       FileOutputStream fos = new FileOutputStream("birds.out");
     
      java.util.Properties xmlProps = OutputPropertiesFactory.getDefaultMethodProperties("xml");
      xmlProps.setProperty("indent", "yes");
      xmlProps.setProperty("standalone", "no");     
      Serializer serializer = SerializerFactory.getSerializer(xmlProps);
      serializer.setOutputStream(fos);
  
     
      // Set the result handling to be a serialization to the file output stream.
      Result result = new SAXResult(serializer.asContentHandler());
      handler.setResult(result);
     
      // Parse the XML input document.
      reader.parse("birds.xml");
     
View Full Code Here

        response.setContentType("text/xml; charset=\"utf-8\"");
        Writer writer = response.getWriter();
        // borrow xalan's serializer to let us use SAX choice menu generator
        Properties props =
           OutputPropertiesFactory.getDefaultMethodProperties(Method.XML);
        Serializer ser = SerializerFactory.getSerializer(props);
        ser.setWriter(writer);
        try
        {
            ChoicesXMLGenerator.generate(result, format, ser.asContentHandler());
        }
        catch(SAXException e)
        {
            throw new IOException(e.toString(), e);
        }
        finally
        {
            ser.reset();
        }
        writer.flush();
    }
View Full Code Here

      if (null == m_serializationHandler)
      {
        // if we didn't get one from the pool, go make a new one

       
        Serializer serializer = org.apache.xml.serializer.SerializerFactory.getSerializer(
            m_textformat.getProperties());
        m_serializationHandler = (SerializationHandler) serializer;
      }

        m_serializationHandler.setTransformer(this);
View Full Code Here

    {
      StreamResult sresult = (StreamResult) outputTarget;

      try
      {
        Serializer serializer =
          SerializerFactory.getSerializer(m_outputFormat.getProperties());

        m_serializer = serializer;

        if (null != sresult.getWriter())
          serializer.setWriter(sresult.getWriter());
        else if (null != sresult.getOutputStream())
          serializer.setOutputStream(sresult.getOutputStream());
        else if (null != sresult.getSystemId())
        {
          String fileURL = sresult.getSystemId();

          if (fileURL.startsWith("file:///")) {
            if (fileURL.substring(8).indexOf(":") >0) {
              fileURL = fileURL.substring(8);
            } else  {
              fileURL = fileURL.substring(7);
            }
          } else if (fileURL.startsWith("file:/")) {
            if (fileURL.substring(6).indexOf(":") >0) {
              fileURL = fileURL.substring(6);
            } else {
              fileURL = fileURL.substring(5);
            }
          }

          m_outputStream = new java.io.FileOutputStream(fileURL);
          serializer.setOutputStream(m_outputStream);
        }
        else
          throw new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_NO_OUTPUT_SPECIFIED, null)); //"No output specified!");

        m_resultContentHandler = serializer.asContentHandler();
      }
      catch (IOException ioe)
      {
        throw new TransformerException(ioe);
      }
View Full Code Here

    if (!m_foundFirstElement && null != m_serializer)
    {
      m_foundFirstElement = true;

      Serializer newSerializer;

      try
      {
        newSerializer = SerializerSwitcher.switchSerializerIfHTML(uri,
                localName, m_outputFormat.getProperties(), m_serializer);
      }
      catch (TransformerException te)
      {
        throw new SAXException(te);
      }

      if (newSerializer != m_serializer)
      {
        try
        {
          m_resultContentHandler = newSerializer.asContentHandler();
        }
        catch (IOException ioe// why?
        {
          throw new SAXException(ioe);
        }
View Full Code Here

   
      // xmlFilter3 outputs SAX events to the serializer.
      java.util.Properties xmlProps = OutputPropertiesFactory.getDefaultMethodProperties("xml");
      xmlProps.setProperty("indent", "yes");
      xmlProps.setProperty("standalone", "no");
      Serializer serializer = SerializerFactory.getSerializer(xmlProps);                     
      serializer.setOutputStream(System.out);
      xmlFilter3.setContentHandler(serializer.asContentHandler());

      // Perform the series of transformations as follows:
      //   - transformer3 gets its parent (transformer2) as the XMLReader/XMLFilter
      //     and calls transformer2.parse(new InputSource("foo.xml")).
      //   - transformer2 gets its parent (transformer1) as the XMLReader/XMLFilter
View Full Code Here

TOP

Related Classes of org.apache.xml.serializer.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.