You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Vjacheslav Borisov (JIRA)" <ji...@apache.org> on 2015/04/08 13:33:12 UTC

[jira] [Commented] (CXF-6150) Override XSLTJaxbProvider xsl path at runtime

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

Vjacheslav Borisov commented on CXF-6150:
-----------------------------------------

xslt.template allows to serve different mime types from same resource using different xslt files

Just need to add annotation to resource method  with All mime types served using xslt
@XSLTTransform(value = "/path/to/xhtml_representation.xsl", mediaTypes = {"application/xhtml+xml", "text/csv" }, type = XSLTTransform.TransformType.SERVER)

and in code specify xslt override path (and add some headers if need, like Content-Disposition)

            if (messageContext.getHttpHeaders().getAcceptableMediaTypes().get(0).toString().equals("text/csv")){
                messageContext.put("xslt.template","/path/to/csv_representation.xsl");
            }


> Override XSLTJaxbProvider xsl path at runtime
> ---------------------------------------------
>
>                 Key: CXF-6150
>                 URL: https://issues.apache.org/jira/browse/CXF-6150
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>    Affects Versions: 3.0.2
>            Reporter: Vjacheslav Borisov
>            Assignee: Sergey Beryozkin
>            Priority: Minor
>             Fix For: 3.0.4, 3.1.0
>
>
> XSLTJaxbProvider xslt url could be configured at runtime using MessageContext:
> eg, at jax-rs method 
> messageContext.put("xslt.template","stylesheets/path/to/xsl");
> and in XSLTJaxbProvider::getOutTemplates 
> {code:title=XSLTJaxbProvider.java|borderStyle=solid}
>         MessageContext mc = getContext();
>         if (mc != null) {
>             String template=(String)mc.getContextualProperty("xslt.template");
>             if(template!=null){
>                 t=createTemplates(template);
>             }
>         }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)