cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache CXF Documentation > XSLT Feature
Date Fri, 09 Nov 2012 09:55:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CXF20DOC&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CXF20DOC/XSLT+Feature">XSLT
Feature</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~ashakirin">Andrei
Shakirin</a>
    </h4>
        <br/>
                         <h4>Changes (5)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>If you should apply non-trivial
transformation, not supported by Transformation Feature - it is use case for XSLT Feature.
Here you can write any custom XSL Transformation and apply it to inbound and/or outbound messages.
<br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">As
far as Xalan XSLT engine is not completely stream oriented, XSLT Feature breaks streaming.
However it uses high-performance DTM (Document Table Model) instead complete DOM model. Performance
can be improved in the future by using newer versions of Xalan or other XSLT engines (like
Saxon or STX oriented Joost). <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">As
far as Xalan XSLT engine is actually not completely stream oriented, XSLT Feature breaks streaming.
However it uses high-performance DTM (Document Table Model) instead complete DOM model. <br>Performance
can be improved in the future by using further versions of Xalan or other XSLT engines (like
Saxon or STX oriented Joost). <br></td></tr>
            <tr><td class="diff-unchanged" > <br>h1. Spring configuration
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >The XSLT scripts should be available
from the classpath. <span class="diff-added-words"style="background-color: #dfd;">If
XSLT path is not specified, no transformation will be done.</span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br>h1. Configuring the XSLT
Feature from the Spring/Bluepring <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>By default XSLT interceptors
run on POST_STREAM and PRE_STREAM phases. <br></td></tr>
            <tr><td class="diff-changed-lines" >In some cases it may be needed
to change the phase, for example, the in transformation has to be applied after the encrypted
payload has been decrypted and its signature checked. <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">For
such transformations to succeed XLSTInInterceptor will need to be created with a constructor
accepting a &#39;phase&#39; String parameter, for the interceptor to run after the
decryption and signature validation actions have been performed.</span> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">For
such transformations to succeed XLSTInInterceptor/XSLTOutInterceptor will need to be created
with a constructor accepting a &#39;phase&#39; String parameter. <br>Additionally
you can specify before and after interceptors for this phase as further constructor parameters.
<br></td></tr>
            <tr><td class="diff-unchanged" > <br>h1. Supported message contents
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p><span style="font-size:2em;font-weight:bold"> XSLT Feature </span></p>

<div>
<ul>
    <li><a href='#XSLTFeature-WhenshouldIuseTransformationFeatureandwhenXSLTFeature%3F'>When
should I use Transformation Feature and when XSLT Feature?</a></li>
    <li><a href='#XSLTFeature-Springconfiguration'>Spring configuration</a></li>
    <li><a href='#XSLTFeature-ConfiguringtheXSLTFeaturefromtheSpring%2FBluepring'>Configuring
the XSLT Feature from the Spring/Bluepring</a></li>
    <li><a href='#XSLTFeature-ConfiguringtheXSLTinterceptorsincode'>Configuring
the XSLT interceptors in code</a></li>
    <li><a href='#XSLTFeature-XSLTinterceptorsandphases'>XSLT interceptors and
phases</a></li>
    <li><a href='#XSLTFeature-Supportedmessagecontents'>Supported message contents</a></li>
</ul></div>

<p>The CXF XSLT Feature is alternative to <a href="http://cxf.apache.org/docs/transformationfeature.html"
class="external-link" rel="nofollow">CXF Transformation Feature</a> providing flexible
way to do the dynamic transformations of XML messages. <br/>
XSLT Feature applies custom XSL transformations to inbound and/or outbound messages.</p>

<h1><a name="XSLTFeature-WhenshouldIuseTransformationFeatureandwhenXSLTFeature%3F"></a>When
should I use Transformation Feature and when XSLT Feature?</h1>
<p>If only trivial transformations must be done, it is recommended to use lightweight
and fast Transformation Feature. It covers the most use cases as:</p>
<ul>
	<li>dropping the namespace of the outbound messages;</li>
	<li>qualifying the incoming message;</li>
	<li>changing namespaces;</li>
	<li>appending or dropping elements;</li>
	<li>converting attributes to elements.</li>
</ul>


<p>Transformation Feature is completely stream oriented and work fast especially for
large messages.</p>

<p>If you should apply non-trivial transformation, not supported by Transformation Feature
- it is use case for XSLT Feature. Here you can write any custom XSL Transformation and apply
it to inbound and/or outbound messages.<br/>
As far as Xalan XSLT engine is actually not completely stream oriented, XSLT Feature breaks
streaming. However it uses high-performance DTM (Document Table Model) instead complete DOM
model.<br/>
Performance can be improved in the future by using further versions of Xalan or other XSLT
engines (like Saxon or STX oriented Joost).</p>

