Author: asankha
Date: Tue Nov 20 04:00:11 2007
New Revision: 596636
URL: http://svn.apache.org/viewvc?rev=596636&view=rev
Log:
allow XSLT transformation results to be stored as message context properties
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XSLTMediatorFactory.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XSLTMediatorSerializer.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/transform/XSLTMediator.java
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XSLTMediatorFactory.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XSLTMediatorFactory.java?rev=596636&r1=596635&r2=596636&view=diff
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XSLTMediatorFactory.java
(original)
+++
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XSLTMediatorFactory.java
Tue Nov 20 04:00:11 2007
@@ -37,7 +37,7 @@
* Creates a XSLT mediator from the given XML
*
* <pre>
- * <xslt key="property-key" [source="xpath"]>
+ * <xslt key="property-key" [source="xpath"] [target="string"]>
* <property name="string" (value="literal" | expression="xpath")/>*
* </transform>
* </pre>
@@ -56,6 +56,7 @@
OMAttribute attXslt = elem.getAttribute(ATT_KEY);
OMAttribute attSource = elem.getAttribute(ATT_SOURCE);
+ OMAttribute attTarget = elem.getAttribute(ATT_TARGET);
if (attXslt != null) {
transformMediator.setXsltKey(attXslt.getAttributeValue());
@@ -75,6 +76,11 @@
attSource.getAttributeValue());
}
}
+
+ if (attTarget != null) {
+
transformMediator.setTargetPropertyName(attTarget.getAttributeValue());
+ }
+
// after successfully creating the mediator
// set its common attributes such as tracing etc
processTraceState(transformMediator, elem);
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XSLTMediatorSerializer.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XSLTMediatorSerializer.java?rev=596636&r1=596635&r2=596636&view=diff
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XSLTMediatorSerializer.java
(original)
+++
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XSLTMediatorSerializer.java
Tue Nov 20 04:00:11 2007
@@ -32,7 +32,7 @@
/**
* <pre>
- * <xslt key="property-key" [source="xpath"]>
+ * <xslt key="property-key" [source="xpath"] [target="string"]>
* <property name="string" (value="literal" | expression="xpath")/>*
* </transform>
* </pre>
@@ -61,6 +61,10 @@
xslt.addAttribute(fac.createOMAttribute(
"source", nullNS, mediator.getSource().toString()));
serializeNamespaces(xslt, mediator.getSource());
+ }
+ if (mediator.getTargetPropertyName() != null) {
+ xslt.addAttribute(fac.createOMAttribute(
+ "target", nullNS, mediator.getTargetPropertyName()));
}
serializeProperties(xslt, mediator.getProperties());
List features = mediator.getFeatures();
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/transform/XSLTMediator.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/transform/XSLTMediator.java?rev=596636&r1=596635&r2=596636&view=diff
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/transform/XSLTMediator.java
(original)
+++
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/transform/XSLTMediator.java
Tue Nov 20 04:00:11 2007
@@ -103,6 +103,11 @@
private AXIOMXPath source = null;
/**
+ * The name of the message context property to store the transformation
result
+ */
+ private String targetPropertyName = null;
+
+ /**
* Any parameters which should be passed into the XSLT transformation
*/
private List properties = new ArrayList();
@@ -439,14 +444,22 @@
}
}
- if (traceOrDebugOn) {
- traceOrDebug(traceOn, "Replace source node with result");
+ if (targetPropertyName != null) {
+ // add result XML as a message context property to the message
+ if (traceOrDebugOn) {
+ traceOrDebug(traceOn, "Adding result as message context
property : " +
+ targetPropertyName);
+ }
+ synCtx.setProperty(targetPropertyName, result);
+ } else {
+ if (traceOrDebugOn) {
+ traceOrDebug(traceOn, "Replace source node with result");
+ }
+ // replace the sourceNode with the result.
+ sourceNode.insertSiblingAfter(result);
+ sourceNode.detach();
}
- // replace the sourceNode with the result.
- sourceNode.insertSiblingAfter(result);
- sourceNode.detach();
-
} catch (TransformerException e) {
handleException("Error performing XSLT transformation using : " +
xsltKey, e, synCtx);
}
@@ -600,6 +613,14 @@
public void setSourceXPathString(String sourceXPathString) {
this.sourceXPathString = sourceXPathString;
+ }
+
+ public String getTargetPropertyName() {
+ return targetPropertyName;
+ }
+
+ public void setTargetPropertyName(String targetPropertyName) {
+ this.targetPropertyName = targetPropertyName;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]