You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "John Krueger (JIRA)" <ji...@apache.org> on 2007/11/21 21:47:34 UTC

[jira] Created: (WW-2334) XSLTResult does not work with stylesheets that use xsl:include or xsl:import

XSLTResult does not work with stylesheets that use xsl:include or xsl:import
----------------------------------------------------------------------------

                 Key: WW-2334
                 URL: https://issues.apache.org/struts/browse/WW-2334
             Project: Struts 2
          Issue Type: Bug
          Components: Other
    Affects Versions: 2.0.11
            Reporter: John Krueger


Imported or included xslt stylesheets are not found when using the XSLTResult type.

According to the javadoc for the org.apache.struts2.views.xslt.ServletURIResolver class, the href atttribute on the following xslt element should allow the transformer to retrieve the resource, common.xsl, but Xalan does not find it.

  <xsl:include href="response:WEB-INF/xslt/common.xsl"/>


After debugging the struts2 source, the problem is that in the XSLTResult class the URIResolver is not being set on the TransformerFactory instance in the getTemplates() method before the xslt source is processed into a Templates object.  I have made and tested this changed in a source build and will try to attach a patch for this fix.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Please…. Unsubscrib me…

Posted by Pedro Neves <pe...@powerlogic.com.br>.
Please…. Unsubscrib me…

I do not want to receive these messages


Thank you 





-----Mensagem original-----
De: Steve Wolke (JIRA) [mailto:jira@apache.org] 
Enviada em: Friday, January 25, 2008 5:19 AM
Para: issues@struts.apache.org
Assunto: [jira] Commented: (WW-2334) XSLTResult does not work with stylesheets that use xsl:include or xsl:import


    [ https://issues.apache.org/struts/browse/WW-2334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43113#action_43113 ] 

Steve Wolke commented on WW-2334:
---------------------------------

The diff below resolved this problem for me.

Index: XSLTResult.java
===================================================================
--- XSLTResult.java     (revision 615211)
+++ XSLTResult.java     (working copy)
@@ -408,6 +408,7 @@
                 LOG.debug("Preparing XSLT stylesheet templates: " + path);

                 TransformerFactory factory = TransformerFactory.newInstance();
+                factory.setURIResolver(getURIResolver());
                 templates = factory.newTemplates(new StreamSource(resource.openStream()));
                 templatesCache.put(path, templates);
             }


> XSLTResult does not work with stylesheets that use xsl:include or xsl:import
> ----------------------------------------------------------------------------
>
>                 Key: WW-2334
>                 URL: https://issues.apache.org/struts/browse/WW-2334
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 2.0.11
>            Reporter: John Krueger
>             Fix For: 2.1.1
>
>
> Imported or included xslt stylesheets are not found when using the XSLTResult type.
> According to the javadoc for the org.apache.struts2.views.xslt.ServletURIResolver class, the href atttribute on the following xslt element should allow the transformer to retrieve the resource, common.xsl, but Xalan does not find it.
>   <xsl:include href="response:WEB-INF/xslt/common.xsl"/>
> After debugging the struts2 source, the problem is that in the XSLTResult class the URIResolver is not being set on the TransformerFactory instance in the getTemplates() method before the xslt source is processed into a Templates object.  I have made and tested this changed in a source build and will try to attach a patch for this fix.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-- 
No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.19.11/1242 - Release Date: 1/24/2008 8:32 PM



[jira] Commented: (WW-2334) XSLTResult does not work with stylesheets that use xsl:include or xsl:import

Posted by "Victor Voronenko (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43775#action_43775 ] 

Victor Voronenko commented on WW-2334:
--------------------------------------

Confirmed, works for me.

This is the exact INCLUDE statement that I successfully tested:

<xsl:include href="response:/WEB-INF/xsl/XslUtils.xsl"/>

