Package javax.xml.transform.sax

Examples of javax.xml.transform.sax.SAXTransformerFactory


            if (tf == null)
                tf = TransformerFactory.newInstance();
            if (!tf.getFeature(SAXTransformerFactory.FEATURE))
                throw new JspTagException(
        Resources.getMessage("PARSE_NO_SAXTRANSFORMER"));
            SAXTransformerFactory stf = (SAXTransformerFactory) tf;
            th = stf.newTransformerHandler();
  }

  // produce a Document by parsing whatever the attributes tell us to use
  Document d;
  Object xmlText = this.xml;
View Full Code Here


               ProfileDOMFilter filter = new ProfileDOMFilter(profiles);
               filter.process(doc.getDocumentElement());

               // SAX event stream -> String
               StringWriter buffer = new StringWriter();
               SAXTransformerFactory tf = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
               TransformerHandler hd = tf.newTransformerHandler();
               StreamResult result = new StreamResult(buffer);
               hd.setResult(result);
               Transformer serializer = tf.newTransformer();
               serializer.setOutputProperty(OutputKeys.ENCODING, "UTF8");
               serializer.setOutputProperty(OutputKeys.INDENT, "yes");

               // Transform -> SAX event stream
               SAXResult saxResult = new SAXResult(new NoKernelNamespaceSAXFilter(hd));
View Full Code Here

      ProfileDOMFilter filter = new ProfileDOMFilter(profiles);
      filter.process(doc.getDocumentElement());

      // SAX event stream -> String
      StringWriter buffer = new StringWriter();
      SAXTransformerFactory tf = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
      TransformerHandler hd = tf.newTransformerHandler();
      StreamResult result = new StreamResult(buffer);
      hd.setResult(result);
      Transformer serializer = tf.newTransformer();
      serializer.setOutputProperty(OutputKeys.ENCODING, "UTF8");
      serializer.setOutputProperty(OutputKeys.INDENT, "yes");

      // Transform -> SAX event stream
      SAXResult saxResult = new SAXResult(new NoKernelNamespaceSAXFilter(hd));
View Full Code Here

        }
        if(outputProperties.get(OutputKeys.INDENT) == null){
            outputProperties.put(OutputKeys.INDENT, "yes");
        }
        StreamResult streamResult = new StreamResult(new OutputStreamWriter(out, enc));
        SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
        try{
            tf.setAttribute("indent-number", Integer.valueOf(2));
        } catch (IllegalArgumentException ignore){
            // ignore
        }
        try{
            hd = tf.newTransformerHandler();
        } catch (TransformerConfigurationException ex){
            throw new RuntimeException(ex);
        }
        Transformer serializer = hd.getTransformer();
        //System.err.println("Using "+serializer.getClass().getName());
View Full Code Here

      // --SAXTransformerFactory is an interface
      // --TransformerFactory is a concrete class
      // --TransformerFactory actually returns a SAXTransformerFactory instance
      // --We didn't care about that before, because we didn't use the
      // --SAXTransformerFactory extensions. But now we do, so we cast the result.
      SAXTransformerFactory stf =
        (SAXTransformerFactory) TransformerFactory.newInstance();
      XMLFilter filter1 = stf.newXMLFilter(new StreamSource(stylesheet1));
      XMLFilter filter2 = stf.newXMLFilter(new StreamSource(stylesheet2));

      // Wire the output of the reader to filter1
      // and the output of filter1 to filter2
      // --A filter is a kind of reader
      // --Setting the parent sets the input reader
      // --Since a filter is a reader, the "parent" could be another filter
      filter1.setParent(reader);
      filter2.setParent(filter1);

      // Set up the output stream
      StreamResult result = new StreamResult(System.out);
     
      // Set up the transformer to process the SAX events generated
      // by the last filter in the chain
      Transformer transformer = stf.newTransformer();
      SAXSource transformSource = new SAXSource(filter2, input);
      transformer.transform(transformSource, result);
    }
    catch (TransformerConfigurationException tce) {
      // Error generated by the parser
View Full Code Here

    }

    private TransformerHandler createTransformerHandler(FileOutputStream fileOuputStream)
            throws TransformerFactoryConfigurationError, TransformerConfigurationException,
            SAXException {
        SAXTransformerFactory transformerFact = (SAXTransformerFactory) SAXTransformerFactory
                .newInstance();
        TransformerHandler saxHandler = transformerFact.newTransformerHandler();
        saxHandler.getTransformer().setOutputProperty(OutputKeys.ENCODING, "UTF-8");
        saxHandler.getTransformer().setOutputProperty(OutputKeys.INDENT, "yes");
        saxHandler.setResult(new StreamResult(fileOuputStream));
        return saxHandler;
    }
View Full Code Here

                    streamSource.getSystemId());

            EntityResolver resolver = ConfigFactory.getDefaultInstance().
                    createRepositoryEntityResolver();

            SAXTransformerFactory factory = (SAXTransformerFactory)
                    transformerMetaFactory.createTransformerFactory();
            Source xslSource = stylesheet;
            TransformerHandler robotInDisguise =
                    factory.newTransformerHandler(xslSource);

            XMLReader reader = new com.volantis.xml.xerces.parsers.SAXParser();
            reader.setEntityResolver(resolver);
            reader.setContentHandler(robotInDisguise);
            reader.setDTDHandler(robotInDisguise);
View Full Code Here

        InputStream connectionInput = null;
        try {
            connectionInput = content.getInputStream();
            StreamSource xslSource = new StreamSource(connectionInput,
                    absoluteURI);
            SAXTransformerFactory factory = getTransformerFactory(isCompilable);
            factory.setErrorListener(this.getCollatingErrorListener());
            return factory.newTemplates(xslSource);
        } finally {
            // Ensure that we close the input stream
            if (connectionInput != null) {
                connectionInput.close();
            }
View Full Code Here

            ContentHandler handler = getNextProcess();
            for (int i = templatesList.size() - 1; i >= 0; i--) {
                Templates templates = (Templates) templatesList.get(i);

                Boolean compilable = (Boolean) compilableList.get(i);
                SAXTransformerFactory factory =
                        getTransformerFactory(compilable.booleanValue());

                try {
                    transformerHandler = factory.newTransformerHandler(templates);
                    for (int j = 0; j < paramNames.size(); j++) {
                        String name = (String) paramNames.get(j);
                        Object value = paramValues.get(j);
                        transformerHandler.
                                getTransformer().setParameter(name, value);
View Full Code Here

    return row;
  }

  private static ContentHandler getHtmlHandler(Writer writer)
          throws TransformerConfigurationException {
    SAXTransformerFactory factory = (SAXTransformerFactory)
            SAXTransformerFactory.newInstance();
    TransformerHandler handler = factory.newTransformerHandler();
    handler.getTransformer().setOutputProperty(OutputKeys.METHOD, "html");
    handler.setResult(new StreamResult(writer));
    return new ContentHandlerDecorator(handler) {
      @Override
      public void startElement(
View Full Code Here

TOP

Related Classes of javax.xml.transform.sax.SAXTransformerFactory

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.