JSTL XML Transforms not working with nested XSL includes
I have a bit of JSP that does this:
<c:import url="/xsl/Trans开发者_StackOverflowformer.xsl" var="xslt" />
<x:transform doc="${actionBean.dom}" xslt="${xslt}" xsltSystemId="/xsl/">
This transforms the XML exactly as expected so long as Transformer.xsl contains no <xsl:include>
tags or so long as any documents it does include do not include anything.
However, if I use an XSL which includes a document which in turn includes another document, I get the following error:
ERROR: 'Invalid URI 'NestedInclude.xsl Could not resolve entity reference: "NestedInclude.xsl"'.'
Note that the JSP is contained in the directory below the xsl documents. If all my XSLs and JSPs are in the same directory (and I remove the xsltSystemId attribute) then everything would work fine, but I don't really want to do this.
Can anyone see anything I'm doing wrong, as it's a bit of a killer at the moment and the JSTL documentation is next to useless.
If you provide a value for the xsltSystemId
attribute that starts with "/", I believe JSTL will use an EntityResolver
that attempts to locate: PageContext.getServletContext().getResourceAsStream(xsltSystemId)
. So, you might try either xsltSystemId="/xsl/Transformer.xsl"
, or just leave out the attribute.
I had the same problem and I could solve it by giving absolute path. something like this:
<c:import url="/WEB-INF/some-folders/xsl/Transformer.xsl"/>
精彩评论