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

Vjacheslav Borisov commented on CXF-5625:
-----------------------------------------

Yes, I can configure XSLTJaxbProvider with Spring, but *without Spring* this is 
not possible (or not so beatiful)
And I think that contextual annotation of method with @XMLInstruction is more  
readable in many cases and does not require Spring at all.

In the other case this is only client-side xslt transformation. And client-side 
transformation is not always applicable.

I think that @XMLInstruction can be used equally for both client side and 
server-side transformation.

And yes, to get XSLTJaxbProvider updated, there is need option, to which mime 
type from list of @Produces it applies
Currently I hardcoded that server-side @XMLInstruction applies to *second* 
mime-type in @Produces list (application/xhtml+xml), and hardcode is really bad 
and not applicable in public lib (see resultMt=values[1] in my source):

            if(a instanceof Produces){
                String values[]=((Produces) a).value();
                if (values.length>1) {
                    resultMt=values[1];
                }
            }

Another options could be parsing <xsl:output
media-type="application/xhtml+xml" (but with overhead to processing)
or adding parameter mimeType="sometype" to @XMLInstruction to specify to which 
mime-type it applies

In current realistion different Accept: mime type leads to different result
With 
curl  http://tomcat-bystrobank.rhcloud.com/testappjava/web/document/list
serves text/xml (raw object model with clint-side transformation)

With
curl -H "Accept: application/xhtml+xml" 
http://tomcat-bystrobank.rhcloud.com/testappjava/web/document/list
serves application/xhtml+xml (server-side transformation)

There may be another realistions of logic, example by examining user-agent.

Actually i don't mind if you accept or reject this request (in any possible 
realisation).
I only want that someone else can find this solution if need,  so I posted it 
there.

> Server side xslt transformation using @XMLInstruction
> -----------------------------------------------------
>
>                 Key: CXF-5625
>                 URL: https://issues.apache.org/jira/browse/CXF-5625
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>    Affects Versions: 3.0.0-milestone2
>            Reporter: Vjacheslav Borisov
>            Priority: Minor
>
> XSLTJaxbProvider could look to @XMLInstruction to determine path to xslt 
> transformation, like this
>     @Produces({"text/xml", "application/xhtml+xml"})
>     @XMLInstruction("<?xml-stylesheet type=\"text/xsl\" 
> href=\"../../stylesheets/testappjava/document.xsl\"?>")
> Like this
> https://github.com/bystrobank/testappjava/blob/master/src/main/java/ru/ilb/common/rs/XsiXSLTJaxbProvider.java
> But realisation is hardcoded that xslt is applied to second mime type in 
> @Produces annotation ("application/xhtml+xml")  
> May be this hardcode is not applicable in public library
> This can be used to write service that can be used both with server-side and 
> client-side xslt transformation identically or to serve xml or html  based on 
> Accept: header
> Deployed application
> http://tomcat-bystrobank.rhcloud.com/testappjava/web/document/list



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

Reply via email to