[XsltView] URI base for imports is meaningless [SPR-4894] #9570
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Kenny MacLeod opened SPR-4894 and commented
I've been using XsltViewResolver for the first time, and found some rather peculiar behaviour when it comes to resolving the URI base for XSL imports.
Say I have a stylesheet defined in /WEB-INF/transform.xslt and that stylesheet contains <xsl:import href="import.xslt"/> where import.xslt is contained in the same WEB-INF directory. The import fails because import.xslt cannot be found.
If I then plug in my own URIResolver and make it log the href and base arguments, the base has actually resolved as file:///D:/WEB-INF. I'd expect the base to be the webapp's WEB-INF directory on disk. This is probably because when Spring wraps my transform.xslt in a StreamSource (via ServletContextResource) and passes that Source to the TransformerFactory, it loses all context information and doesn't know the base URi of the stylesheet.
Would it be possible for XsltViewResolver to default to a sensible implementation of URIResolver, which uses the local ResourceLoader to try and locate the resource? The current behaviour would seem to be completely useless.
Affects: 2.0.8, 2.5.4, 2.5.5
Backported to: 2.0.9
The text was updated successfully, but these errors were encountered: