All,
I have an XML file which I transform it using an XSLT document to another XML.
Can I define another set of transformations in the same XSLT file to be applied in the result XML of the first transformation?
Thanks,
MK
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes.
I. This XSLT 1.0 transformation:
when applied on this XML document:
produces:
Do note:
Two transformations are actually performed, the second is performed on the result of the first.
The result of the first transformation is the content of the variable
$vrtfPass1.In XSLT 1.0 the type of variables that contain dynamically generated (temporary) XML trees (XML document or XML fragment) is RTF (Result-Tree-Fragment). No XPath operations are possible on an RTF — it needs to be converted to a regular node-set using the extension function
xxx:node-set(), which is provided by the vast majority of XSLT 1.0 processor vendors. In this example exslt:node-set() is used, because EXSLT is implemented by many different vendors.The second transformation is applied on the result of the first:
<xsl:apply-templates select="ext:node-set($vrtfPass1)/*" mode="pass2"/>. A separatemodeis used in order to cleanly separate the code of the two transformations.The first transformation multiplies each
num/text()by 2. The second transformation increments eachnum/text(). The result is2*.+1II. This XSLT 2.0 transformation:
when applied on the same XML document, produces the same wanted and correct result.
Do note: In XSLT 2.0/XPath 2.0 the RTF type has been abolished. No
xxx:node-set()extension function is needed.