Note that there are some explanatory texts on larger screens.

plurals
  1. POXPath functions URL with fn prefix does not work
    primarykey
    data
    text
    <p>Following XLST code works fine :-</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt; &lt;xsl:template match="/"&gt; &lt;xsl:for-each select="bookstore/book"&gt; &lt;xsl:if test="starts-with(author, 'W')"&gt; &lt;!-- Line 1 --&gt; &lt;xsl:value-of select="title" /&gt; &amp;#160; by &lt;xsl:value-of select="author" /&gt; &lt;br/&gt; &lt;/xsl:if&gt; &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>Here I am directly using <a href="http://www.w3schools.com/xsl/xsl_functions.asp#string" rel="nofollow">XPath String function</a> starts-with() in Line 1.</p> <p>Now, as per <a href="http://www.w3schools.com/xsl/xsl_functions.asp" rel="nofollow">W3Schools</a>, adding the namespace for XPath functions (<a href="http://www.w3.org/2005/xpath-functions" rel="nofollow">http://www.w3.org/2005/xpath-functions</a>), the following code does not work :-</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions" version="1.0"&gt; &lt;xsl:template match="/"&gt; &lt;xsl:for-each select="bookstore/book"&gt; &lt;xsl:if test="fn:starts-with(author, 'W')"&gt; &lt;!-- Line 2 --&gt; &lt;xsl:value-of select="title" /&gt; &amp;#160; by &lt;xsl:value-of select="author" /&gt; &lt;br/&gt; &lt;/xsl:if&gt; &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>Here, I am using the XPath function with its prefix attached to the namespace. </p> <p>IE shows that "Error: Namespace '<a href="http://www.w3.org/2005/xpath-functions" rel="nofollow">http://www.w3.org/2005/xpath-functions</a>' does not contain any functions" I checked the URL and it does have functions.</p> <p>Where am I going wrong? And if I can use all XPath functions with Transform URL itself, then why is a separate URL for XPath functions is provided?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload