xsl-list
[Top] [All Lists]

RE: [xsl] Java XSLT transformers and document('') problem

2008-09-08 04:36:51
You need to understand what document('') actually does. It treats '' as a
relative URI and resolves it against the base URI of the element containing
the call to the document() function. Normally if your stylesheet is read
from a file on disk, this will re-read that file from disk and return its
parsed representation. (In some processors it's possible that this will be
optimized - if the processor still has the original XML of the stylesheet
available at run-time, then it might not need to re-read it).

If your stylesheet wasn't read from disk, then this isn't going to work. The
only thing I can suggest is to supply a URIResolver which intercepts the
document('') request and returns whatever you want it to return.

Note that with XSLT 2.0 there is almost never a need to use document('') and
it should generally (in my view) be avoided. Even with 1.0, it is often used
to read "lookup data", and in my view it's better to put such lookup data in
a separate document rather than putting it in the stylesheet.

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: LS [mailto:leonid(_at_)schleicher(_dot_)ru] 
Sent: 08 September 2008 04:11
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Java XSLT transformers and document('') problem

I have strange behavior with XSLT and Java (tested on Xalan 
and Saxon):

when I create transformer from XSLT file, function 
document('') works as I expect:

document('')/* -> xsl:template
count(document('')/*) -> 1

when I create transformer from Domsource, modify it (add some 
templates, remove others) - something breaks function document(''):

document('')/* -> ?
count(document('')/*) -> 0

all works well when I write modified XSL to file and create 
transformer from that file but dumping modified XSL to string 
 and create transformer from Streamsourse again works with errors

Is there any way to create transformation on-the fly and use 
it without temporary dumping it to file?
My question depends only on document('') function, because 
all of the others seems like ok

--~------------------------------------------------------------------
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>
--~--



--~------------------------------------------------------------------
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>
--~--