Hi, Please help me on this....

My application opens a Word12 document (.docx extension) programmatically and gets its contents as xml and saves the xml in a string. I need to attach an xsl file to it so that it renders on browser.

My xsl file resides in sharepoint document library. In case the docx file that I open contains an image, that image is saved as binary data when I get its xml. The xsl has the following code to render this binary content as image:

<img src="{ext:decodePicture(w:binData, $dir, substring-after(w:binData/@w:name, 'wordml://'))}" alt="{v:shape/v:imagedata/@o:title}" style="{v:shape/@style}" title="{v:shape/v:imagedata/@o:title}"/>

public string decodePicture(XPathNodeIterator bindata, string dirname, string filename) {
if (bindata.MoveNext()) {
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(dirname);
if (!di.Exists)
using (System.IO.FileStream fs =
System.IO.File.Create(System.IO.Path.Combine(di.FullName, filename))) {
byte[] data = Convert.FromBase64String(bindata.Current.Value);
fs.Write(data, 0, data.Length);
return dirname + "/" + filename;
return "";

I use the following code in my page code behind file:

XSLTExtension XsltExt = new XSLTExtension();
//XSLTExtension is a class which contains a method "getFolderpath()"

String x= XsltExt.getFolderPath();
XsltArgumentList args = new XsltArgumentList();
String uri = "http://www.myurl.com";
args.AddExtensionObject(uri, XsltExt);

I call the method "getFolderPath()" from XSLT to get the path at runtime. This works fine when I am working on local file system, but fails when my xsl is in doc library, error I get is "Function kau:getFolderPath() failed."

I want to know if:
1. It is somehow possible to modify the decodePicture() function in XSLT so that I can save the image file in sharepoint document library.
2. Why is the getFolderPath() method not getting invoked.

This is a long post ....but please help me on this...Thanks in advance!!!