[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Help moving away from named templates

Subject: Help moving away from named templates
From: Steve <subsume@xxxxxxxxx>
Date: Wed, 2 May 2007 11:18:24 -0400
 Help moving away from named templates
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.