XSLT for a XML inside a workflow in JAVA












0















I'm creating an integration solution with Java that filters and modify huge XML files. Those XML files are inputted as a payload document through the solution and to do a big filter in the parts that are interesting for me I want to use XSLT stylesheet.
My difficult is that the default Java solution for this does not work for me (XSLT processing with Java?) as I do not want to take the XML from the system, once it is already in the workflow of the solution, and I need the output source to stay in the workflow.



Element production = docX2.createElement("PRODUCTION");
try {
TransformerFactory factory = TransformerFactory.newInstance();
Source xslt = new StreamSource("slimmer.xslt");
Transformer transformer = factory.newTransformer(xslt);
Source text = new StreamSource((InputStream) docX1);
transformer.transform(text, new StreamResult((OutputStream) production));
} catch (Exception ex) {
Logger.getLogger(IntProcess.class.getName()).log(Level.SEVERE, null, ex);
}
root.appendChild(production);


docX1 is the XML input document that is flowing through the solution, and docX2 is the output document (both are Document class in Java). Production is a tag element from docX2.










share|improve this question























  • Are the used Document and Element classes or interfaces the W3C DOM ones? I don't understand the attempted cast (OutputStream) production. If you want to populate a DOM document or element node use a docs.oracle.com/javase/7/docs/api/javax/xml/transform/dom/… from that node.

    – Martin Honnen
    Nov 14 '18 at 16:37
















0















I'm creating an integration solution with Java that filters and modify huge XML files. Those XML files are inputted as a payload document through the solution and to do a big filter in the parts that are interesting for me I want to use XSLT stylesheet.
My difficult is that the default Java solution for this does not work for me (XSLT processing with Java?) as I do not want to take the XML from the system, once it is already in the workflow of the solution, and I need the output source to stay in the workflow.



Element production = docX2.createElement("PRODUCTION");
try {
TransformerFactory factory = TransformerFactory.newInstance();
Source xslt = new StreamSource("slimmer.xslt");
Transformer transformer = factory.newTransformer(xslt);
Source text = new StreamSource((InputStream) docX1);
transformer.transform(text, new StreamResult((OutputStream) production));
} catch (Exception ex) {
Logger.getLogger(IntProcess.class.getName()).log(Level.SEVERE, null, ex);
}
root.appendChild(production);


docX1 is the XML input document that is flowing through the solution, and docX2 is the output document (both are Document class in Java). Production is a tag element from docX2.










share|improve this question























  • Are the used Document and Element classes or interfaces the W3C DOM ones? I don't understand the attempted cast (OutputStream) production. If you want to populate a DOM document or element node use a docs.oracle.com/javase/7/docs/api/javax/xml/transform/dom/… from that node.

    – Martin Honnen
    Nov 14 '18 at 16:37














0












0








0








I'm creating an integration solution with Java that filters and modify huge XML files. Those XML files are inputted as a payload document through the solution and to do a big filter in the parts that are interesting for me I want to use XSLT stylesheet.
My difficult is that the default Java solution for this does not work for me (XSLT processing with Java?) as I do not want to take the XML from the system, once it is already in the workflow of the solution, and I need the output source to stay in the workflow.



Element production = docX2.createElement("PRODUCTION");
try {
TransformerFactory factory = TransformerFactory.newInstance();
Source xslt = new StreamSource("slimmer.xslt");
Transformer transformer = factory.newTransformer(xslt);
Source text = new StreamSource((InputStream) docX1);
transformer.transform(text, new StreamResult((OutputStream) production));
} catch (Exception ex) {
Logger.getLogger(IntProcess.class.getName()).log(Level.SEVERE, null, ex);
}
root.appendChild(production);


docX1 is the XML input document that is flowing through the solution, and docX2 is the output document (both are Document class in Java). Production is a tag element from docX2.










share|improve this question














I'm creating an integration solution with Java that filters and modify huge XML files. Those XML files are inputted as a payload document through the solution and to do a big filter in the parts that are interesting for me I want to use XSLT stylesheet.
My difficult is that the default Java solution for this does not work for me (XSLT processing with Java?) as I do not want to take the XML from the system, once it is already in the workflow of the solution, and I need the output source to stay in the workflow.



Element production = docX2.createElement("PRODUCTION");
try {
TransformerFactory factory = TransformerFactory.newInstance();
Source xslt = new StreamSource("slimmer.xslt");
Transformer transformer = factory.newTransformer(xslt);
Source text = new StreamSource((InputStream) docX1);
transformer.transform(text, new StreamResult((OutputStream) production));
} catch (Exception ex) {
Logger.getLogger(IntProcess.class.getName()).log(Level.SEVERE, null, ex);
}
root.appendChild(production);


docX1 is the XML input document that is flowing through the solution, and docX2 is the output document (both are Document class in Java). Production is a tag element from docX2.







java xml xslt






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 16:17









Rodolfo BerleziRodolfo Berlezi

