ndw / xmlcalabash1

XML Calabash, an XProc processor
http://xmlcalabash.com/
108 stars 41 forks source link

With 1.1.26-99, a new error for the test case in #281 appears #289

Open gimsieke opened 5 years ago

gimsieke commented 5 years ago

In the same area of our EPUB converter where #281 and #288 appeared, there was now a new error. There is a p:iteration-source that iterates over resources whose base URI is supposed to end in .css or .xhtml. The .css resources are created by an XSLT named …/css-tools/xsl/css-generate.xsl. With 1.1.26-99, after the first .css resource has been iterated over, the next resource has a base URI that ends in css-tools/xsl/css-generate.xsl which leads to subsequent errors (“tr:ext-to-mime-type(): Empty type for 'xsl'”).

I haven’t prepared a minimal repro yet, but I noticed that the repro of #281 now throws the following error:

$ java -jar xmlcalabash-1.1.26-99.jar -i source=../Untitled2.xml ../issue281.xpl
Message: before:   base-uri(): file:/C:/cygwin/home/gerrit/Dev/tmp/Calabash/Untitled2.xml,  /*/@xml:base: file:/foo/bar.xml,  base-uri(/*): file:/foo/bar.xml
ERROR: file:/C:/cygwin/home/gerrit/Dev/tmp/Calabash/issue281.xpl:27:15:err:XD0026:Expression refers to context when none is available: ' after:   base-uri(): ',   base-uri(),                      ',  /*/@xml:base: ', /*/@xml:base,                      ',  base-uri(/*): ', base-uri(/*)
ERROR: It is a dynamic error if the select expression makes reference to the context node, size, or position when the context item is undefined.

With 1.1.25-99, it’s still:

Message: before:   base-uri(): file:/C:/cygwin/home/gerrit/Dev/tmp/Calabash/Untitled2.xml,  /*/@xml:base: file:/foo/bar.xml,  base-uri(/*): file:/foo/bar.xml
Message:  after:   base-uri(): file:/C:/cygwin/home/gerrit/Dev/tmp/Calabash/Untitled2.xml,  /*/@xml:base: ,  base-uri(/*):

This seems to be related to p:xslt not producing any output. If I modify Untitled3.xsl so that it produces a primary output, the base URIs that 1.1.26-99 reports are:

Message:  after:   base-uri(): file:/C:/cygwin/home/gerrit/Dev/tmp/Calabash/Untitled2.xml,  /*/@xml:base: ,  base-uri(/*): file:/C:/cygwin/home/gerrit/Dev/tmp/Calabash/Untitled3.xsl

With 1.1.25-99:

Message:  after:   base-uri(): file:/C:/cygwin/home/gerrit/Dev/tmp/Calabash/Untitled2.xml,  /*/@xml:base: ,  base-uri(/*): file:/C:/cygwin/home/gerrit/Dev/tmp/Calabash/Untitled2.xml

So the primary output gets again the base URI of the XSLT stylesheet.

ndw commented 5 years ago

Ok. The raw destination that I had to use to fix the previous issue doesn't allow me to specify the base URI of the output document (so I guess it gets the stylesheet URI). I thought this was rectified before the document was returned, but perhaps there's a case where it isn't. I'll investigate.

ndw commented 5 years ago

281 now runs without error for me (with the latest Saxon 9.9). Works for you now?

gimsieke commented 5 years ago

It doesn’t throw an error any more when I run it with Saxon 9.9.1.2 or 9.9.1.3 and Calabash 1.1.26-99 or 1.1.27-99, but in all cases the result is like

$ java -jar xmlcalabash-1.1.27-99.jar  -i source=../../../Untitled2.xml ../../../issue281.xpl
Message: before:   base-uri(): file:/C:/cygwin/home/gerrit/Dev/Calabash/Untitled2.xml,  /*/@xml:base: file:/foo/bar.xml,  base-uri(/*): file:/foo/bar.xml
Message:  after:   base-uri(): file:/C:/cygwin/home/gerrit/Dev/Calabash/Untitled2.xml,  /*/@xml:base: ,  base-uri(/*): file:/C:/cygwin/home/gerrit/Dev/Calabash/Untitled3.xsl
<doc/>

which means that after the transformation, base-uri(/*) is the base URI of the stylesheet while it needs to be identical to base-uri() in the absence of /*/@xml:base. This was the error that I reported in #281.