Re: Spurious error on recursive invocation of fn:transform
Dimitre Novatchev <[email protected]> Mon, 23 Nov 2020 15:32:30 -0800
| Newsgroups | gmane.text.xml.saxon.help |
|---|---|
| Message-ID | <CAK4KnZdSFVmQraFK1QdP4oiFf-QZE2ypvuTxjg47kjS06pOm1w@mail.gmail.com> |
> > Then change the official XSLT 1.0 specification and inform all the XSLT 1.0 user's whose code will suddenly start failing. > > I wish we could, because what it states is clearly wrong. This is one more reason not to add up to the existing versions of XSLT, but to start anew from zero with a completely new language -- I think the proposed K++ sounds OK :) On Mon, Nov 23, 2020 at 2:26 PM Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]> wrote: > Having a stylesheet read it's own source code using doc("") is a pretty dreadful hack > and really has no place in modern XSLT code. In the general case where compiled stylesheets are deployed around the world, > the source code isn't available at execution time anyway. Then change the official XSLT 1.0 specification and inform all the XSLT 1.0 user's whose code will suddenly start failing. > > I wish we could, because what it states is clearly wrong. > > A reminder: it says: > > Note that a zero-length URI reference is a reference to the document > relative to which the URI reference is being resolved; thus document("") refers > to the root node of the stylesheet; the tree representation of the > stylesheet is exactly the same as if the XML document containing the > stylesheet was the initial source document. > > Now, firstly, it's hard to tell whether that's supposed to be normative, > because it starts with "Note that". But because it says "Note that", it's > clearly trying to remind us of something that we could have worked out for > ourselves; it's referring to concepts defined elsewhere, rather than saying > anything prescriptive. > > But as such, it's factually inaccurate: a zero length URI reference > actually represents the base URI of the element node at which it appears, > which is not necessarily the URI of the stylesheet module (XSLT 1.0 > sometimes uses the term "stylesheet" to mean the entire stylesheet, and > sometimes to mean one particular stylesheet module). The base URI can be > different for different elements in one document, for example if xml:base > is used, if external entities are used, if XInclude is used, or if APIs > such as JAXP are used that allow you to specify a base URI different from > the location of the document. Even if it is the URI of the stylesheet > module, there is no guarantee that the stylesheet module is accessible, or > that it still has the same content as it had at an earlier point in time. > Furthermore, section 2.7 says that "an XSLT stylesheet may also be > embedded in another resource", and in that situation document("") will give > you that resource, which may contain numerous stylesheets. Indeed, in the > presence of xml:base there is nothing to stop many different stylesheets > having the same base URI. > > Furthermore, stylesheets are often loaded from resources that have no > known URI (for example a DOM tree or a Stream). The specification gives no > clues as to what document("") should do in such cases; the only thing you > can be sure of is that's it's not going to be reliable. > > So there are many ways in which using document("") and assuming it will > retrieve the source code of the stylesheet is hopelessly broken. In effect, > it only works under very limited conditions: where the stylesheet contains > a single module, where that module is the entirety of an XML document, > where the XML document corresponds one-to-one with an addressable and > web-accessible resource, where the address of that resource is known to the > XSLT processor, and where the content of that resource is stable over time. > > Michael Kay > Saxonica > > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > [email protected] > https://lists.sourceforge.net/lists/listinfo/saxon-help _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [email protected] https://lists.sourceforge.net/lists/listinfo/saxon-help