0

I want to modify some element values like font size,color in xslt through java. I tried with following java code

File xslFile = new File("D:/header.xsl");
     System.out.println(xslFile.getPath());
     javax.xml.transform.Source xsltSource = new javax.xml.transform.stream.StreamSource(xslFile); 
     javax.xml.transform.TransformerFactory transformerFactory = javax.xml.transform.TransformerFactory.newInstance();
     javax.xml.transform.Transformer xsltTransformer = transformerFactory.newTransformer(xsltSource);
     xsltTransformer.setParameter("clr", "red");

The java code building successfully but the value is not reflecting into xsl stylesheet.

1
  • Have a look at Apache POI Commented Feb 20, 2015 at 11:20

1 Answer 1

1

Using parameter passing this way does not change the original stylesheet, just the in memory representation of it. But, assuming that you have a

<xsl:parameter name="clr">blue</xsl:parameter>

declaration at the top level of your stylesheet, your code would set the value of that parameter to red.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your suggestion. I tried this but still it is not working.
We need more details. Show us (relevant parts of) your style sheet, your input XML document and the expected result.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.