Hoi Wong wrote:
> <xsl:template name="patientData">
> <birthyear>
> <xsl:value-of
> select="document('rpt_pat.xml')//parameter[@name='PatientBirthYear']"/>
> </birthyear>
> <gender>
> <xsl:value-of
> select="document('rpt_pat.xml')//parameter[@name='PatientGender]"/>
> </gender>
> </xsl:template>
>
>
> Instead of specifying document('rpt_pat.xml') every time using absolute
> paths, I could have used <xsl:for-each select=document('rpt_pat.xml')>.
> However, I'd like to avoid using this syntax because there's only one
> instance of document('rpt_pat.xml') node. Using <xsl:for-each> can lead to
> whoever that reads my XSLT scripts into thinking that there are multiple
> instances of the document('rpt_pat.xml') node, adding confusion to the
> already huge chaos.
I don't think there is a way to change the current node without using
apply-templates or for-each. If you want to shorten the code then using
a variable could do e.g.
<xsl:template name="patientData">
<xsl:variable name="pat_doc" select="document('rpt_pat.xml')"/>
<birthyear>
<xsl:value-of
select="$pat_doc//parameter[@name='PatientBirthYear']"/>
</birthyear>
<gender>
<xsl:value-of
select="$pat_doc//parameter[@name='PatientGender]"/>
</gender>
</xsl:template>
--
Martin Honnen
http://JavaScript.FAQTs.com/