This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

resolving variables out of context?



Hiya XSL-List members,
 
If I have a template match like:

<xsl:template match="//xptr">
<xsl:variable name="doc" select="concat(../@src, '.xml')"/>
<xsl:variable name="fromID select="concat('B.', ../@src, '.', substring-before(substring-after(@from, 'ID('), ')'))"/>
<xsl:if test="@to">
<xsl:variable name="toID" select="concat('B.', ../@src, '.', substring-before(substring-after(@to, 'ID('), ')'))"/>
</xsl:if>

	<xsl:value-of select="$doc"/>
	<xsl:value-of select="$from"/>
<!-- The above two work -->
	<xsl:value-of select="$toID"/>
<!-- But this one does not -->
</xsl:template>

Is the $toID limited to use *only* within the <xsl:if>?  Is
there any way to declare it so that it can be used anywhere
within the <xsl:template match="//xptr"> as a whole?  (I.e.
I don't want to for the whole document, as it changes each
time an <xptr> is matched.)

What I want to acheive is the setting of the variables once
at the beginning of the template, and then have access to
them from within nested <xsl:when> statements, rather than
declaring said variable again and again and again for all
the different possibilities.  Any suggestions?

-James

-- 
James Cummings, James.Cummings@uea.ac.uk, http://www.uea.ac.uk/~q503
Cursus Project, School of Music, University of East Anglia,
Norwich, Norfolk, NR4 7TJ, UK



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]