xsl-list
[Top] [All Lists]

RE: [xsl] Windows Batchfile calling Saxon - Confusion of / and \

2007-10-10 06:50:46

For documents named on the command line, Saxon accepts a Windows filename,
because that's the standard for the Windows command line.

For documents named in a stylesheet, Saxon accepts a URI, because that's the
standard for stylesheet documents. URIs do not use backslashes: it must be
file:///a.b.c.xml. Or you can use a relative URI such as ../a.xml which is
interpreted relative to the base URI of the stylesheet - which is the result
of converting the Windows filename to a URI.

If the name of the second document is passed as a string parameter to the
stylesheet from the command line, you might consider using the format
+doc=filename instead. This doesn't pass the filename as a string, it
fetches the file, turns it into a tree, and passes the document node as the
value of the stylesheet parameter. This way you don't need to call the
document() function, and the filename is interpreted as a Windows filename
relative to the current directory, which is what makes sense when you're
using the command line.

There are unfortunately many products that accept Windows filenames in
contexts where the standards mandate a URI. I have been resisting doing
this, because I think standards conformance should outweigh minor
convenience. However, I've been dithering a little on this one recently,
because once everyone breaks a standard in the same way, they establish a
new de facto standard. 

However, since Windows has been supporting use of forward-slash in filenames
for about ten years, I find it surprising that people still want to use
backslashes.

Michael Kay
http://www.saxonica.com/


-----Original Message-----
From: Kerry, Richard [mailto:richard(_dot_)kerry(_at_)siemens(_dot_)com] 
Sent: 10 October 2007 14:27
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Windows Batchfile calling Saxon - Confusion of / and \

 
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 ?
 
 
 
Appreciatively,
Richard.
 
 
Richard Kerry
Colledia Control Engineer
Siemens IT Solutions and Services Ltd
Room 457 Design Building, BBC Television Centre, Wood Lane, 
London, W12 7RJ
T: +44 (0)20 82259063 F: +44 (0)20 8576 8182 M: +44 (0)7921 244993
Email: richard(_dot_)kerry(_at_)siemens(_dot_)com
<blocked::mailto:richard(_dot_)kerry(_at_)siemens(_dot_)com>
Website:  www.siemens.co.uk/it-solutions 
<blocked::outbind://47/www.siemens.co.uk/it-solutions> 

This e-mail contains confidential information and is for the 
exclusive use of the addressee/s.  If you are not the 
addressee, then any distribution, copying or use of this 
e-mail is prohibited. If received in error, please advise the 
sender and delete it immediately.  We accept no liability for 
any loss or damage suffered by any person arising from use of 
this e-mail.

Siemens IT Solutions and Services Limited Registered No: 
1203466 England Registered Office: Faraday House, Sir William 
Siemens Square, Frimley, Camberley, GU16 8QD


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