You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2008/11/08 23:19:14 UTC

svn commit: r712442 - in /ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep: v1/xpath20/JaxpFunctionResolver.java v2/xpath20/JaxpFunctionResolver.java

Author: mriou
Date: Sat Nov  8 14:19:14 2008
New Revision: 712442

URL: http://svn.apache.org/viewvc?rev=712442&view=rev
Log:
ODE-408 Missed part of the patch in commit.

Modified:
    ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath20/JaxpFunctionResolver.java
    ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xpath20/JaxpFunctionResolver.java

Modified: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath20/JaxpFunctionResolver.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath20/JaxpFunctionResolver.java?rev=712442&r1=712441&r2=712442&view=diff
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath20/JaxpFunctionResolver.java (original)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath20/JaxpFunctionResolver.java Sat Nov  8 14:19:14 2008
@@ -280,43 +280,20 @@
             Document varDoc = DOMUtils.newDocument();
             varDoc.appendChild(varDoc.importNode(varElmt, true));
 
+            Object result;
             DOMSource source = new DOMSource(varDoc);
-            // Using a StreamResult as a DOMResult doesn't behaves properly when the result
-            // of the transformation is just a string.
-            StringWriter writerResult = new StringWriter();
-            StreamResult result = new StreamResult(writerResult);
             XslRuntimeUriResolver resolver = new XslRuntimeUriResolver(_oxpath, _ectx.getBaseResourceURI());
             XslTransformHandler.getInstance().cacheXSLSheet(xslUri, xslSheet.sheetBody, resolver);
             try {
-                XslTransformHandler.getInstance().transform(xslUri, source, result, parametersMap, resolver);
+                result = XslTransformHandler.getInstance().transform(xslUri, source, parametersMap, resolver);
             } catch (Exception e) {
                 e.printStackTrace();
                 throw new XPathFunctionException(
                         new FaultException(_oxpath.getOwner().constants.qnSubLanguageExecutionFault,
                                 e.toString()));
             }
-            writerResult.flush();
-
-            String output = writerResult.toString();
-            if (__log.isDebugEnabled())
-                __log.debug("Returned by XSL Sheet: " + output);
-            // I'm not really proud of that but hey, it does the job and I don't think there's
-            // any other easy way.
-            if (output.startsWith("<?xml")) {
-                try {
-                    return DOMUtils.stringToDOM(output).getChildNodes();
-                } catch (SAXException e) {
-                    throw new XPathFunctionException("Parsing the result of the XSL sheet " + args.get(0) +
-                            " didn't produce a parsable XML result: " + output);
-                } catch (IOException e) {
-                    throw new XPathFunctionException(e);
-                } catch (Exception e) {
-                    throw new XPathFunctionException("Parsing the result of the XSL sheet " + args.get(0) +
-                            " didn't produce a parsable XML result: " + output);
-                }
-            } else {
-                return output;
-            }
+            if(result instanceof Node) return ((Node)result).getChildNodes();
+            else return result;
         }
     }
     

Modified: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xpath20/JaxpFunctionResolver.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xpath20/JaxpFunctionResolver.java?rev=712442&r1=712441&r2=712442&view=diff
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xpath20/JaxpFunctionResolver.java (original)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xpath20/JaxpFunctionResolver.java Sat Nov  8 14:19:14 2008
@@ -284,43 +284,20 @@
             Document varDoc = DOMUtils.newDocument();
             varDoc.appendChild(varDoc.importNode(varElmt, true));
 
+            Object result;
             DOMSource source = new DOMSource(varDoc);
-            // Using a StreamResult as a DOMResult doesn't behaves properly when the result
-            // of the transformation is just a string.
-            StringWriter writerResult = new StringWriter();
-            StreamResult result = new StreamResult(writerResult);
             XslRuntimeUriResolver resolver = new XslRuntimeUriResolver(_oxpath, _ectx.getBaseResourceURI());
             XslTransformHandler.getInstance().cacheXSLSheet(xslUri, xslSheet.sheetBody, resolver);
             try {
-                XslTransformHandler.getInstance().transform(xslUri, source, result, parametersMap, resolver);
+                result = XslTransformHandler.getInstance().transform(xslUri, source, parametersMap, resolver);
             } catch (Exception e) {
                 e.printStackTrace();
                 throw new XPathFunctionException(
                         new FaultException(_oxpath.getOwner().constants.qnSubLanguageExecutionFault,
                                 e.toString()));
             }
-            writerResult.flush();
-
-            String output = writerResult.toString();
-            if (__log.isDebugEnabled())
-                __log.debug("Returned by XSL Sheet: " + output);
-            // I'm not really proud of that but hey, it does the job and I don't think there's
-            // any other easy way.
-            if (output.startsWith("<?xml")) {
-                try {
-                    return DOMUtils.stringToDOM(output).getChildNodes();
-                } catch (SAXException e) {
-                    throw new XPathFunctionException("Parsing the result of the XSL sheet " + args.get(0) +
-                            " didn't produce a parsable XML result: " + output);
-                } catch (IOException e) {
-                    throw new XPathFunctionException(e);
-                } catch (Exception e) {
-                    throw new XPathFunctionException("Parsing the result of the XSL sheet " + args.get(0) +
-                            " didn't produce a parsable XML result: " + output);
-                }
-            } else {
-                return output;
-            }
+            if(result instanceof Node) return ((Node)result).getChildNodes();
+            else return result;
         }
     }