1

Got this error "Cannot find a matching 1-argument function named {urn:rend-scripts}GetImageString().” when invoking C# Method GetImageString(String) from XSLT using Saxon9ee Processor. please help me how to resolve this.

Code:

 <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:xpp="http://www.sdl.com/xpp"  xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:rend="urn:rend-scripts" exclude-result-prefixes="xsl xpp msxsl rend">
 <msxsl:script language="c#" implements-prefix="rend">
 <msxsl:assembly href="C:\Users\velagasx\Desktop\dll4rtf\System.IO.dll"/>
 <msxsl:assembly href="C:\Users\velagasx\Desktop\dll4rtf\System.Drawing.dll"/>
 <msxsl:using namespace="System.IO"/>
 <msxsl:using namespace="System.Drawing"/>    
 <![CDATA[
    public string GetImageString(String path_to_image){
      MemoryStream stream = new MemoryStream();
      Image img = Image.FromFile(path_to_image);
      img.Save(stream, System.Drawing.Imaging.ImageFormat.Tiff);
      byte[] bytes = stream.ToArray();
      string output = BitConverter.ToString(bytes, 0).Replace("-", string.Empty);          
      return output;
      }
    ]]>

    <xsl:template match="img">
       <xsl:value-of select="rend:GetImageString(@path)"/>
    </xsl:template>

thanks

Srinadh

1
  • is this just a typing issue? Does it work with "rend:GetImageString('somethingFixed')" ? It could be you need to either a: convert the @path to a string before passing it in (maybe the text() function?), or b: have the method accept an XPathNodeIterator Commented Nov 20, 2013 at 13:32

1 Answer 1

1

msxsl:script in the namespace urn:schemas-microsoft-com:xslt is a proprietary extension element, originally supported by the various Microsoft MSXML versions, then enhanced with msxsl:assembly and msxsl:using for the Microsoft XslCompiledTransform. I don't think Saxon supports that extension element. If you want to use extensions with Saxon check http://www.saxonica.com/documentation/index.html#!extensibility/dotnetextensions.

Sign up to request clarification or add additional context in comments.

1 Comment

Correct, Saxon's approach to calling C# methods is quite different from Microsoft's. There's no standard in this area.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.