Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 

Go Back   XSL - XML - RSS Forums > XSLForum: Main > XSL-XSD-XML and more

Tags:



Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-18-2008, 01:02 AM
David Carlisle
 
Posts: n/a

Default Re: [XSLT] How to establish a context node without <xsl:for-each>



Hoi Wong wrote:

> Instead of specifying document('rpt_pat.xml') every time using absolute
> paths,


as others have said you can't change the current node without for-each
or apply-templates, etc, however you could use a variable
<xsl:variable name="rpt" select="document('rpt_pat.xml')"/>
then you can use $rpt///parameter[@name='PatientBirthYear']

In xslt2 I'd do
<xsl:variable name="rpt" select="document('rpt_pat.xml')"/>
<xsl:key name="rpt" match="parameter" use="@name"/>
then


<xsl:template name="patientData">
<birthyear>
<xsl:value-of select="key('rpt','PatientBirthYear',$rpt)"/>
</birthyear>
<gender>
<xsl:value-of select="key('rpt','PatientGender',$rpt)"/>
</gender>
</xsl:template>

The third argument of key doesn't exactly change the current node but it
changes the effective node used for determing the key lookup, which has
more or less the same effect here.

David

--
http://dpcarlisle.blogspot.com
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Contact Us -|- XSL - XML - RSS Forums -|- Archive -|- Top -|-Rules/Disclaimer-|-Help/Support -|-Advertise
© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
All times are GMT. The time now is 12:01 PM.
Style Developed by Epic Designz