Subject: RE: Windows Batchfile calling Saxon - Confusion of / and \
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 17 Oct 2007 17:28:34 -0400
|
Hi,
At 11:25 AM 10/11/2007, Richard Kerry wrote:
> So the person
> who brought up the issue could have just used forward slashes,
> right?
No. That would be me. And the reason I couldn't is pretty much
as indicated in the later part of Andrew's posting (below).
When I was generating full paths in my batch file I was generating
them using '/' as Saxon was only happy with those (for multiple
documents using document()).
When I finished doing the initial 'experimental' phase of my task
I needed to change the batch file so it no longer had the original
full path hard-coded in it and could be run from anywhere. Then
I found that Saxon wouldn't understand '.' as meaning the current
directory. So I used Windows' 'cd' command to get the current
directory and assigned the result to a variable (using 'set'), which
I then passed into the stylesheet for this purpose. It was at this
point that the problem arose.
So, as Andrew indicates, this is a problem specifically with paths
that are generated by Windows itself and have not been entered manually,
and so there is no reasonable alternative that I can see to using
the '=' option in 'set' that allows strings to be substituted.
Somehow in the original discussion of this problem, last week, it was
never mentioned that while
document('Secondary.xml')
resolves relatively to the stylesheet,
document('Secondary.xml',/)
resolves relatively to the root of the root of the tree containing
the context node. So if the node being processed is inside
'Main.xml', the processor should then look for 'Secondary.xml' next to it.
Accordingly, document('Secondary.xml',/) or
document('Secondary.xml',$source) (where $source is appropriately
bound) is often the cleanest and most portable solution to this
particular problem.
Of course, if your secondary file isn't located in the same
subdirectory as the main file, you still have to make sure the path
to it has forward slashes (as in URI syntax) not back-slashes (as in
Windows paths).
To put it another way: the OP suggests that Saxon "doesn't understand
'.' as the current directory" -- but it does; it's just following the
XSLT spec in defining that directory as the directory in which the
stylesheet, not the source document, is located. But (again, as per
the spec) the second argument to document() can be used to reset this.
Cheers,
Wendell
======================================================================
Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
|