Package javax.xml.transform.sax

Examples of javax.xml.transform.sax.SAXTransformerFactory.newTransformer()


            StreamResult result = new StreamResult(writer);

            // Set up the transformer to process the SAX events generated
            // by the last filter in the chain
            Transformer transformer = stf.newTransformer();

            // set outputproperties
            transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
            transformer.setOutputProperty(OutputKeys.METHOD, "xml");
            transformer.setOutputProperty(
View Full Code Here


      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

              transformer.transform(new DOMSource(xmlDoc, inFileName),
                                    new DOMResult(outNode));

              // Now serialize output to disk with identity transformer
              Transformer serializer = stf.newTransformer();
              serializer.setErrorListener(new DefaultErrorHandler());

              Properties serializationProps =
                stylesheet.getOutputProperties();
View Full Code Here

              Document outNode = docBuilder.newDocument();
              transformer.transform(new DOMSource(xmlDoc, inFileName),
                                    new DOMResult(outNode));
                                   
              // Now serialize output to disk with identity transformer
              Transformer serializer = stf.newTransformer();
              Properties serializationProps = stylesheet.getOutputProperties();
              serializer.setOutputProperties(serializationProps);
              serializer.transform(new DOMSource(outNode),
                                   new StreamResult(outputStream));
           }
View Full Code Here

        File stylesheet = new File(args[1]);
        Source styleSource = new StreamSource(stylesheet);

        try {

            transformer = factory.newTransformer(styleSource);

        } catch (TransformerConfigurationException ex) {
            System.err.println("unable to build transformer");
            ex.printStackTrace();
            System.exit(1);
View Full Code Here

               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

         // Get a Result to write the XML data.
         SAXResult sxResult = xmlDest.setResult(SAXResult.class);
         
         // Transform the Source to a Result by using the identity transform.
         SAXTransformerFactory stf = (SAXTransformerFactory) TransformerFactory.newInstance();
         Transformer identity = stf.newTransformer();
         identity.transform(sxSource, sxResult);

         // Insert the destination SQLXML object into the database.
         PreparedStatement psmt =
           con.prepareStatement(
View Full Code Here

                    getClass().getResourceAsStream(MODEL2TRANSLATION));
            if (xslt1.getInputStream() == null) {
                throw new FileNotFoundException(MODEL2TRANSLATION + " not found");
            }
            DOMResult domres = new DOMResult();
            Transformer transformer = tFactory.newTransformer(xslt1);
            transformer.transform(src, domres);
            final Node generated = domres.getNode();

            Node sourceDocument;
            if (resultExists) {
View Full Code Here

            Node sourceDocument;
            if (resultExists) {
                //Load existing translation file into memory (because we overwrite it later)
                src = new StreamSource(getTranslationFile().toURI().toURL().toExternalForm());
                domres = new DOMResult();
                transformer = tFactory.newTransformer();
                transformer.transform(src, domres);
                sourceDocument = domres.getNode();
            } else {
                //Simply use generated as source document
                sourceDocument = generated;
View Full Code Here

                StreamSource xslt2 = new StreamSource(
                        getClass().getResourceAsStream(MERGETRANSLATION));
                if (xslt2.getInputStream() == null) {
                    throw new FileNotFoundException(MERGETRANSLATION + " not found");
                }
                transformer = tFactory.newTransformer(xslt2);
                transformer.setURIResolver(new URIResolver() {
                    public Source resolve(String href, String base) throws TransformerException {
                        if ("my:dom".equals(href)) {
                            return new DOMSource(generated);
                        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.