The following XLST code works fine: -
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:for-each select="bookstore/book"> <xsl:if test="starts-with(author, 'W')"> <xsl:value-of select="title" />   by <xsl:value-of select="author" /> <br/> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Here, I directly use the XPath String function starts with () in line 1.
Now, according to W3Schools , adding a namespace for XPath functions ( http://www.w3.org/2005/xpath-functions ), the following code does not work: -
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions" version="1.0"> <xsl:template match="/"> <xsl:for-each select="bookstore/book"> <xsl:if test="fn:starts-with(author, 'W')"> <xsl:value-of select="title" />   by <xsl:value-of select="author" /> <br/> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Here I use the XPath function with my prefix attached to the namespace.
IE shows that "Error: namespace" http://www.w3.org/2005/xpath-functions ' does not contain any functions "I checked the URL and it has functions.
Where am I mistaken? And if I can use all XPath functions with the transform URL itself, then why is there a separate URL for XPath functions?
source share