(notice the slash character before the WEB-INF: if it's not there then the XSLTResult:execute ( ) breaks on NULL pointer here:

           if (location != null) {
                templates = getTemplates(location);
                transformer = templates.newTransformer();    // <--------- here
            } else
                transformer = TransformerFactory.newInstance().newTransformer();

Still I'm not quite happy with this resolution, because:

1. Even if I don't know what does that "response" mean (namespace?) and I don't want to know,
I am asking you: 
- does the end user (Struts programmer) have any control over it? Is there any attribute or property that user can change without going into tricks ? And to what benefit?

If the answer is : NO then why can't it be set internally, maybe even hardcoded.
Because outside of Struts people DON"T know this syntax.
They know plain <xsl:include href="/WEB-INF/xsl/XslUtils.xsl"/> one.

2. Why should ANY problem in XSLTResult result in a heavy exception that nobody can catch properly?

This is how I am handling it now in my modified XSLTResult class and I am not happy about it:

    public void execute(ActionInvocation invocation) throws Exception {
        try {
            HttpServletResponse response = ServletActionContext.getResponse();
........
        } catch (Exception e) {
    		if (session != null)
    			session.setAttribute("error", "Unable to render XSLT Template (cause unknown), '" + location + "'");
    		else
        		System.err.println("XSLTResult/execute: failed to set an error attribute.");
    		response.sendRedirect("/HardError.jsp");
        }

If I would not catch it here then it will be promoted to front-end as HTTP 404 error.

INSTEAD:

I need any exceptions that happen here to be promoted to Action's error path, that is here:

<action name="SomeAction" class="com.SomeAction">
	<result name="error">/Error.jsp</result>

Does anybody know HOW TO DO it?

Thank you.


> XSLTResult does not work with stylesheets that use xsl:include or xsl:import
> ----------------------------------------------------------------------------
>
>                 Key: WW-2334
>                 URL: https://issues.apache.org/struts/browse/WW-2334
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 2.0.11
>            Reporter: John Krueger
>            Assignee: Don Brown
>             Fix For: 2.1.1
>
>
> Imported or included xslt stylesheets are not found when using the XSLTResult type.
> According to the javadoc for the org.apache.struts2.views.xslt.ServletURIResolver class, the href atttribute on the following xslt element should allow the transformer to retrieve the resource, common.xsl, but Xalan does not find it.
>   <xsl:include href="response:WEB-INF/xslt/common.xsl"/>
> After debugging the struts2 source, the problem is that in the XSLTResult class the URIResolver is not being set on the TransformerFactory instance in the getTemplates() method before the xslt source is processed into a Templates object.  I have made and tested this changed in a source build and will try to attach a patch for this fix.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2334) XSLTResult does not work with stylesheets that use xsl:include or xsl:import

Posted by "Steve Wolke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43113#action_43113 ] 

Steve Wolke commented on WW-2334:
---------------------------------

The diff below resolved this problem for me.

Index: XSLTResult.java
===================================================================
--- XSLTResult.java     (revision 615211)
+++ XSLTResult.java     (working copy)
@@ -408,6 +408,7 @@
                 LOG.debug("Preparing XSLT stylesheet templates: " + path);

                 TransformerFactory factory = TransformerFactory.newInstance();
+                factory.setURIResolver(getURIResolver());
                 templates = factory.newTemplates(new StreamSource(resource.openStream()));
                 templatesCache.put(path, templates);
             }


> XSLTResult does not work with stylesheets that use xsl:include or xsl:import
> ----------------------------------------------------------------------------
>
>                 Key: WW-2334
>                 URL: https://issues.apache.org/struts/browse/WW-2334
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 2.0.11
>            Reporter: John Krueger
>             Fix For: 2.1.1
>
>
> Imported or included xslt stylesheets are not found when using the XSLTResult type.
> According to the javadoc for the org.apache.struts2.views.xslt.ServletURIResolver class, the href atttribute on the following xslt element should allow the transformer to retrieve the resource, common.xsl, but Xalan does not find it.
>   <xsl:include href="response:WEB-INF/xslt/common.xsl"/>
> After debugging the struts2 source, the problem is that in the XSLTResult class the URIResolver is not being set on the TransformerFactory instance in the getTemplates() method before the xslt source is processed into a Templates object.  I have made and tested this changed in a source build and will try to attach a patch for this fix.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2334) XSLTResult does not work with stylesheets that use xsl:include or xsl:import

