[thelist] XSL: current node question

Mike Migurski mike at cloudfactory.org
Fri Mar 30 11:08:37 CST 2001


Hi all,

I'm in the process of learning XSL, and I'm running into a really silly
roadblock. It seems to me that this should be a very easy problem to
solve, yet I can find no mention of it in Bradley's XSL Companion.

OK, so here's the context:

I have an XML document with three different elements valid on a given
level, let's call them Anne, Betty, and Cindy:

	<root>
		<anne>
			...
		</anne>
		<betty>
			...
		</betty>
		<cindy>
			...
		</cindy>
	</root>

I want them all to be treated equally, by a template like the following:

	<xsl:template match="anne|betty|cindy">
		<div class="...">
			[more stuff in here]
		</div>
	</xsl:template>

what do I do if I want the class on that <div> to be anne, or betty, or
cindy, depending on the context? But still have it processed via one
template? I am currently doing this:

	<xsl:template match="anne">
	        <div class="anne">  
	                [more stuff in here]
	        </div>
	</xsl:template>

	<xsl:template match="betty">
	        <div class="betty">  
	                [more stuff in here]
	        </div>
	</xsl:template>

	<xsl:template match="cindy">
	        <div class="cindy">  
	                [more stuff in here]
	        </div>
	</xsl:template>

...but this seems like a back-asswards way of taking care of this.

any help would be appreciated,
-mike.


--------------------------------------------------------------------------
                   michal migurski     mike at cloudfactory.org
                  tel:415.385.1993     AIM:migurski
    http://www.viberation.com/mike     ICQ:47513232
--------------------------------------------------------------------------
"...one of the reasons that people tend to feel alienated from the
political process and from the media nowadays is a surfeit of images that
are all equivalent. We have so many mass-produced, commercially oriented
images, but very few individually produced images that come from a
thinking brain and address a thinking reader."
	- Francoise Mouly
--------------------------------------------------------------------------





More information about the thelist mailing list