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

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

To fix  string1 set to null, need to  call source.setSystemId() (see 
http://stackoverflow.com/questions/3699860/resolving-relative-paths-when-loading-xslt-files):
also need loc parameter to be added:
protected Templates createTemplates(InputStream is,String loc) {
...
            Source source = new StreamSource(r);
            source.setSystemId(new File(loc).getName());

..
}

then URIResolver could be like this:

public class ServletContextURIResolver implements URIResolver {

    @Override
    public Source resolve(String string, String string1) throws 
TransformerException {
        URL u;
        try {
            u=new URL(new URL(string1), string);
            return new StreamSource(u.openStream());
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }
}


> 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
>            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)

Reply via email to