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]
Other format: [Raw text]

SV: using mode-values within a template



>does anybody know whether there is a possibility to get the value of a
mode?? I want to use the mode-value within the 
>template it belongs to.

You could use the document() function, but it can be somewhat painful,
the question is if you need a very self-aware type stylesheet or not,
probably you don't so it makes just as much sense to do as Tom Weissmann
suggested and add in a variable in each template where you need to know
the mode.
Anyway here's an incomplete example just to give some sort of idea(am
not testing and seriously overdosed on bad coffee, hope I don't commit a
howler) :)
Lets assume a global parameter

<xsl:param name="modes">
<xsl:for-each select="document('')//@mode"><!-- since this is an example
am using very process intensive xpaths-->
<mode name="{name()}"><xsl:value-of
select="parent::xsl:template/@match"/></mode>
</xsl:for-each>
</xsl:param>

So if you have the following

<xsl:template match="match1" mode="prime">
....
</xsl:template>
<xsl:template match="match2" mode="secondary">

</xsl:template>

The parameter $modes should hold a nodeset that evaluates to

<mode name="prime">match1</mode>
<mode name="secondary">match2</mode>

Can try it with a node-set function
<xsl:template match="/">
<xsl:for-each select="msxsl:node-set($modes)/mode">
<h1>The mode is <xsl:value-of select="@name"/></h1>
<p>while the match is <xsl:value-of select="."/></p>
</xsl:for-each>
</xsl:template>


 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]