[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Windows Batchfile calling Saxon - Confusion of / a

Subject: Re: Windows Batchfile calling Saxon - Confusion of / and \
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Wed, 10 Oct 2007 14:43:54 +0100
Re:  Windows Batchfile calling Saxon - Confusion of / a
On 10/10/2007, Kerry, Richard <richard.kerry@xxxxxxxxxxx> wrote:
>
> I think this may really be primarily a Windows batch-file issue but as
> I'm trying to call Saxon I thought I'd ask here.
>
> I have a Windows batch file that I'm using to call an Xsl stylesheet,
> using Saxon 8-9j.
>
> My stylesheet uses a second input document, using document() to load it.
> The reading of the main input xml document is happy to read from the
> current working directory when I say 'Main.xml'.
> However the extra document doesn't seem to do so.  If I just pass in
> 'Secondary.xml' it's looking somewhere else, possibly 'C:\'.
> (If I use './Secondary.xml' it looks in the directory where the batch
> file is located)
>
> If I pass the secondary file as 'C:/Projects/Secondary.xml' it's happy.
> If I pass the secondary file as 'C:\Projects\Secondary.xml' it isn't,
> saying "FODC0005: Exception thrown by URIResolver. Invalid relative
> URI".
>
> I don't want to hard-code the current path in my batch file, I want to
> say "set DIR=%cd%", but if I do that DIR has '\' in it in the usual
> Windows manner, causing the read to fail, as above.
>
> So :
> 1.  Can I get Saxon to accept '\' instead of '/' ?  I presume not as its
> a URI not a directory name.
> 2.  Can I get Windows batch-files to convert '\' to '/' ?
> 3.  Can I get Saxon's document() function to search relative to the
> current working directory rather than the top of the disk ?

It should look for it relative to the stylesheet...

You're best option is to define the location as a parameter in the
stylesheet with a default value and then use that in the document
function:

<xsl:param name="secondary" select="'Secondary.xml'" as="xs:string"/>

and then use "document($secondary)"

That way your transform can run without needing the parameter
supplied, but if for some reason you need to point to a different
"Secondary.xml", or the name has changed, then can just override the
default value in the parameter with the new one (and not have to
change the hard code values in the stylesheet)


-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.