Package javax.xml.transform

Examples of javax.xml.transform.TransformerFactory.newTransformer()


      throws TransformerException {
    StringWriter stringWriter = new StringWriter();
    StreamResult streamResult = new StreamResult(stringWriter);
    TransformerFactory transformerFactory = TransformerFactory
        .newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty(
        "{http://xml.apache.org/xslt}indent-amount", "2");
    transformer.setOutputProperty(OutputKeys.METHOD, "xml");
    transformer.transform(new DOMSource(document.getDocumentElement()),
View Full Code Here


        if(xslTransform == null) {
            throw new ScriptException("XSLT transform " + xslt + " not found");
        }
        try {
            final TransformerFactory tf = TransformerFactory.newInstance();
            final Transformer t = tf.newTransformer(new StreamSource(xslTransform));
            t.setParameter("pageTitle", pageTitle);
            t.setParameter("slingScriptPath", fullPath(request,SLING_JS_PATH));
            t.setParameter("jstScriptPath", fullPath(request, scriptPath + ".jst.js"));
            t.setParameter("defaultRendering", defaultRendering.toString());
            t.setParameter("jsonData", jsonData.toString());
View Full Code Here

    @Before
    public void setUp() throws Exception {
        collection = new CommonsXsdSchemaCollection();
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        transformer = transformerFactory.newTransformer();
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        documentBuilderFactory.setNamespaceAware(true);
        documentBuilder = documentBuilderFactory.newDocumentBuilder();
        XMLUnit.setIgnoreWhitespace(true);
    }
View Full Code Here

    @Before
    public void setUp() throws Exception {
        interceptor = new PayloadTransformingInterceptor();
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        transformer = transformerFactory.newTransformer();
        input = new ClassPathResource("transformInput.xml", getClass());
        output = new ClassPathResource("transformOutput.xml", getClass());
        xslt = new ClassPathResource("transformation.xslt", getClass());
        XMLUnit.setIgnoreWhitespace(true);
    }
View Full Code Here

  public static boolean doc2XmlFile(Document document, String filename) {
        boolean flag = true;
        try {
          
            TransformerFactory tFactory = TransformerFactory.newInstance();
            Transformer transformer = tFactory.newTransformer();
            DOMSource source = new DOMSource(document);
            StreamResult result = new StreamResult(new File(filename));
            transformer.transform(source, result);
        } catch (Exception ex) {
            flag = false;
View Full Code Here

  public static String getDocumentAsString(Resource resource)
      throws Exception {

    Document document = getDocument(resource);
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer transformer = tf.newTransformer();
    transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
    StringWriter writer = new StringWriter();
    transformer
        .transform(new DOMSource(document), new StreamResult(writer));
    String output = writer.getBuffer().toString().replaceAll("\n|\r", "");
View Full Code Here

  }

  public void dump(File output) {
    try {
      TransformerFactory transformerFactory = TransformerFactory.newInstance();
      Transformer transformer = transformerFactory.newTransformer();
      DOMSource source = new DOMSource(doc);
      StreamResult result = new StreamResult(output);
      transformer.transform(source, result);
    } catch (Exception e) {
      throw Throwables.propagate(e);
View Full Code Here

    DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
    Document document = builder.parse(new InputSource(new StringReader(originalServerXml)));
    document.normalize();

    TransformerFactory factory = TransformerFactory.newInstance();
    Transformer transformer = factory.newTransformer();
    StringWriter writer = new StringWriter();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.transform(new DOMSource(document.getDocumentElement()), new StreamResult(writer));
    return writer.toString().replace("\\s+\\n", "\\n");
  }
View Full Code Here

      URL url = getStylesheetURL();
      try {
        TransformerFactory transformerFactory = new TransformerFactoryImpl();
        transformerFactory.setURIResolver(uriResolver);
        Source source = new StreamSource(url.openStream(), url.toExternalForm());
        Transformer transformer = transformerFactory.newTransformer(source);

        if (!isShowXslMessages()) {
          Controller controller = (Controller) transformer;
          try {
            controller.makeMessageEmitter();
View Full Code Here

            ClassLoader classLoader = Thread.currentThread()
                                            .getContextClassLoader();

            TransformerFactory factory = TransformerFactory.newInstance();
            Transformer transformer = factory.newTransformer(new StreamSource(classLoader.getResourceAsStream(COPY_XSL)));


            DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
            dbfactory.setValidating(false);
            DocumentBuilder builder = dbfactory.newDocumentBuilder();
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.