<h1><a name="XSLTFeature-Springconfiguration"></a>Spring configuration</h1>

<p>It is necessary to configure XSLT script for inbound or/and outbound transformation.
Example: </p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
    <span class="code-tag">&lt;bean id=<span class="code-quote">"xsltFeature"</span>
class=<span class="code-quote">"org.apache.cxf.feature.transform.XSLTFeature"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"inXSLTPath"</span>
value=<span class="code-quote">"requestTransformation.xsl"</span> /&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"outXSLTPath"</span>
value=<span class="code-quote">"responseTransformation.xsl"</span> /&gt;</span>
    <span class="code-tag">&lt;/bean&gt;</span>
</pre>
</div></div>

<p>The XSLT scripts should be available from the classpath. If XSLT path is not specified,
no transformation will be done.</p>

<h1><a name="XSLTFeature-ConfiguringtheXSLTFeaturefromtheSpring%2FBluepring"></a>Configuring
the XSLT Feature from the Spring/Bluepring</h1>

<p>The feature can be configured from the code for JAX-WS or JAX-RS clients and endpoints.
Example:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
	&lt;jaxws:client id=<span class="code-quote">"customerService"</span> serviceName=<span
class="code-quote">"customer:CustomerServiceService"</span>
		endpointName=<span class="code-quote">"customer:CustomerServiceEndpoint"</span>
address=<span class="code-quote">"http://localhost:9091/CustomerServicePort"</span>
		serviceClass=<span class="code-quote">"com.example.customerservice.CustomerService"</span>&gt;
		<span class="code-tag">&lt;jaxws:features&gt;</span>
			<span class="code-tag">&lt;ref bean=<span class="code-quote">"xsltFeature"</span>
/&gt;</span>
		<span class="code-tag">&lt;/jaxws:features&gt;</span>
	<span class="code-tag">&lt;/jaxws:client&gt;</span>

	&lt;jaxws:endpoint <span class="code-keyword">xmlns:customer</span>=<span
class="code-quote">"http://customerservice.example.com/"</span>
		id=<span class="code-quote">"CustomerServiceHTTP"</span> address=<span class="code-quote">"http://localhost:9090/CustomerServicePort"</span>
		serviceName=<span class="code-quote">"customer:CustomerServiceService"</span>
endpointName=<span class="code-quote">"customer:CustomerServiceEndpoint"</span>
		implementor=<span class="code-quote">"com.example.customerservice.server.CustomerServiceImpl"</span>&gt;
		<span class="code-tag">&lt;jaxws:features&gt;</span>
                      <span class="code-tag">&lt;ref bean=<span class="code-quote">"xsltFeature"</span>
/&gt;</span>
		<span class="code-tag">&lt;/jaxws:features&gt;</span>
	<span class="code-tag">&lt;/jaxws:endpoint&gt;</span>
</pre>
</div></div>

<h1><a name="XSLTFeature-ConfiguringtheXSLTinterceptorsincode"></a>Configuring
the XSLT interceptors in code</h1>

<p>Here is how a JAX-WS client can be configured:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
  CustomerServiceService service = <span class="code-keyword">new</span> CustomerServiceService();
  CustomerService customerService = service.getCustomerServicePort();
  Client client = ClientProxy.getClient(customerService);
  XSLTOutInterceptor outInterceptor = <span class="code-keyword">new</span> XSLTOutInterceptor(Phase.PRE_STREAM,
StaxOutInterceptor.class, <span class="code-keyword">null</span>,
                                                                   XSLT_REQUEST_PATH);
  client.getOutInterceptors().add(outInterceptor);
</pre>
</div></div>

<h1><a name="XSLTFeature-XSLTinterceptorsandphases"></a>XSLT interceptors
and phases</h1>

<p>By default XSLT interceptors run on POST_STREAM and PRE_STREAM phases.<br/>
In some cases it may be needed to change the phase, for example, the in transformation has
to be applied after the encrypted payload has been decrypted and its signature checked.<br/>
For such transformations to succeed XLSTInInterceptor/XSLTOutInterceptor will need to be created
with a constructor accepting a 'phase' String parameter.<br/>
Additionally you can specify before and after interceptors for this phase as further constructor
parameters.</p>

<h1><a name="XSLTFeature-Supportedmessagecontents"></a>Supported message
contents</h1>
<p>The XSLT interceptors support following message contents: </p>
<ul>
	<li>InputStream/OutputStream;</li>
	<li>Reader/Writer;</li>
	<li>XMLStreamReader/XMLStreamWriter.</li>
</ul>


<p>Therefore the interceptors can be used on different phases. XSLT Interceptors were
tested with JMS Transport uses JMS Text messages (produces Reader/Writer message contents).</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/XSLT+Feature">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=30741563&revisedVersion=2&originalVersion=1">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/XSLT+Feature?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message