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 2006/03/16 07:12:00 UTC

svn commit: r386273 - in /webservices/commons/modules/XmlSchema: src/org/apache/ws/commons/schema/SchemaBuilder.java test-resources/anyAttTest.xsd test/tests/AnyAttTest.java

Author: ajith
Date: Wed Mar 15 22:11:59 2006
New Revision: 386273

URL: http://svn.apache.org/viewcvs?rev=386273&view=rev
Log:
1. Fixing the any attribute missing problem. The anyAttribute was missing due to it being not processed in the SchemaBuilder.java
2. Added a test case to the test suite

Added:
    webservices/commons/modules/XmlSchema/test-resources/anyAttTest.xsd
    webservices/commons/modules/XmlSchema/test/tests/AnyAttTest.java
Modified:
    webservices/commons/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java

Modified: webservices/commons/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java?rev=386273&r1=386272&r2=386273&view=diff
==============================================================================
--- webservices/commons/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java (original)
+++ webservices/commons/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java Wed Mar 15 22:11:59 2006
@@ -600,6 +600,9 @@
             } else if (el.getLocalName().equals("annotation")) {
                 XmlSchemaAnnotation ann = handleAnnotation(el);
                 ct.setAnnotation(ann);
+            } else if (el.getLocalName().equals("anyAttribute")) {
+                XmlSchemaAnyAttribute anyAtt = handleAnyAttribute(schema,el,schemaEl);
+                ct.setAnyAttribute(anyAtt);
             }
             //}
         }

Added: webservices/commons/modules/XmlSchema/test-resources/anyAttTest.xsd
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/XmlSchema/test-resources/anyAttTest.xsd?rev=386273&view=auto
==============================================================================
--- webservices/commons/modules/XmlSchema/test-resources/anyAttTest.xsd (added)
+++ webservices/commons/modules/XmlSchema/test-resources/anyAttTest.xsd Wed Mar 15 22:11:59 2006
@@ -0,0 +1,18 @@
+<schema
+    xmlns="http://www.w3.org/2001/XMLSchema"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:tns="http://unqualified-elements.example.com"
+    targetNamespace="http://unqualified-elements.example.com">
+
+    <element name="AnyAttContainer">
+        <complexType>
+            <sequence>
+                <element name="chileValue" type="xsd:string"/>
+            </sequence>
+            <anyAttribute namespace="##other" processContents="lax"></anyAttribute>
+        </complexType>
+    </element>
+
+    <element name="global" type="xsd:int"/>
+
+</schema>

Added: webservices/commons/modules/XmlSchema/test/tests/AnyAttTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/XmlSchema/test/tests/AnyAttTest.java?rev=386273&view=auto
==============================================================================
--- webservices/commons/modules/XmlSchema/test/tests/AnyAttTest.java (added)
+++ webservices/commons/modules/XmlSchema/test/tests/AnyAttTest.java Wed Mar 15 22:11:59 2006
@@ -0,0 +1,66 @@
+package tests;
+
+import junit.framework.TestCase;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaParticle;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaAnyAttribute;
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+public class AnyAttTest extends TestCase {
+
+    protected void setUp() throws Exception {
+
+    }
+
+    public void testAnyAtt() throws Exception{
+          //create a DOM document
+        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+        documentBuilderFactory.setNamespaceAware(true);
+        Document doc = documentBuilderFactory.newDocumentBuilder().
+                parse("test-resources/anyAttTest.xsd");
+
+        XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+        XmlSchema s = schemaCol.read(doc.getDocumentElement());
+
+        //get the element
+        XmlSchemaElement elt = s.getElementByName(new QName("http://unqualified-elements.example.com","AnyAttContainer"));
+        assertNotNull("Element \"AnyAttContainer\" is missing! ",elt);
+
+        XmlSchemaType schemaType = elt.getSchemaType();
+        assertNotNull("Relevant schema type is missing!",schemaType);
+
+        XmlSchemaComplexType xmlSchemaComplexType = ((XmlSchemaComplexType) schemaType);
+        XmlSchemaParticle particle = xmlSchemaComplexType.getParticle();
+        assertNotNull(particle);
+
+        XmlSchemaAnyAttribute anyAttribute = xmlSchemaComplexType.getAnyAttribute();
+        assertNotNull("Any attribute is missing",anyAttribute);
+
+
+    }
+
+}