Package org.apache.xalan.xpath.xml

Examples of org.apache.xalan.xpath.xml.FormatterToXML


    Document out = new org.apache.xerces.dom.DocumentImpl();
    XSLTResultTarget resultTarget = new XSLTResultTarget(out);
    processor.process(xmlID, stylesheetID, resultTarget);
   
    PrintWriter pw = new PrintWriter( System.out );
    FormatterToXML fl = new FormatterToXML(pw, true);
    TreeWalker tw = new TreeWalker(fl);
    tw.traverse(out);
   
  }
View Full Code Here


        serializer.getSerializerObject().setOutputFormat(props.getProperties());
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "xml" ) )
      {
        FormatterToXML serializer = new FormatterToXML(writer);
        serializer.getSerializerObject().setOutputFormat(props.getProperties());
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "text" ) )
      {
        FormatterToText serializer = new FormatterToText(writer);
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else
      {
        handler = null;
      }
    }
   
    if(null == handler)
    {
      String method = format.getMethod();
      org.apache.xml.serialize.SerializerFactory factory = org.apache.xml.serialize.SerializerFactory.getSerializerFactory(method);
      org.apache.xml.serialize.Serializer serializer = factory.makeSerializer(writer, format);
      handler = serializer.asDocumentHandler();
    }

    return handler;
  }
View Full Code Here

        serializer.getSerializerObject().setOutputFormat(props.getProperties());
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "xml" ) )
      {
        FormatterToXML serializer = new FormatterToXML(ostream);
        serializer.getSerializerObject().setOutputFormat(props.getProperties());
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "text" ) )
      {
        String encoding = format.getEncoding();
        if(null == encoding)
        {
          try
          {
            encoding = System.getProperty("file.encoding");
            encoding = (null != encoding) ?
                       org.apache.xalan.serialize.Encodings.convertJava2MimeEncoding( encoding ) : "ASCII";
            if(null == encoding)
            {
              encoding = "ASCII";
            }
          }
          catch(SecurityException se)
          {
            encoding = "ASCII";
          }
        }

        //this.m_encoding =   encoding;

        String javaEncoding = org.apache.xalan.serialize.Encodings.convertMime2JavaEncoding(encoding);

        Writer w = new OutputStreamWriter( ostream, javaEncoding );
        ((ParserAdapter)handler).setContentHandler(new FormatterToText(w).getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "xhtml" ) )
      {
        handler = new XMLSerializer(ostream, format);
        //handler = Serializer.makeSAXSerializer(ostream, format);
      }
      else
      {
        handler = new XMLSerializer(ostream, format);
        //handler = Serializer.makeSAXSerializer(ostream, format);
      }
    }
    if(null == handler)
    {
      String method = props.getProperty(OutputKeys.METHOD);
      org.apache.xml.serialize.SerializerFactory factory = org.apache.xml.serialize.SerializerFactory.getSerializerFactory(method);
      org.apache.xml.serialize.Serializer serializer = factory.makeSerializer(ostream, format);
      handler = serializer.asDocumentHandler();
    }

    return handler;
  }
View Full Code Here

        serializer.getSerializerObject().setOutputFormat(props.getProperties());
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "xml" ) )
      {
        FormatterToXML serializer = new FormatterToXML(writer);
        serializer.getSerializerObject().setOutputFormat(props.getProperties());
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "text" ) )
      {
        FormatterToText serializer = new FormatterToText(writer);
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else
      {
        handler = null;
      }
    }
   
    if(null == handler)
    {
      String method = format.getMethod();
      org.apache.xml.serialize.SerializerFactory factory = org.apache.xml.serialize.SerializerFactory.getSerializerFactory(method);
      org.apache.xml.serialize.Serializer serializer = factory.makeSerializer(writer, format);
      handler = serializer.asDocumentHandler();
    }

    return handler;
  }
View Full Code Here

        serializer.getSerializerObject().setOutputFormat(props.getProperties());
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "xml" ) )
      {
        FormatterToXML serializer = new FormatterToXML(ostream);
        serializer.getSerializerObject().setOutputFormat(props.getProperties());
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "text" ) )
      {
        String encoding = format.getEncoding();
        if(null == encoding)
        {
          try
          {
            encoding = System.getProperty("file.encoding");
            encoding = (null != encoding) ?
                       org.apache.xalan.serialize.Encodings.convertJava2MimeEncoding( encoding ) : "ASCII";
            if(null == encoding)
            {
              encoding = "ASCII";
            }
          }
          catch(SecurityException se)
          {
            encoding = "ASCII";
          }
        }

        //this.m_encoding =   encoding;

        String javaEncoding = org.apache.xalan.serialize.Encodings.convertMime2JavaEncoding(encoding);

        Writer w = new OutputStreamWriter( ostream, javaEncoding );
        ((ParserAdapter)handler).setContentHandler(new FormatterToText(w).getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "xhtml" ) )
      {
        handler = new XMLSerializer(ostream, format);
        //handler = Serializer.makeSAXSerializer(ostream, format);
      }
      else
      {
        handler = new XMLSerializer(ostream, format);
        //handler = Serializer.makeSAXSerializer(ostream, format);
      }
    }
    if(null == handler)
    {
      String method = props.getProperty(OutputKeys.METHOD);
      org.apache.xml.serialize.SerializerFactory factory = org.apache.xml.serialize.SerializerFactory.getSerializerFactory(method);
      org.apache.xml.serialize.Serializer serializer = factory.makeSerializer(ostream, format);
      handler = serializer.asDocumentHandler();
    }

    return handler;
  }
