xsl-list
[Top] [All Lists]

Re: [xsl] Referring to stylesheet itself, possible in XSLT 1.0, but how in XSLT 2.0?

2006-10-17 05:42:06
Abel Braaksma wrote:

This output:
------------
Error on line 1 column 1 of file:/D:/Workspaces/Eclipse/etc/:
SXXP0003: Error reported by XML parser: Content is not allowed in prolog. Recoverable error on line 5 of file:/D:/Workspaces/Eclipse/etc/def/config/test.xslt: FODC0005: org.xml.sax.SAXParseException: Content is not allowed in prolog.
<?xml version="1.0" encoding="UTF-8"?>
       1)
       2) file:/D:/Workspaces/Eclipse/etc/
       3) file:/D:/Workspaces/Eclipse/etc/test.xml


There's an error in what I send above, it should of course be:

      1)
      2) file:/D:/Workspaces/Eclipse/etc/
      3) file:/D:/Workspaces/Eclipse/etc/def/config/test.xml


From what I understand from you all is the following (nr have no bearing with the above numbers):

1. If you place xml:base on xsl:stylesheet of your containing stylesheet xslt file, and that base location does NOT have your stylesheet physically, document('') will fail. In this scenario, it is NOT possible to resolve the original XSLT file that the xslt processor was calling.

2. If you place xml:base only on places where needed, you can use a global parameter with static-base-uri() to make sure it will be resolved against the uri of the stylesheet. It will return the stylesheet url.

3. If you do not use xml:base at all, or when it points to a location where your current xslt file is located as well, both document-uri(document('')) and static-base-uri() will return the same result.

Not sure I covered all scenarios. I am aware of URIResolver, or using the xslt as a parameter or as source document. I decided, for now, to put the name of the current xslt inside an entity reference. Not the best solution, I know, and it has to be repeated for each stylesheet, but good enough for the moment.

Colin, Dimitre,  Michael, David, Andrew: thanks for the valuable insights!

Cheers,
-- Abel Braaksma
  http://www.nuntia.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>
--~--

<Prev in Thread] Current Thread [Next in Thread>