It's not immediately clear to me what's happening here, but I suspect that
the problem might not be with the URI passed to unparsed-text(), but rather
with the base URI of the stylesheet. Although in principle when you supply
an absolute URI to unparsed-text() it shouldn't matter what the base URI is,
in practice it might well be that problems with the base URI get reported on
this path.
The most likely reason for a problem with the base URI is that you didn't
call setSystemId() on the Source object defining the stylesheet.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Mukul Gandhi [mailto:gandhi(_dot_)mukul(_at_)gmail(_dot_)com]
Sent: 20 March 2008 04:22
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Problem running a 2.0 transformation with JAXP
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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--