Bug 60950 - JSTL TransformSupport XSL import not finding relative path
Summary: JSTL TransformSupport XSL import not finding relative path
Status: RESOLVED FIXED
Alias: None
Product: Taglibs
Classification: Unclassified
Component: XTags Taglib (show other bugs)
Version: 1.2.5
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-03 14:09 UTC by Tomaz Cerar
Modified: 2017-04-03 16:26 UTC (History)
1 user (show)



Attachments
Reproducer war (2.21 KB, application/zip)
2017-04-03 14:09 UTC, Tomaz Cerar
Details
Patch that passes URI resolver to newTransformer (3.40 KB, patch)
2017-04-03 14:12 UTC, Tomaz Cerar
Details | Diff
Thread Safe Patch that passes URI resolver to newTransformer (3.51 KB, patch)
2017-04-03 14:51 UTC, Tomaz Cerar
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tomaz Cerar 2017-04-03 14:09:15 UTC
Created attachment 34894 [details]
Reproducer war

When you try to use references to local xslt files inside same deployment.
You can get error when creating XML Transformer as transformer factory doesn't have URI resolver set to be able to recognize jstl protocol.

Reproducer "test.war" is attached.
Part of code that makes it fail:

test.jsp:
------------
<c:import var="xslStylesheet" url="/xsl/style.xsl" charEncoding="UTF-8" />
<c:import url="http://localhost:8080/test/test.xml" var="doc"/>
<x:transform xml="${doc}" xslt="${xslStylesheet}" xsltSystemId="/xsl/">
</x:transform> 

style.xsl
---------------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                version="1.0">

    <xsl:import href="parent.xsl"/>
...

results in
javax.xml.transform.TransformerException: Had IO Exception with stylesheet file: parent.xsl
	   at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:942)
	   at org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:780)
	   at __redirected.__TransformerFactory.newTransformer(__TransformerFactory.java:133)
   at org.apache.taglibs.standard.util.XmlUtil.newTransformer(XmlUtil.java:187)
Caused by: java.net.MalformedURLException: unknown protocol: jstl
   at java.net.URL.<init>(URL.java:600)
   at java.net.URL.<init>(URL.java:490)
   at java.net.URL.<init>(URL.java:439)
   at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:964)
   at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:144)
   at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:832)
   at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:798)
   at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:108)
   at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1198)
   at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:564)
   at org.apache.xalan.processor.ProcessorInclude.parse(ProcessorInclude.java:312)

This is also tracked in Red Hat BZ https://bugzilla.redhat.com/show_bug.cgi?id=1320747
as well as in WildFly Jira: https://issues.jboss.org/browse/WFLY-8498
Comment 1 Tomaz Cerar 2017-04-03 14:12:25 UTC
Created attachment 34895 [details]
Patch that passes URI resolver to newTransformer

Proposed patch passes URI resolver to XmlUtil#newTransformer.
so it is set on TRANSFORMER_FACTORY before new transformer is created.
Comment 2 Tomaz Cerar 2017-04-03 14:51:07 UTC
Created attachment 34896 [details]
Thread Safe Patch that passes URI resolver to newTransformer
Comment 3 Remy Maucherat 2017-04-03 16:26:03 UTC
Reviewed and committed as r1790020, it will be in the next (1.2.6 ?) release.