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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--