Altova Mailing List Archives>Archive Index >xsl-list Archive Home >Recent entries >Thread Prev - >Thread Next - Re: [xsl] Help moving away from named templates [xsl] Help moving away from named templatesTo: Date: 5/2/2007 3:19:00 PM Hey there,
I'm trying to reorganize my xsl application to make more use of the
template match attribute. I mostly transform XML documents which are
created based on SQL query results. For the time being, my XSL calls a
named template to display this profile. I can think of two
alternatives (illustrated below). If someone has a better one I am all
ears!
Sample XML-------------
<Records>
<Record>
<firstName>Steve</firstName>
<customerID>999</custID>
</Record>
</Records>
--------------------------------
1) To display their profile I *could* do:
<xsl:apply-templates match="Records/Record/node()[name()='firstName']"/>
and in most cases this would work, but of course this would conflict
with any other customer info that also contained 'firstName' (display
Emergency Contact info, for example, would have a 'firstName' and thus
conflict). I could make it so it checked for more than the firstName,
but this a nightmare in the making. Am I wrong?
2) At the time of XML generation I could include a node indicating
which template needed to be displayed, but while this simplifies XSL
it doesn't seem to simplify program code.
Example:
<Records>
<template>customerProfile</template>
<Record>
<etc />
<etc />
</Record>
</Records>
Then do <xsl:apply-templates
match="Records[template='customerProfile']/Record" />
The problem with this solution is that it doesn't seem to reduce
complexity, only to shuffle it away from XSL.
Thanks!
-Steve | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
