xsl-list
[Top] [All Lists]

Re: contains() function to search general in xslt

2005-12-05 05:09:08
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 :-)

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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--