[xsl] Problem running a 2.0 transformation with JAXP

Subject: [xsl] Problem running a 2.0 transformation with JAXP
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Thu, 20 Mar 2008 09:52:24 +0530
Hi all,
   I am using Saxon 9 XSLT processor to run my program. Below is a
description of my problem.

In a 2.0 stylesheet, I am using 'unparsed-text' function as following:

<xsl:param name="file" />  <!-- this is a global stylesheet parameter -->

<xsl:variable name="fileStr" select="unparsed-text($file,'UTF-8')" />

I am passing the value of parameter 'file' as a URI string value of
format, file:/C:/dirname/filename.csv

I am calling the transformation from a Java program using the JAXP
API. Below is the code fragment of my Java program:

File f = new File("filename.csv");
String file = f.toURI().toString();  //this generates string of
format, file:/C:/dirname/filename.xyz

transformer.setParameter("file", file);
transformer.transform(xmlSource, new StreamResult(new File("result.csv")));

(I am actually using the syntax, <xsl:output method="text" /> in the
stylesheet, to generate a CSV output).

When the Java program is run, I get the following error:

Error
  XTDE1170: Cannot resolve relative URI: no protocol:
net.sf.saxon.trans.DynamicError: Cannot resolve relative URI
        at net.sf.saxon.functions.UnparsedText.readFile(UnparsedText.java:112)
        at net.sf.saxon.functions.UnparsedText.evaluateItem(UnparsedText.java:72
)
        at net.sf.saxon.expr.ExpressionTool.eagerEvaluate(ExpressionTool.java:29
7)
        at net.sf.saxon.expr.ExpressionTool.lazyEvaluate(ExpressionTool.java:245
)
        at net.sf.saxon.instruct.GlobalVariable.getSelectValue(GlobalVariable.ja
va:168)
        at net.sf.saxon.instruct.GlobalVariable.evaluateVariable(GlobalVariable.

If I run the stylesheet from command line, passing the relevant URI
parameter as string, in the same format, I do not get the error.

It seems, 'unparsed-text' function is having some problem working with
the passed value.

Could somebody please help me with this.


-- 
Regards,
Mukul Gandhi

Current Thread