Re: [xsl] contains() function to search general in xslt

Subject: Re: [xsl] contains() function to search general in xslt
From: "Ragulf Pickaxe" <ragulf.pickaxe@xxxxxxxxxxx>
Date: Mon, 05 Dec 2005 13:09:08 +0100
Hi Raj,

		<xsl:if
test="contains(child::Box/@name,'Application')">
			<xsl:text>Box with Application is avaialble
</xsl:text>

Using the above code,
I got the output Box with Application is not
available.. Can tell me the reason? why it is not
checking the Box with a name 'Application'..

If you read up on contains, this function requires a value and a substring.
If value is not a string, it is converted to one, using the rules for string conversion.


child::Box/@name (which can be written much shorter as simply Box/@name - as the child axis is the default axis), returns a nodeset containing all the found name attributes. The string conversion rule explicitly states that it takes the string-value of the first node in document order. The first Box/@name you encounter has a string value of "header1", which is not what you are testing for.

You should be able to do something like:

<xsl:template match="Box[contains(@name,'Application')]">
 <xsl:text>Box with Application is avaialble</xsl:text>
</xsl:template>

So in your for-each, apply templates on Box elements, and have a template for each of your conditions.

I hope this helps.

Regards,
Ragulf Pickaxe :-)

_________________________________________________________________
Undge pop-ups med MSN Toolbar -  http://toolbar.msn.dk/ hent den gratis!

Current Thread