Re: [xsl] Problem running a 2.0 transformation with JAXP

Subject: Re: [xsl] Problem running a 2.0 transformation with JAXP
From: hugh <hdixon@xxxxxxxxxxxxxx>
Date: Thu, 20 Mar 2008 17:59:37 +1030
On Thu, 20 Mar 2008 02:52:24 pm Mukul Gandhi wrote:
> 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'm  not sure if this is your problem, but I found using MS products, that 
when I moved from IE6 to IE7 it was more sensitive to the formatting of the 
URI.
In particular 
	file:/C:/dirname/filename.csv
would fail.  The URI should be
	file://C:/dirname/filename.csv

(Double backslash after file: not single)

No idea if this is your problem, but it was a problem I have had.

Hugh

>
> 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.

Current Thread