Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Help moving away from named templates

From: Steve <subsume@--------->
To:
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent