• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

selecting the XPath for ONE element...using for-each construct!

 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(Sorry for being vague due to business reasons)
I have a cascading template calls and based on some some
business logic I select a specific element in my input XML
file. I then need to call some templates by selecting
this element.
I am currently using the "for-each" construct and the "select"
attribute to select the ONE element. See pseudo-code below...
Wondering if there is a better way to do this...
<xsl:variable name="TheElement" select="key('businessKey', $criteria)"/>
<!-- So I selected the element
Some other processing follows...
-->
<xsl:for-each select="$TheElement">
<xsl:call-template name="Level1Template>
<xsl:with-param .../> <!-- being brief -->
</xsl:call-template>
</xsl:for-each>
<!--
Some other processing follows...
-->
The template called above inturn calls other templates.
As I mentioned I am doing this ONLY to select the
XPath of TheElement so that processing of the
subsequent templates is easy.
Additionally, I can positively say that the key
guarentees to return ONE and ONLY ONE element.
Is the for-each construct the best way to do this task ?
Any help is appreciated.
Thanks.
- madhav............it works fine, but is there a better way!
 
reply
    Bookmark Topic Watch Topic
  • New Topic