title: String functions missing in Xalan 2.7, java.lang.String used instead?
body: <p>I am using Xalan 2.7.0 (as bundled with Apache FOP 1.0) and have problems when using string functions.</p>
  
  <p>The line <code>&lt;xsl:value-of select="fn:replace('test', 't', '*')"/&gt;</code> results in this exception:</p>
  
  <pre><code>javax.xml.transform.TransformerException: java.lang.IllegalArgumentException: argument type mismatch
      at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:302)
  </code></pre>
  
  <p><code>&lt;xsl:value-of select="fn:string-length('foobar')"/&gt;</code> results in:</p>
  
  <pre><code>javax.xml.transform.TransformerException: java.lang.NoSuchMethodException: For extension function, could not find method java.lang.String.stringLength([ExpressionContext,] ).
      at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:302)
  </code></pre>
  
  <p>Now this is weird! Why does Xalan look for a <code>stringLength</code> function on <code>java.lang.String</code>? I tested <code>&lt;xsl:value-of select="fn:substring('foobar', 2, 3)"/&gt;</code>, and indeed: the result is <code>o</code>, so the arguments were used as <code>startIndex, endIndex</code> (like <code>java.lang.String.substring()</code>) instead of XPath's <code>fn:substring(string, start, length)</code> funcion.</p>
  
  <p>So I think that Xalan is somehow missing its XPath function library and using the regular String class instead. I confirmed this by calling the non-existing function <code>fn:index-of('foobar', 'bar')</code> which works fine and maps to <code>java.lang.String.indexOf(str)</code>.</p>
  
  <p>Why does Xalan do that? And how can I fix it?</p>
  
  <p>System info: Xalan uses the standard Mac OS X 10.6.4 Java version, 1.6.0_20.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Okay, leave aside the <code>replace()</code> function for a moment. Shouldn't Xalan, being an XSLT 1.0 processor, implement the <a href="http://www.w3.org/TR/xpath/#function-substring" rel="noreferrer">XPath 1.0 function substring</a> <code>(string, startIndex, length)</code> and not the <code>(string, startIndex, endIndex)</code> function I see in my expirements? Is it coincidence that this startIndex, endIndex function looks like the substring method of <code>java.lang.String</code>?</p>
  
  <p>And why do I get a NoSuchMethodError when I use the <code>fn:string-length</code> function?</p>
  
  <p>Something's wrong here, and it clearly isn`t about XPath 1.0 vs 2.0...</p>