title: Using functions in XSLT
body: <p>I'm learning XSLT. These questions may be obvious, but I'm really stuck now.
  Oxygen returns the following two kind of errors:</p>
  
  <ol>
  <li><blockquote>
    <p>Namespace is not declared for 'ownFunction()'. ("undeclared namespace prefix {xs}")</p>
  </blockquote></li>
  <li><p><blockquote>unknown system function index-of-string()</blockquote> The XSLT function <code>index-of-string</code> I got from <a href="http://www.xsltfunctions.com/xsl/functx_index-of-string.html" rel="nofollow">this website</a> doesn't seems to be recognized</p></li>
  </ol>
  
  <p>This is a simplified version of the XSL file:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"     xmlns:foo="http://www.wathever.com"&gt;
  &lt;xsl:output method="xml" /&gt;
  
    &lt;xsl:function name="foo:ownFunction" as="xs:string"&gt;
      &lt;xsl:param name="string" as="xs:string"/&gt;
  
          &lt;xsl:choose&gt;
  
            &lt;xsl:when test='contains($string,"src=")'&gt;
              &lt;xsl:variable name="position"&gt;&lt;xsl:value-of select="index-of-string($string,'src=')"/&gt;+&lt;xsl:number value="10"/&gt;&lt;/xsl:variable&gt;
              &lt;xsl:variable name="partString"&gt;&lt;xsl:value-of select="substring($string,$position)"/&gt;&lt;/xsl:variable&gt;
              &lt;xsl:variable name="length"&gt;&lt;xsl:value-of select="index-of-string($partString,'quot;')"/&gt; - &lt;xsl:number value="2"/&gt;&lt;/xsl:variable&gt;
              &lt;xsl:value-of select="substring($partString,1,$length)"/&gt;
            &lt;/xsl:when&gt;
  
            &lt;xsl:otherwise&gt;
              &lt;xsl:value-of select="hotpot-jmatch-file/data/title"/&gt;
            &lt;/xsl:otherwise&gt;
  
          &lt;/xsl:choose&gt;
    &lt;/xsl:function&gt;
  
    &lt;xsl:template match="/"&gt;
      &lt;data&gt;
        &lt;title&gt;
          &lt;xsl:variable name="string"&gt;&lt;xsl:value-of select="hotpot-jmatch-file/data/title"/&gt;&lt;/xsl:variable&gt;
          &lt;xsl:value-of select="foo:ownFunction($string)"/&gt;
        &lt;/title&gt;
      &lt;/data&gt;
    &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>