You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2011/04/04 21:05:40 UTC

svn commit: r1088730 - in /axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans: XmlBeansXMLReader.java template/XmlbeansDatabindingTemplate.xsl

Author: veithen
Date: Mon Apr  4 19:05:40 2011
New Revision: 1088730

URL: http://svn.apache.org/viewvc?rev=1088730&view=rev
Log:
Changed the XmlBeans databinding to make use of the API defined in r1088682.

Added:
    axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/XmlBeansXMLReader.java   (with props)
Modified:
    axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/template/XmlbeansDatabindingTemplate.xsl

Added: axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/XmlBeansXMLReader.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/XmlBeansXMLReader.java?rev=1088730&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/XmlBeansXMLReader.java (added)
+++ axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/XmlBeansXMLReader.java Mon Apr  4 19:05:40 2011
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.xmlbeans;
+
+import java.io.IOException;
+
+import org.apache.axiom.util.sax.AbstractXMLReader;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class XmlBeansXMLReader extends AbstractXMLReader {
+    private final XmlObject object;
+    private final XmlOptions options;
+    
+    public XmlBeansXMLReader(XmlObject object, XmlOptions options) {
+        this.object = object;
+        this.options = options;
+    }
+
+    public void parse(InputSource input) throws IOException, SAXException {
+        parse();
+    }
+
+    public void parse(String systemId) throws IOException, SAXException {
+        parse();
+    }
+    
+    private void parse() throws SAXException {
+        object.save(contentHandler, lexicalHandler, options);
+    }
+}

Propchange: axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/XmlBeansXMLReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/template/XmlbeansDatabindingTemplate.xsl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/template/XmlbeansDatabindingTemplate.xsl?rev=1088730&r1=1088729&r2=1088730&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/template/XmlbeansDatabindingTemplate.xsl (original)
+++ axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/template/XmlbeansDatabindingTemplate.xsl Mon Apr  4 19:05:40 2011
@@ -64,15 +64,14 @@
             private org.apache.axiom.om.OMElement toOM(final <xsl:value-of select="@type"/> param)
                     throws org.apache.axis2.AxisFault {
 
-                org.apache.axiom.om.impl.builder.SAXOMBuilder builder = new org.apache.axiom.om.impl.builder.SAXOMBuilder();
                 org.apache.xmlbeans.XmlOptions xmlOptions = new org.apache.xmlbeans.XmlOptions();
                 xmlOptions.setSaveNoXmlDecl();
                 xmlOptions.setSaveAggressiveNamespaces();
                 xmlOptions.setSaveNamespacesFirst();
+                org.apache.axiom.om.OMXMLParserWrapper builder = org.apache.axiom.om.OMXMLBuilderFactory.createSAXOMBuilder(
+                        new javax.xml.transform.sax.SAXSource(new org.apache.axis2.xmlbeans.XmlBeansXMLReader(param, xmlOptions), new org.xml.sax.InputSource()));
                 try {
-                   param.save(builder, builder, xmlOptions);
-                   org.apache.axiom.om.OMElement element = builder.getRootElement();
-                   return element;
+                    return builder.getDocumentElement(true);
                 } catch (java.lang.Exception e) {
                     throw org.apache.axis2.AxisFault.makeFault(e);
                 }