[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Java XSLT transformers and document('') problem
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@xxxxxxxxxxxxx] > Sent: 08 September 2008 04:11 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|