I'm trying to find a solution for how to replace standard 3-line code of type "call-template" - "with-param" with one single line.
For example I have the following piece of code:
<xsl:call-template name="do_job">
<xsl:with-param name="str">data1</xsl:with-param>
</xsl:call-template>
that i want to replace with something like this:
<myNs:tr name="data1"/>
Beside Dimitre excellent answer and recomendation, you could something like this stylesheet:
With this input:
Output:
Note: Also I recomend to you to read Dimitre Novatchev's FXSL in http://fxsl.sf.net/
As Dimitre already said, macros are not supported. You could however generate your XSLT on the fly from an XML document containing macros and then run the generated XSLT.
A stylesheet that would create your XSLT would look like this:
It is not possible to create and use macros in XSLT.
In XSLT 2.0 one can write functions using the
<xsl:function>
instruction. Then a function is referenced in any XPath expression:Here is a full example:
when this transformation is applied on any XML document (not used), the correct result is produced: