cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vjacheslav Borisov (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CXF-5849) XSLTJaxbProvider document() resources and URIResolver
Date Sun, 06 Jul 2014 17:31:34 GMT

    [ https://issues.apache.org/jira/browse/CXF-5849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14053158#comment-14053158
] 

Vjacheslav Borisov commented on CXF-5849:
-----------------------------------------

checked, relative xsl includes also not working  in server-side xslt  (like <xsl:include
href="controls.xsl" />)

to make relative xsl:include (and document() function) work in server-side xslt, need to setSystemId
in createTemplates method  (and also pass loc parameter)

{code:title=XSLTJaxbProvider.java|borderStyle=solid}
    protected Templates createTemplates(InputStream is){
        return createTemplates(is,null);
    }
    protected Templates createTemplates(InputStream is,String loc) {
        /* cut */
        Source source = new StreamSource(r);
        // this line added
        source.setSystemId(ResourceUtils.getResourceURL(loc, this.getBus()).toExternalForm());
        /* cut */
    }
{code}

and ServletContextURIResolver should  setSystemId on any resource it resolves (to make resources
resolving  work recursive in  includes):
{code:title=ServletContextURIResolver.java|borderStyle=solid}
public class ServletContextURIResolver implements URIResolver {
    private static final Logger LOG = LogUtils.getL7dLogger(ServletContextURIResolver.class);

    @Override
    public Source resolve(String string, String string1) throws TransformerException {
        URL url;
        try {
            url = new URL(new URL(string1), string);
            Source source=new StreamSource(url.openStream());
            source.setSystemId(url.toExternalForm());
            return source;
        } catch (IOException ex) {
            LOG.warning("URIResolver exception : " + ex.getMessage());
            throw new RuntimeException(ex);
        }

    }
}
{code}

> XSLTJaxbProvider document() resources and URIResolver
> -----------------------------------------------------
>
>                 Key: CXF-5849
>                 URL: https://issues.apache.org/jira/browse/CXF-5849
>             Project: CXF
>          Issue Type: New Feature
>            Reporter: Vjacheslav Borisov
>            Assignee: Sergey Beryozkin
>            Priority: Minor
>
> XSLTJaxbProvider provider may include some default URIResolver class, to resolve relative
adressed resources included in xslt with document('path/to/file')
> Currently relative addressing  works only in case of Client-side xslt transformation
XSLTTransform.TransformType.CLIENT (when browser resolves relative paths) 
> Eg I have {WEBROOT}/stylesheets/document.xsl and  {WEBROOT}/schemas/document.xsd
> and I can relatively address document.xsd with 
> document('../schemas/document.xsd')
> But in case of XSLTTransform.TransformType.SERVER relative address is comuted against
current dir (user.dir property, which defaults to ${catalina_home}/bin) and not against dir
where xslt file is placed.
> So XSLTTransform.TransformType.SERVER differs from XSLTTransform.TransformType.CLIENT.
> As a workaround if this is unacceptable, can someone  point me is it possible to configure
XSLTJaxbProvider uri resolver without Spring?



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message