Posted by "John Krueger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43122#action_43122 ] 

John Krueger commented on WW-2334:
----------------------------------

I thought setting the uri resolver on the Transformer should work too but it doesn't.  I believe the difference is that when a Templates object creates the Transformer the XSL style sheet has already been processed or compiled.  I have not dug into the Xalan code but I assume it resolves the URIs used in document(), xsl:import, or xsl:include at the time the style sheet is compiled.  From my testing setting the URIResolver on a Transformer that was created using Templates.newTransformer() has no impact.

The diff Steve provided works for me.

> XSLTResult does not work with stylesheets that use xsl:include or xsl:import
> ----------------------------------------------------------------------------
>
>                 Key: WW-2334
>                 URL: https://issues.apache.org/struts/browse/WW-2334
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 2.0.11
>            Reporter: John Krueger
>             Fix For: 2.1.1
>
>
> Imported or included xslt stylesheets are not found when using the XSLTResult type.
> According to the javadoc for the org.apache.struts2.views.xslt.ServletURIResolver class, the href atttribute on the following xslt element should allow the transformer to retrieve the resource, common.xsl, but Xalan does not find it.
>   <xsl:include href="response:WEB-INF/xslt/common.xsl"/>
> After debugging the struts2 source, the problem is that in the XSLTResult class the URIResolver is not being set on the TransformerFactory instance in the getTemplates() method before the xslt source is processed into a Templates object.  I have made and tested this changed in a source build and will try to attach a patch for this fix.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WW-2334) XSLTResult does not work with stylesheets that use xsl:include or xsl:import

Posted by "Don Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2334?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Don Brown resolved WW-2334.
---------------------------

    Resolution: Fixed
      Assignee: Don Brown

Fixed, thanks for the patch!

> XSLTResult does not work with stylesheets that use xsl:include or xsl:import
> ----------------------------------------------------------------------------
>
>                 Key: WW-2334
>                 URL: https://issues.apache.org/struts/browse/WW-2334
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 2.0.11
>            Reporter: John Krueger
>            Assignee: Don Brown
>             Fix For: 2.1.1
>
>
> Imported or included xslt stylesheets are not found when using the XSLTResult type.
> According to the javadoc for the org.apache.struts2.views.xslt.ServletURIResolver class, the href atttribute on the following xslt element should allow the transformer to retrieve the resource, common.xsl, but Xalan does not find it.
>   <xsl:include href="response:WEB-INF/xslt/common.xsl"/>
> After debugging the struts2 source, the problem is that in the XSLTResult class the URIResolver is not being set on the TransformerFactory instance in the getTemplates() method before the xslt source is processed into a Templates object.  I have made and tested this changed in a source build and will try to attach a patch for this fix.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2334) XSLTResult does not work with stylesheets that use xsl:include or xsl:import

Posted by "John Krueger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43763#action_43763 ] 

John Krueger commented on WW-2334:
----------------------------------

The ServletURIResolver in Struts2 uses "response:" not "request:"   

The following is working in my project.

  <xsl:include href="response:WEB-INF/xslt/common.xsl"/>

> XSLTResult does not work with stylesheets that use xsl:include or xsl:import
> ----------------------------------------------------------------------------
>
>                 Key: WW-2334
>                 URL: https://issues.apache.org/struts/browse/WW-2334
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 2.0.11
>            Reporter: John Krueger
>            Assignee: Don Brown
>             Fix For: 2.1.1
>
>
> Imported or included xslt stylesheets are not found when using the XSLTResult type.
> According to the javadoc for the org.apache.struts2.views.xslt.ServletURIResolver class, the href atttribute on the following xslt element should allow the transformer to retrieve the resource, common.xsl, but Xalan does not find it.
>   <xsl:include href="response:WEB-INF/xslt/common.xsl"/>
> After debugging the struts2 source, the problem is that in the XSLTResult class the URIResolver is not being set on the TransformerFactory instance in the getTemplates() method before the xslt source is processed into a Templates object.  I have made and tested this changed in a source build and will try to attach a patch for this fix.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2334) XSLTResult does not work with stylesheets that use xsl:include or xsl:import

