Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transform XML from command line

Status
Not open for further replies.

simonchristieis

Programmer
Jan 10, 2002
1,144
GB
Not exactly on subject but I wasn't sure where it would fit.

But here goes:

I am trying to tranform an xml file using xslt using the saxon parser, the saxon parser is called through a java line run through dos on windows server.

The problem lies when the xslt has a document('Output.xml') xpath statement within an apply-templates.

Command Line Call:

Code:
(All on one line)

java -Xrs -Xmx512m 
-Xbootclasspath/p:
\\server\shareddrive\Library\v1.0.5\saxon\saxon9.jar;
\\server\shareddrive\Library\v1.0.5\saxon\saxon9-dom4j.jar;
\\server\shareddrive\Library\v1.0.5\saxon\saxon9-dom.jar;
\\server\shareddrive\Library\v1.0.5\saxon\saxon9-jdom.jar;
\\server\shareddrive\Library\v1.0.5\saxon\saxon9-s9api.jar;
\\server\shareddrive\Library\v1.0.5\saxon\saxon9-sql.jar;
\\server\shareddrive\Library\v1.0.5\saxon\saxon9-xom.jar;
\\server\shareddrive\Library\v1.0.5\saxon\saxon9-xpath.jar;
\\server\shareddrive\Library\v1.0.5\saxon\saxon9-xqj.jar 
net.sf.saxon.Transform 
-s:\\server\shareddrive\Data.xml 
-xsl:\\server\shareddrive\Transform.xsl 
-o:\\server\shareddrive\Output.xml  
descriptionLocation=\\server\shareddrive\ExtraData.xml

This is an extract of the xsl file that is failing:

Code:
<xsl:apply-templates select="$descriptionFile/root"/>

The error that I'm given is here:

Code:
Recoverable error on line 30 of Transform.xsl:
  FODC0002: Exception thrown by URIResolver: Invalid relative URI
  {D:\shareddrive...}: Illegal character in opaque part at index 2:
  D:\shareddrive\Output.xml

Anyone have any ideas ?

The xml and xsl are fine and the parameters are passed in correctly and all worked fine using the xerces parser.

Regards

Simon







 
What's the relation between descriptionLocation and descriptionFile?
 
My bad - just missed some information:

In Transform.xsl the param is passed like this:

Code:
	<xsl:param name="descriptionLocation"/>
	<xsl:variable name="descriptionFile" select="document($descriptionLocation,/)"/>
 
What I would check are:
[1] Make sure saxon version is 7.5 or later; as v7.5 is dated 2003, it probably is.
[2] Change it to relative uri as the path is the same as the xsl document. I mean simply this.
[tt] descriptionLocation=ExtraData.xml[/tt]
and make descriptionFile simply this as a test.
[tt] <xsl:variable name="descriptionFile" select="document($descriptionLocation)"/>[/tt]
 
If I place the ExtraData.xml file in the root of the output xml location then the transform works correctly.

I just dont understand what changes I need to make for the parser to understand that I wish to pick up the file from a different location.

Any ideas ?


 
The problem is that the parser is expecting the full path with forward slashes not backslashes:

descriptionLocation=\\server\shareddrive\ExtraData.xml

should be

descriptionLocation=//server/shareddrive/ExtraData.xml

Thanks for your help anyway.

Regards

Simon
 
Use relative url should be the safest. It is taken as relative to the stylesheet path.

A dated discussion on the url resolution, and in particular on the unc, can be found here:
including prev & next by Thread.

Also this attempt to summary, dated as usual.

But a few factor in this mess: saxon can be improving in url resolution; unc's use can be spread into parameter feeding which find its way into document() and result-document() etc xpath functions. That can multiple the adhoc rules.

The less-than-perfect uri resolution may find some blame in the java's uri resolution as well which again is transforming all the time hopefully in the good direction.

If that resolve your problem, I have nothing to add and thanks for posting back.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top