[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-dev
Subject:    [jira] Commented: (WW-2334) XSLTResult does not work with
From:       "Victor Voronenko (JIRA)" <jira () apache ! org>
Date:       2008-04-30 14:23:05
Message-ID: 1357399693.1209565385344.JavaMail.jira () brutus
[Download RAW message or body]


    [ 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.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic