After compilation and configuring Path variable it compiles but fails to execute. WHAT CAN CAUSE THE FAILURE? I am using Stylus Studion 2006 Enterprise Edition.
Does it has something to tdo with resolving URI (relative?...)?
(Fatal Error) net.sf.saxon.trans.DynamicError: Invalid relative URI {C:\SoftwareDevelopment\LVS_Wor...}: Invalid relative URI {C:\SoftwareDevelopment\LVS_Wor...}: Illegal character in opaque part at index 2: <<< WHAT THIS MEANS???? C:\SoftwareDevelopment\LVS_Workspace\tool_m2c2\doc\graphs\rf_headers.xml
Exception in thread "main" net.sf.saxon.trans.DynamicError: net.sf.saxon.trans.DynamicError: Invalid relative URI {C:\SoftwareDevelopment\LVS_Wor...}
at net.sf.saxon.functions.Document.makeDoc(Document.java:252)
at net.sf.saxon.functions.Doc.doc(Doc.java:87)
....
Here are the supporting printouts:
===========================================================
file:///c:/SoftwareDevelopment/LVS_Workspace/tool_m2c2/doc/graphs/rf_generator.xquery:14,-1: (Fatal Error) Invalid relative URI {C:\SoftwareDevelopment\LVS_Wor...}: Illegal character in opaque part at index 2: C:\SoftwareDevelopment\LVS_Workspace\tool_m2c2\doc\graphs\rf_headers.xml
(Fatal Error) net.sf.saxon.trans.DynamicError: Invalid relative URI {C:\SoftwareDevelopment\LVS_Wor...}: Invalid relative URI {C:\SoftwareDevelopment\LVS_Wor...}: Illegal character in opaque part at index 2: C:\SoftwareDevelopment\LVS_Workspace\tool_m2c2\doc\graphs\rf_headers.xml
Subject:XQUERY Java run-time error Author:Jack Tan Date:17 Apr 2007 04:42 AM
Ivan,
thanks for late night reply ;-)
I am using Java generated code.
Interestingly when in the XQUERY script I changed:
let $svgDoc := "\SoftwareDevelopment\LVS_Workspace\tool\doc\graphs\rf_headers.xml"
let $doc := "C:\SoftwareDevelopment\LVS_Workspace\tool\doc\graphs\intermediate.xml"
to
let $svgDoc := "rf_headers.xml"
let $doc := "C:\SoftwareDevelopment\LVS_Workspace\tool\doc\graphs\intermediate.xml"
problem disapeared.
Below, I am attaching Java code.
Thx
Jack
/**
* Generated by Stylus Studio.
* This application skeleton demonstrates how to execute XQuery from Java.
*/
/**
* Run an XQuery.
* This class requires the following items in the classpath.
* C:/SoftwareDevelopment/LVS_Workspace/rf_record
* C:/Program Files/Stylus Studio 2006 Release 3 XML Enterprise Edition/bin/saxon8sa.jar
* C:/Program Files/Stylus Studio 2006 Release 3 XML Enterprise Edition/bin/saxon8.jar
*/
public class rf_generator
{
String m_baseURI;
String m_paramNames[];
String m_paramValues[];
boolean m_useResolver = true; // true = use the StylusFileFactory URIResolver
int m_selectedProcessor = 0;
int m_validationProcessor = 0;
// items from the Saxon XSLT Settings dialog
int m_stripWhitespace;
boolean m_schemaAwareProcessor;
boolean m_tinyTree;
boolean m_enableFileExtensions;
boolean m_validateWithDTD;
boolean m_validationIssuesWarnings;
int m_sourceValidationLevel;
BufferedReader m_saxonLicenseReader;
String m_validatorInput;
File m_tmpFile;
// application constructor
public rf_generator() {}
public static void main(String[] args) throws Exception
{
rf_generator app = new rf_generator();
// This section lists all scenarios selected for this XQuery.
// Uncomment the setScenario call for the scenario you want
// the code to run. All other scenarios must be commented out.
try {
app.setScenario_Scenario1();
/////////////////////////////////////////////////////////////////
// Only one of these setScenario methods can be called at a time.
/////////////////////////////////////////////////////////////////
public void setScenario_Scenario1()
throws IOException
{
m_useResolver = false;
m_scriptSource = new BasicSource();
m_xmlSource = new BasicSource();
m_finalResult = new BasicResult();
m_paramNames = new String[] {};
m_paramValues = new String[] {};
m_selectedProcessor = SAXON8;
// If you are using schema aware version of Saxon, you must supply a license key.
// There are 2 options:
// 1) put the saxon-license.lic file in your classpath.
// 2) Supply a BufferedReader (could be a FileReader or a StringReader) which will return
// the license.
///////////////////////
// m_saxonLicenseReader = <<Insert the buffered reader here and uncomment this line.>>
///////////////////////
///////////////////////////////////////////////////////////
// Perform initialization common to all scenarios. One of
// the setScenario methods should have been called first.
///////////////////////////////////////////////////////////
public void initialize() throws Exception
{
initializeAll();
if (m_selectedProcessor==SAXON8) initializeSaxon();
}
public void process() throws IOException
, TransformerException
{
if (m_selectedProcessor==SAXON8) processSaxon();
}
public void initializeAll() throws Exception
{
if (!m_useApacheFop && !m_useRenderX && !m_doValidation) {
// In the simplest scenario, the XQuery output is sent
// directly to the output URL.
// xmlSource -> XQuery -> finalResult
m_transformResult = m_finalResult;
}
else
if (m_finalResult.isFile()) {
// The XQuery output is being written to a file, and there
// is also a validation and/or FOP step. After the
// XQuery output is written to the file, that file will be
// used as input for the validation and/or FOP step.
// xmlSource -> XQuery -> finalResult -> validator
// finalResult -> FOP
m_transformResult = m_finalResult;
m_validatorInput = m_finalResult.getFilename();
m_foInputFilename = m_finalResult.getFilename();
}
else
{ // The XQuery output is being written to a URL or to System.out.
// and there is also a validation and/or FOP step. The XQuery
// output will first be written to a temp file. Then, the
// temp file will be copied to the output URL (or System.out).
// The temp file will also be used as input for the validation
// and/or FOP step.
// xmlSource -> XQuery-> tmpFile -> doCopy -> finalResult
// tmpFile -> validator
// tmpFile -> FOP
m_tmpFile = File.createTempFile("tmp", ".xml");
m_transformResult = new BasicResult();
m_transformResult.setFile(m_tmpFile.getAbsolutePath());
m_doCopyStep = true;
public void parseParametersSaxon(Configuration cfg, String[] paramNames, String[] paramValues, String uri, DynamicQueryContext globalDQC)
{
// loop over all parameter name/value pairs
// evaluate the value, and then do setParameter
for(int i=0; i<paramNames.length; i++) {
Value xvalue=null;
try {
StaticQueryContext sqc = new StaticQueryContext(cfg);
sqc.getConfiguration().setErrorListener(new TransformerErrorListener());
sqc.setBaseURI(uri);
DynamicQueryContext localDQC = new DynamicQueryContext(cfg);
StringReader sr = new StringReader(svalue);
private static final int XALANJ = 10;
private static final int SAXON6 = 11;
private static final int SAXON8 = 12;
private static final int XERCESJ = 13;
if (m_doCopyStep) copyOutput(m_validatorInput, m_finalResult);
}
/**
* Copy the XQuery or XSLT output from the temp output file to the
* proper result file.
* The XQuery or XSLT output was left in a temporary file.
* This routine copies it to the proper result: m_finalResult
*/
void copyOutput(String inFilename, BasicResult result) throws IOException {
InputStream is = null;
OutputStream os = null;
try {
is = new FileInputStream(inFilename);
os = result.getOutputStream();
byte buffer[] = new byte[8000];
int bytesRead = 0;
while ((bytesRead = is.read(buffer)) != -1)
os.write(buffer, 0, bytesRead);
} finally {
result.close();
if (is != null)
is.close();
}
}
public void cleanup() throws IOException {
// The following code ensures that all streams opened by setScenario are closed.
if (m_scriptSource != null) m_scriptSource.close();
if (m_xmlSource != null) m_xmlSource.close();
if (m_transformResult != null) m_transformResult.close();
if (m_finalResult != null) m_finalResult.close();
if (m_tmpFile != null) m_tmpFile.delete();
if (m_foSource != null) m_foSource.getByteStream().close();
if (m_xepSource != null) m_xepSource.getInputStream().close();
if (m_foOutputStream != null) m_foOutputStream.close();
}
private class TransformerErrorListener implements ErrorListener {
public void warning(TransformerException exception) {
printMsg(exception, "(Warning) ");
}
public void error(TransformerException exception) {
printMsg(exception, "(Error) ");
}
public void fatalError(TransformerException exception) {
printMsg(exception, "(Fatal Error) ");
}
// Saxon sends the same exception 2 times. This is used to suppress the 2nd copy.
private String m_lastMsg;
private void printMsg(TransformerException exception, String errorType) {
String msg = errorType + exception.getLocalizedMessage();
SourceLocator loc = exception.getLocator();
if (loc!=null) {
String file = loc.getSystemId();
int line = loc.getLineNumber();
int col = loc.getColumnNumber();
msg = file + ":" + line + "," + col + ": " + msg;
}
Throwable t = exception.getCause();
while(t!=null) {
msg += ": " + t.getLocalizedMessage();
t = t.getCause();
}
if (!msg.equals(m_lastMsg)) // dont print the same message twice
System.out.println(msg);
m_lastMsg = msg;
}
}
///////////////////////////
// Support code for RenderX
///////////////////////////
// These helper classes are used to convert a URL string into a Source or Result:
// BasicSource and BasicResult are used if NOT using the Stylus Studio URIResolver.
// ResolverSource and ResolverResult are used with the Stylus Studio URIResolver.
The problem is indeed most likely an invalid relative URI.
Just having a pathname starting with a backslash doesn't
help, because it's not a valid relative URI. When converting
from filesnames to URI's, Saxon will attempt to open using
the java URI handling, but since there is an absolute path (you
started it with a \) but no protocol, it won't open. If it
prepends "file:///" it gets an invalid URI. Same thing if it
tries to open as a file.
Either include the C: to make it an absolute name, or make it a
true URI by including the protocol.