In your example, the "named" templates are different here. For example, if you want to create the same two elements in different places, create a named template this way
<xsl:template name="exampleTemplate"> <xsl:element name="wsb:codigoOperacion"> <xsl:value-of select="STDR2_DATOS_CONTROL/STDR2_CODOPE" /> </xsl:element> <xsl:element name="wsb:numeroOperacion"> <xsl:value-of select="STDR2_DATOS_CONTROL/STDR2_NUMOPEBCO" /> </xsl:element> </xsl:template>
Then, to create these two elements, simply call the template as follows:
<xsl:call-template name="exampleTemplate" />
And this!
Notice, like functions, you can also pass parameters to templates.
<xsl:template name="example"> <xsl:param name="value" /> Value is <xsl:value-of select="$value" /> </xsl:template> <xsl:call-template name="example"> <xsl:with-param name="value" select="element" /> </xsl:call-template>
As an aside, there is no need to use xsl: element to create an element, if you use a static name, just write the element name directly. So instead
<xsl:element name="wsb:numeroOperacion"> <xsl:value-of select="STDR2_DATOS_CONTROL/STDR2_NUMOPEBCO" /> </xsl:element>
Just do it
<wsb:numeroOperacion> <xsl:value-of select="STDR2_DATOS_CONTROL/STDR2_NUMOPEBCO" /> </wsb:numeroOperacion>
Tim c source share