View Full Code Here

        serializer.getSerializerObject().setOutputFormat(props.getProperties());
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "xml" ) )
      {
        FormatterToXML serializer = new FormatterToXML(writer);
        serializer.getSerializerObject().setOutputFormat(props.getProperties());
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "text" ) )
      {
        FormatterToText serializer = new FormatterToText(writer);
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else
      {
        handler = null;
      }
    }
   
    if(null == handler)
    {
      String method = format.getMethod();
      org.apache.xml.serialize.SerializerFactory factory = org.apache.xml.serialize.SerializerFactory.getSerializerFactory(method);
      org.apache.xml.serialize.Serializer serializer = factory.makeSerializer(writer, format);
      handler = serializer.asDocumentHandler();
    }

    return handler;
  }
View Full Code Here

        serializer.getSerializerObject().setOutputFormat(props.getProperties());
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "xml" ) )
      {
        FormatterToXML serializer = new FormatterToXML(ostream);
        serializer.getSerializerObject().setOutputFormat(props.getProperties());
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "text" ) )
      {
        String encoding = format.getEncoding();
        if(null == encoding)
        {
          try
          {
            encoding = System.getProperty("file.encoding");
            encoding = (null != encoding) ?
                       org.apache.xalan.serialize.Encodings.convertJava2MimeEncoding( encoding ) : "ASCII";
            if(null == encoding)
            {
              encoding = "ASCII";
            }
          }
          catch(SecurityException se)
          {
            encoding = "ASCII";
          }
        }

        //this.m_encoding =   encoding;

        String javaEncoding = org.apache.xalan.serialize.Encodings.convertMime2JavaEncoding(encoding);

        Writer w = new OutputStreamWriter( ostream, javaEncoding );
        ((ParserAdapter)handler).setContentHandler(new FormatterToText(w).getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "xhtml" ) )
      {
        handler = new XMLSerializer(ostream, format);
        //handler = Serializer.makeSAXSerializer(ostream, format);
      }
      else
      {
        handler = new XMLSerializer(ostream, format);
        //handler = Serializer.makeSAXSerializer(ostream, format);
      }
    }
    if(null == handler)
    {
      String method = props.getProperty(OutputKeys.METHOD);
      org.apache.xml.serialize.SerializerFactory factory = org.apache.xml.serialize.SerializerFactory.getSerializerFactory(method);
      org.apache.xml.serialize.Serializer serializer = factory.makeSerializer(ostream, format);
      handler = serializer.asDocumentHandler();
    }

    return handler;
  }
View Full Code Here

    processor.process(xmlID, stylesheetID, resultTarget);

    // Use the FormatterToXML and TreeWalker to print the DOM to System.out
    // Note: Not yet sure how to get the Xerces Serializer to  handle
    // arbitrary nodes.
    FormatterToXML fl = new FormatterToXML(System.out);
    TreeWalker tw = new TreeWalker(fl);
    tw.traverse(out);
  }
View Full Code Here

        nl = XPathAPI.selectNodeList(root, xpath);
       
        // Use the FormatterToXML class right not instead of
        // the Xerces Serializer classes, because I'm not sure
        // yet how to make them handle arbitrary nodes.
        FormatterToXML fl = new FormatterToXML(System.out);
        TreeWalker tw = new TreeWalker(fl);
        int n = nl.getLength();
        for(int i = 0; i < n; i++)
        {
          tw.traverse(nl.item(i));
          // We have to do both a flush and a flushWriter here,
          // because the FormatterToXML rightly does not flush
          // until it get's an endDocument, which usually will
          // not happen here.
          fl.flush();
          fl.flushWriter();
        }
      }
      catch (Exception e2)
      {
        System.err.println("selectNodeList threw: " + e2.toString() + " perhaps your xpath didn't select any nodes");
View Full Code Here

        serializer.getSerializerObject().setOutputFormat(props.getProperties());
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "xml" ) )
      {
        FormatterToXML serializer = new FormatterToXML(writer);
        serializer.getSerializerObject().setOutputFormat(props.getProperties());
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else if ( format.getMethod().equalsIgnoreCase( "text" ) )
      {
        FormatterToText serializer = new FormatterToText(writer);
        ((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
      }
      else
      {
        handler = null;
      }
    }
   
    if(null == handler)
    {
      String method = format.getMethod();
      org.apache.xml.serialize.SerializerFactory factory = org.apache.xml.serialize.SerializerFactory.getSerializerFactory(method);
      org.apache.xml.serialize.Serializer serializer = factory.makeSerializer(writer, format);
      handler = serializer.asDocumentHandler();
    }

    return handler;
  }
View Full Code Here

TOP

Related Classes of org.apache.xalan.xpath.xml.FormatterToXML

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.