Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to put 2 separate XSL element templates for the same XML node?

Status
Not open for further replies.

SilverStray

Programmer
Oct 25, 2001
47
AU
Hi,

Since XSL is supposed to be for formatting XML data, is it possible for me to create 2 entirely different templates for the same XML node, or for the 'assyData' node as in the example below? And if so, how do I call which template?

Here is a compressed version of my XSL code:

<xsl:template match="/">
<xsl:if test="//step/name=='WIRE_BOND'">
<xsl:apply-templates select='assyData'/>
</xsl:if>

</xsl:template>

I'd like to add another if-test in the code above, which will check if the step name is DIE_BOND, and if so, it will call a different template for assyData, but how?

If it could be more helpful, i put below the sample XML code.

-<step>
<name>WIRE_BOND</name>
<desc>Wirebonding Process</desc>
-<assyStepData>
-<assyData>
<compType>WIRE</compType>
..more elements here...
</assyData>
-<assyData>
<compType>EPOXY</compType>
</assyData>
</assyStepData>
</step>

-<step>
<name>DIE_BOND</name>
<desc>Wirebonding Process</desc>
..more elements here...
</step>

Hope you could help!

Thanks!

J. Echavez
 
For the benefit of those who might be interested, and who might have missed this on their studies about XSL templates, I now found the solution to my problem.

There's an attribute of <xsl:apply-template> called 'mode' where I put the following:

<xsl:apply-templates select='assyData' mode='1'/>

And accordingly, my two XSL templates definition now includes the mode attribute too, as in

<xsl:template match="assyDate" mode="1">

which in my real code contains formatting for mode 1, and the other is

<xsl:template match="assyDate" mode="2">


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top