Win a copy of Securing DevOps this week in the Security forum!

David P Brown

+ Follow
since Apr 10, 2004
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by David P Brown

Quite right, but then

simply gives 'Source file input does not exist'.
Regardless of my confusion, I think we have to acknowledge Micheal Kay's suggestion. I understand this is the same MK who is the name at the W3C
XSL Transformations (XSLT) Version 2.0
12 November 2003, Michael Kay
Any suggestions why the java code doesn't compile?
That is an interesting question, Bill, which prompted me to try simply writing to the file.

However, it doesn't work and I think it is due to XSLT being a compiled language. The error I get is 'Variable name must be a valid QName' which is directly due to the file doesn't exist and consequently the xsl can't be compiled.
This is consistent with Micheal Kay's suggesting that I would need to create a custom URIResolver.
Evidently this is more about the file not existing at compilation, than it is about the output.
Thanks Lasse, but I'm still getting the same compilation error.
I expect I'm not being clear. (a little out of my depth
What I know is that I've been advised that a custom URIResolver is what I need. This from Micheal Kay author of the Saxon processor.
I grabbed the idea of the java code required from other talk of URIResolver as it looked like it made sense.
What I need is that the XSLT processor is able to write to a file suggested to it and it can't do that if the file doesn't exist.
Accepting what you suggest I've constructed the following which crashes with one error.. illegal start of expression
public Source resolve(href, base) {

If you can suggest a correction for that error then I'll see if it does work for me.
The problem, ~obviously, is that XSLT (Saxon) can't work with files that don't exist.
Therefore it must find at least
<?xml version="1.0"?>
to be successful.
There is a way for XSLT to detect a file doesn't exist but that is of no use to me.
Forgive me, my knowledge of Java is *very limited*
I need not simply to return the location of a source but copy a null file to the location requested. This file will then be written to as if it already existed.
It's not just input I'm needing, it's the creation of a copy of null.xml to requested.xml
Then I'm expecting
try {s = systemURIResolver.resolve(href, base);} will work.
I need a custom URIResolver for use with Saxon but know too little about Java to tackle it, and hope you might be able to help.
Specifically, I need a URIResolver that will respond to FileNotFoundException by copying the file 'null.xml' from a known location and then responding, that the file was found.
So, when an XSLT calls, with document(), a file that doesn't exist, its processing continues uninterupted because, at the very least it will find a copy of null.xml in that place, which the XSLT can then write to..
I'm wondering if the following is partly what I need. In my ignorance I'm expecting that this requires wrapping in a
"class MyResolver implements URIResolver {}"
but that's a guess.

(I know enough that I can compile java and use this custom URIResolver with Saxon)