Posted by "Victor Voronenko (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43756#action_43756 ] 

Victor Voronenko commented on WW-2334:
--------------------------------------

Sorry, but this issue IS NOT QUITE RESOLVED.

It still generates the error for <xsl:include> in the latest XSLTResult.java class with enchanced error handling added by Don.

The error occurrs in execute() method right BEFORE Don's code that would set the transformer.setErrorListener:

if (location != null) {
    templates = getTemplates(location);
    transformer = templates.newTransformer();    // <----------  here (java.lang.NullPointerException)
} else
    transformer = TransformerFactory.newInstance().newTransformer();

The error message is:
ERROR [com.tss.admin.revreal.transform.XSLTResult] - Unable to render XSLT Template, '/WEB-INF/xsl/dealSheet.xsl'
java.lang.NullPointerException

SystemErr     R (Location of error unknown)Cannot handle procotol of resource /WEB-INF/xsl/applicationUtils.xsl

This misspelled word from the message can serve as a marker to find the origin of an error:    "p  r  o  c  o  t  o  l  " ("proCoTol" instead of "proToCol").

Googling this issue may bring a very old response from Don to add the "request:" prefix before the included URL, that is:
	<xsl:include href="request:/WEB-INF/xsl/applicationUtils.xsl"/>

Unfortunately, does not work for me.


> XSLTResult does not work with stylesheets that use xsl:include or xsl:import
> ----------------------------------------------------------------------------
>
>                 Key: WW-2334
>                 URL: https://issues.apache.org/struts/browse/WW-2334
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 2.0.11
>            Reporter: John Krueger
>            Assignee: Don Brown
>             Fix For: 2.1.1
>
>
> Imported or included xslt stylesheets are not found when using the XSLTResult type.
> According to the javadoc for the org.apache.struts2.views.xslt.ServletURIResolver class, the href atttribute on the following xslt element should allow the transformer to retrieve the resource, common.xsl, but Xalan does not find it.
>   <xsl:include href="response:WEB-INF/xslt/common.xsl"/>
> After debugging the struts2 source, the problem is that in the XSLTResult class the URIResolver is not being set on the TransformerFactory instance in the getTemplates() method before the xslt source is processed into a Templates object.  I have made and tested this changed in a source build and will try to attach a patch for this fix.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2334) XSLTResult does not work with stylesheets that use xsl:include or xsl:import

Posted by "Don Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43099#action_43099 ] 

Don Brown commented on WW-2334:
-------------------------------

Why would that be any different than setting the uri resolver on the Transformer object itself?  It seems like that should ensure the uri resolver is used, no matter how the Transformer is created.

> XSLTResult does not work with stylesheets that use xsl:include or xsl:import
> ----------------------------------------------------------------------------
>
>                 Key: WW-2334
>                 URL: https://issues.apache.org/struts/browse/WW-2334
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 2.0.11
>            Reporter: John Krueger
>             Fix For: 2.1.1
>
>
> Imported or included xslt stylesheets are not found when using the XSLTResult type.
> According to the javadoc for the org.apache.struts2.views.xslt.ServletURIResolver class, the href atttribute on the following xslt element should allow the transformer to retrieve the resource, common.xsl, but Xalan does not find it.
>   <xsl:include href="response:WEB-INF/xslt/common.xsl"/>
> After debugging the struts2 source, the problem is that in the XSLTResult class the URIResolver is not being set on the TransformerFactory instance in the getTemplates() method before the xslt source is processed into a Templates object.  I have made and tested this changed in a source build and will try to attach a patch for this fix.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.