Reputation: 457
Hi my xml looks like this
<Component name="super.useful.component">
<StringValue name="component.title.1">
<Value>some value</Value>
</StringValue>
<StringValue name="component.title.2">
<Value>some more value</Value>
</StringValue>
</Component>
all i want to do is to have the name as parameter.
My xsl looks like this:
<xsl:call-template name="showComponents">
<xsl:with-param name="container" select="//Component/StringValue[@name????]/>
</xsl:call-template
so when i call it , it can have the both names of the components.
<xsl:template name="showComponents">
<xsl:param name="container" />
<xsl:for-each select="Component[@name='$container']>
//do stuff here
Upvotes: 1
Views: 103
Reputation: 111521
Seems like you got part of your answer already from @svasa, but also note that you almost certainly not what you want
<xsl:for-each select="Component[@name='$container']>
but rather
<xsl:for-each select="Component[@name=$container]>
otherwise you'll be testing literally against the string, '$container'
, without variable evaluation.
Upvotes: 1
Reputation: 14228
I think you are fumbling upon the xpath to get the attribute name
for StringValue
elements. If that is the case, the xpath selector will be :
//StringValue/@name
Upvotes: 1