You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by aj...@apache.org on 2007/07/02 09:44:51 UTC

svn commit: r552419 - in /webservices/commons/trunk/modules/XmlSchema/src: main/java/org/apache/ws/commons/schema/ test/java/tests/ test/test-resources/

Author: ajith
Date: Mon Jul  2 00:44:50 2007
New Revision: 552419

URL: http://svn.apache.org/viewvc?view=rev&rev=552419
Log:
1. Fixed issue WSCOMMONS-153
2. Added a test case for the appinfo serialization

Added:
    webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AppInfoMarkupTest.java
    webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/appInfo.xsd
Modified:
    webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
    webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java

Modified: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java?view=diff&rev=552419&r1=552418&r2=552419
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java Mon Jul  2 00:44:50 2007
@@ -1754,7 +1754,7 @@
      */
     XmlSchemaAppInfo handleAppInfo(Element content) {
         XmlSchemaAppInfo appInfo = new XmlSchemaAppInfo();
-        NodeList markup = getChild(content);
+        NodeList markup = getChildren(content);
 
         if (!content.hasAttribute("source") &&
                 (markup == null || markup.getLength() <= 0)) {
@@ -1768,7 +1768,7 @@
     //iterate each documentation element, create new XmlSchemaAppinfo and add to collection
     XmlSchemaDocumentation handleDocumentation(Element content) {
         XmlSchemaDocumentation documentation = new XmlSchemaDocumentation();
-        NodeList markup = getChild(content);
+        NodeList markup = getChildren(content);
 
         if (!content.hasAttribute("source") &&
                 !content.hasAttribute("xml:lang") &&
@@ -1777,7 +1777,7 @@
 
         documentation.setSource(getAttribute(content, "source"));
         documentation.setLanguage(getAttribute(content, "xml:lang"));
-        documentation.setMarkup(getChild(content));
+        documentation.setMarkup(getChildren(content));
 
         return documentation;
     }
@@ -1788,7 +1788,7 @@
         return null;
     }
 
-    private NodeList getChild(Element content) {
+    private NodeList getChildren(Element content) {
         NodeList childs = content.getChildNodes();
         if (childs.getLength() > 0)
             return childs;

Modified: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java?view=diff&rev=552419&r1=552418&r2=552419
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java Mon Jul  2 00:44:50 2007
@@ -1987,17 +1987,7 @@
             int markupLength = appInfoObj.markup.getLength();
             for (int j = 0; j < markupLength; j++) {
                 Node n = appInfoObj.markup.item(j);
-                switch (n.getNodeType()) {
-                    case Node.ELEMENT_NODE:
-                        appendElement(doc, appInfoEl, n, schema);
-                        break;
-                    case Node.TEXT_NODE:
-                        Text t = doc.createTextNode(n.getNodeValue());
-                        appInfoEl.appendChild(t);
-                        break;
-                    default:
-                        break;
-                }
+               appInfoEl.appendChild(doc.importNode(n,true));
             }
         }
 

Added: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AppInfoMarkupTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AppInfoMarkupTest.java?view=auto&rev=552419
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AppInfoMarkupTest.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AppInfoMarkupTest.java Mon Jul  2 00:44:50 2007
@@ -0,0 +1,58 @@
+/*
+ * 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 tests;
+
+import junit.framework.TestCase;
+
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ByteArrayInputStream;
+
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.custommonkey.xmlunit.XMLTestCase;
+import org.w3c.dom.Document;
+
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import sun.management.counter.ByteArrayCounter;
+
+
+public class AppInfoMarkupTest extends XMLTestCase {
+
+    public void testAppInfo() throws Exception{
+        DocumentBuilder b = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+        Document pureDOMDocument = b.parse(new FileInputStream(Resources.asURI("appInfo.xsd")));
+
+        InputStream is = new FileInputStream(Resources.asURI("appInfo.xsd"));
+        XmlSchemaCollection schema = new XmlSchemaCollection();
+        XmlSchema s = schema.read(new StreamSource(is), null);
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        s.write(baos);
+
+        Document serialzedDoument = b.parse(new ByteArrayInputStream(baos.toByteArray()));
+        XMLUnit.compareXML(pureDOMDocument,serialzedDoument);
+
+    }
+
+}

Added: webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/appInfo.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/appInfo.xsd?view=auto&rev=552419
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/appInfo.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/appInfo.xsd Mon Jul  2 00:44:50 2007
@@ -0,0 +1,7 @@
+<xs:schema targetNamespace="http://foo" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+  <xs:annotation>
+    <xs:appinfo>
+      <ns01:bar xmlns:ns01="http://anyuri"/>
+    </xs:appinfo>
+  </xs:annotation>
+</xs:schema> 
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org