0

I don't know much about XSLT, but need to check the feasibility of a requirement. I know that using XSLT we can transform one document into another document with possibly different tag names and all.

Is it possible to generate 2 different output files for two different inputs using a single XSLT file? I have the liberty to use any java APIs if avaliable.

Kindly let me know.

5
  • Not sure what you mean by "generate 2 different output files for two different inputs". A single transformation has only a single input (though it can access other documents). Commented Jul 10, 2020 at 11:18
  • I mean one XSLT file contains rules that do 1 kind of transformation, Is it possible that multiple transformation formulaes can be combined in a single file? Example, if condition is true, then output to file A with tag name as <english>, else if condition is false, output to file B with tag name as <german> Commented Jul 10, 2020 at 12:09
  • If your XSLT engine supports XSLT2+ you can use <xsl:result-document>. saxonica.com/html/documentation/xsl-elements/… Commented Jul 10, 2020 at 13:21
  • it is definitely possible, with one reservation: at least in XSLT 1.0, the result will always be File A. The contents of the file can be vastly different based on the input, but the result is written to a file by the calling application, not by the XSL transformation. Commented Jul 10, 2020 at 13:33
  • @Ankit You can pass <xsl:param> parameters at both local (template) and global (xslt) levels to control/customize the transformation. Commented Jul 10, 2020 at 16:43

1 Answer 1

1

XSLT is no different from any other language here. If there's a lot of commonality between the two tasks then it's worth writing one stylesheet that does both. If there's very little commonality then it's simpler to have two completely separate stylesheet. If there's an overlap - say 50% shared functionality, then you can put the shared code in a module that is imported from two different stylesheets.

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

Comments

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.