12




12













  • Are the used Document and Element classes or interfaces the W3C DOM ones? I don't understand the attempted cast (OutputStream) production. If you want to populate a DOM document or element node use a docs.oracle.com/javase/7/docs/api/javax/xml/transform/dom/… from that node.

    – Martin Honnen
    Nov 14 '18 at 16:37



















  • Are the used Document and Element classes or interfaces the W3C DOM ones? I don't understand the attempted cast (OutputStream) production. If you want to populate a DOM document or element node use a docs.oracle.com/javase/7/docs/api/javax/xml/transform/dom/… from that node.

    – Martin Honnen
    Nov 14 '18 at 16:37

















Are the used Document and Element classes or interfaces the W3C DOM ones? I don't understand the attempted cast (OutputStream) production. If you want to populate a DOM document or element node use a docs.oracle.com/javase/7/docs/api/javax/xml/transform/dom/… from that node.

– Martin Honnen
Nov 14 '18 at 16:37





Are the used Document and Element classes or interfaces the W3C DOM ones? I don't understand the attempted cast (OutputStream) production. If you want to populate a DOM document or element node use a docs.oracle.com/javase/7/docs/api/javax/xml/transform/dom/… from that node.

– Martin Honnen
Nov 14 '18 at 16:37












1 Answer
1






active

oldest

votes


















0














I solve it. With the help of this one Transform XML with XSLT in Java using DOM
My solution is



Element production = docX2.createElement("PRODUCTION");
try {
TransformerFactory factory = TransformerFactory.newInstance();
Source xslt = new StreamSource("slimmer.xslt");
Transformer transformer = factory.newTransformer(xslt);
Source text = new DOMSource(docX1);
transformer.transform(text, new DOMResult(production));
} catch (Exception ex) {
Logger.getLogger(IntProcess.class.getName()).log(Level.SEVERE, null, ex);
}
root.appendChild(production);


The problem was to try using Stream instead of a DOM source.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53304551%2fxslt-for-a-xml-inside-a-workflow-in-java%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I solve it. With the help of this one Transform XML with XSLT in Java using DOM
    My solution is



    Element production = docX2.createElement("PRODUCTION");
    try {
    TransformerFactory factory = TransformerFactory.newInstance();
    Source xslt = new StreamSource("slimmer.xslt");
    Transformer transformer = factory.newTransformer(xslt);
    Source text = new DOMSource(docX1);
    transformer.transform(text, new DOMResult(production));
    } catch (Exception ex) {
    Logger.getLogger(IntProcess.class.getName()).log(Level.SEVERE, null, ex);
    }
    root.appendChild(production);


    The problem was to try using Stream instead of a DOM source.






    share|improve this answer




























      0














      I solve it. With the help of this one Transform XML with XSLT in Java using DOM
      My solution is



      Element production = docX2.createElement("PRODUCTION");
      try {
      TransformerFactory factory = TransformerFactory.newInstance();
      Source xslt = new StreamSource("slimmer.xslt");
      Transformer transformer = factory.newTransformer(xslt);
      Source text = new DOMSource(docX1);
      transformer.transform(text, new DOMResult(production));
      } catch (Exception ex) {
      Logger.getLogger(IntProcess.class.getName()).log(Level.SEVERE, null, ex);
      }
      root.appendChild(production);


      The problem was to try using Stream instead of a DOM source.






      share|improve this answer


























        0












        0








        0







        I solve it. With the help of this one Transform XML with XSLT in Java using DOM
        My solution is



        Element production = docX2.createElement("PRODUCTION");
        try {
        TransformerFactory factory = TransformerFactory.newInstance();
        Source xslt = new StreamSource("slimmer.xslt");
        Transformer transformer = factory.newTransformer(xslt);
        Source text = new DOMSource(docX1);
        transformer.transform(text, new DOMResult(production));
        } catch (Exception ex) {
        Logger.getLogger(IntProcess.class.getName()).log(Level.SEVERE, null, ex);
        }
        root.appendChild(production);


        The problem was to try using Stream instead of a DOM source.






        share|improve this answer













        I solve it. With the help of this one Transform XML with XSLT in Java using DOM
        My solution is



        Element production = docX2.createElement("PRODUCTION");
        try {
        TransformerFactory factory = TransformerFactory.newInstance();
        Source xslt = new StreamSource("slimmer.xslt");
        Transformer transformer = factory.newTransformer(xslt);
        Source text = new DOMSource(docX1);
        transformer.transform(text, new DOMResult(production));
        } catch (Exception ex) {
        Logger.getLogger(IntProcess.class.getName()).log(Level.SEVERE, null, ex);
        }
        root.appendChild(production);


        The problem was to try using Stream instead of a DOM source.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 16:53









        Rodolfo BerleziRodolfo Berlezi

        12




        12
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53304551%2fxslt-for-a-xml-inside-a-workflow-in-java%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Lugert, Oklahoma