[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

SV: using mode-values within a template

Subject: SV: using mode-values within a template
From: "bryan" <bry@xxxxxxxxxx>
Date: Wed, 1 May 2002 21:56:59 +0200
template mode values
>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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.