Author: ajith
Date: Thu Mar 29 18:55:41 2007
New Revision: 523905
URL: http://svn.apache.org/viewvc?view=rev&rev=523905
Log:
1. Moved the custom attribute classes to the attrib package
2. Added new tests and relevant classes /test xsd for the custom element
Added:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttribute.java
- copied, changed from r523836,
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomAttribute.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeDeserializer.java
- copied, changed from r523836,
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomAttributeDeserializer.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeSerializer.java
- copied, changed from r523836,
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomAttributeSerializer.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtDeserializerTest.java
- copied, changed from r523836,
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomExtDeserializerTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionRegistry.java
- copied, changed from r523836,
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomExtensionRegistry.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElement.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementDeserializer.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementSerializer.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtElementDeserializerTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtensionRegistry.java
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/external/externalElementAnnotations.xsd
Removed:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomAttribute.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomAttributeDeserializer.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomAttributeSerializer.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomExtDeserializerTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomExtensionRegistry.java
Copied:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttribute.java
(from r523836,
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomAttribute.java)
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttribute.java?view=diff&rev=523905&p1=webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomAttribute.java&r1=523836&p2=webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttribute.java&r2=523905
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomAttribute.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttribute.java
Thu Mar 29 18:55:41 2007
@@ -1,4 +1,4 @@
-package tests.customext;
+package tests.customext.attrib;
import javax.xml.namespace.QName;
Copied:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeDeserializer.java
(from r523836,
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomAttributeDeserializer.java)
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeDeserializer.java?view=diff&rev=523905&p1=webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomAttributeDeserializer.java&r1=523836&p2=webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeDeserializer.java&r2=523905
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomAttributeDeserializer.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeDeserializer.java
Thu Mar 29 18:55:41 2007
@@ -1,4 +1,4 @@
-package tests.customext;
+package tests.customext.attrib;
import org.apache.ws.commons.schema.extensions.ExtensionDeserializer;
import org.apache.ws.commons.schema.XmlSchemaObject;
@@ -7,10 +7,10 @@
import javax.xml.namespace.QName;
+import tests.customext.attrib.CustomAttribute;
+
/**
- * @author : Ajith Ranabahu
- * Date: Mar 29, 2007
- * Time: 3:58:59 PM
+ * Custome attribute deserializer for our test custom attribute
*/
public class CustomAttributeDeserializer implements ExtensionDeserializer {
@@ -37,10 +37,6 @@
//put this in the schema object meta info map
schemaObject.addMetaInfo(CustomAttribute.CUSTOM_ATTRIBUTE_QNAME,customAttrib);
-
-
-
-
}
}
}
Copied:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeSerializer.java
(from r523836,
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomAttributeSerializer.java)
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeSerializer.java?view=diff&rev=523905&p1=webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomAttributeSerializer.java&r1=523836&p2=webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeSerializer.java&r2=523905
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomAttributeSerializer.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeSerializer.java
Thu Mar 29 18:55:41 2007
@@ -1,4 +1,4 @@
-package tests.customext;
+package tests.customext.attrib;
import org.apache.ws.commons.schema.extensions.ExtensionSerializer;
import org.apache.ws.commons.schema.XmlSchemaObject;
@@ -19,6 +19,6 @@
* serialization mechanism is to create a DOM tree
first and serialize it
*/
public void serialize(XmlSchemaObject schemaObject, Class classOfType,
Node domNode) {
-
+
}
}
Copied:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtDeserializerTest.java
(from r523836,
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomExtDeserializerTest.java)
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtDeserializerTest.java?view=diff&rev=523905&p1=webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomExtDeserializerTest.java&r1=523836&p2=webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtDeserializerTest.java&r2=523905
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomExtDeserializerTest.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtDeserializerTest.java
Thu Mar 29 18:55:41 2007
@@ -1,4 +1,4 @@
-package tests.customext;
+package tests.customext.attrib;
import junit.framework.TestCase;
@@ -8,9 +8,9 @@
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.constants.Constants;
import tests.Resources;
+import tests.customext.attrib.CustomAttribute;
import java.util.Iterator;
import java.util.Map;
@@ -49,6 +49,9 @@
assertNotNull(customAttrib);
}
+
+ //remove our system property
+
System.getProperties().remove(Constants.SystemConstants.EXTENSION_REGISTRY_KEY);;
}
}
Copied:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionRegistry.java
(from r523836,
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomExtensionRegistry.java)
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionRegistry.java?view=diff&rev=523905&p1=webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomExtensionRegistry.java&r1=523836&p2=webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionRegistry.java&r2=523905
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/CustomExtensionRegistry.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionRegistry.java
Thu Mar 29 18:55:41 2007
@@ -1,6 +1,9 @@
-package tests.customext;
+package tests.customext.attrib;
import org.apache.ws.commons.schema.extensions.ExtensionRegistry;
+import tests.customext.attrib.CustomAttribute;
+import tests.customext.attrib.CustomAttributeDeserializer;
+import tests.customext.attrib.CustomAttributeSerializer;
/**
* Custom extension registry to test the functionality
Added:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElement.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElement.java?view=auto&rev=523905
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElement.java
(added)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElement.java
Thu Mar 29 18:55:41 2007
@@ -0,0 +1,34 @@
+package tests.customext.elt;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Custom Element class
+ * The is will be with reference to the http://customattrib.org
+ * namespace and will have 'customElt' as the name and the
+ * value will have two attributes , prefix and a suffix
+ * see the externalAnnotationsElt.xsd for an example schema.
+ */
+public class CustomElement {
+
+ public static final QName CUSTOM_ELT_QNAME = new
QName("http://customattrib.org","customElt");
+ private String prefix;
+ private String suffix;
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public void setPrefix(String prefix) {
+ this.prefix = prefix;
+ }
+
+ public String getSuffix() {
+ return suffix;
+ }
+
+ public void setSuffix(String suffix) {
+ this.suffix = suffix;
+ }
+
+}
Added:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementDeserializer.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementDeserializer.java?view=auto&rev=523905
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementDeserializer.java
(added)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementDeserializer.java
Thu Mar 29 18:55:41 2007
@@ -0,0 +1,39 @@
+package tests.customext.elt;
+
+import org.apache.ws.commons.schema.extensions.ExtensionDeserializer;
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.w3c.dom.Node;
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+
+/**
+ * @author : Ajith Ranabahu
+ * Date: Mar 29, 2007
+ * Time: 9:12:19 PM
+ */
+public class CustomElementDeserializer implements ExtensionDeserializer {
+ /**
+ * deserialize the given element
+ *
+ * @param schemaObject - Parent schema element
+ * @param name - the QName of the element/attribute to be
deserialized.
+ * in the case where a deserializer is used to handle
multiple elements/attributes
+ * this may be useful to determine the correct
deserialization
+ * @param domNode - the raw DOM Node read from the source. This will
be the
+ * extension element itself if for an element or the
extension attribute object if
+ * it is an attribute
+ */
+ public void deserialize(XmlSchemaObject schemaObject, QName name, Node
domNode) {
+ if (CustomElement.CUSTOM_ELT_QNAME.equals(name)){
+ Element elt = (Element)domNode;
+
+ CustomElement customElement = new CustomElement();
+ customElement.setPrefix(elt.getAttribute("prefix"));
+ customElement.setSuffix(elt.getAttribute("suffix"));
+
+ //put this in the schema object meta info map
+
schemaObject.addMetaInfo(CustomElement.CUSTOM_ELT_QNAME,customElement);
+ }
+ }
+}
Added:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementSerializer.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementSerializer.java?view=auto&rev=523905
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementSerializer.java
(added)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementSerializer.java
Thu Mar 29 18:55:41 2007
@@ -0,0 +1,25 @@
+package tests.customext.elt;
+
+import org.apache.ws.commons.schema.extensions.ExtensionSerializer;
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.w3c.dom.Node;
+
+/**
+ * @author : Ajith Ranabahu
+ * Date: Mar 29, 2007
+ * Time: 9:30:07 PM
+ */
+public class CustomElementSerializer implements ExtensionSerializer {
+ /**
+ * serialize the given element
+ *
+ * @param schemaObject - Parent schema object.contains the extension
+ * to be serialized
+ * @param classOfType - The class of type to be serialized
+ * @param domNode - the parent DOM Node that will ultimately be
serialized. The XMLSchema
+ * serialization mechanism is to create a DOM tree
first and serialize it
+ */
+ public void serialize(XmlSchemaObject schemaObject, Class classOfType,
Node domNode) {
+ //To change body of implemented methods use File | Settings | File
Templates.
+ }
+}
Added:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtElementDeserializerTest.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtElementDeserializerTest.java?view=auto&rev=523905
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtElementDeserializerTest.java
(added)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtElementDeserializerTest.java
Thu Mar 29 18:55:41 2007
@@ -0,0 +1,58 @@
+package tests.customext.elt;
+
+import junit.framework.TestCase;
+import org.apache.ws.commons.schema.constants.Constants;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.w3c.dom.Document;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import tests.Resources;
+
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author : Ajith Ranabahu
+ * Date: Mar 29, 2007
+ * Time: 9:33:17 PM
+ */
+public class CustomExtElementDeserializerTest extends TestCase {
+
+
+ public void testSimpleTypeSchemaGeneration() throws Exception {
+ //set the system property for the custom extension registry
+
System.setProperty(Constants.SystemConstants.EXTENSION_REGISTRY_KEY,
+ CustomExtensionRegistry.class.getName());
+
+ //create a DOM document
+ DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ Document doc = documentBuilderFactory.newDocumentBuilder().
+
parse(Resources.asURI("/external/externalElementAnnotations.xsd"));
+
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(doc,null);
+ assertNotNull(schema);
+
+ // get the elements and check whether their annotations are properly
+ // populated
+ Iterator values = schema.getElements().getValues();
+ while (values.hasNext()) {
+ XmlSchemaElement elt = (XmlSchemaElement) values.next();
+ assertNotNull(elt);
+ Map metaInfoMap = elt.getMetaInfoMap();
+ assertNotNull(metaInfoMap);
+
+ CustomElement customElt =
(CustomElement)metaInfoMap.get(CustomElement.CUSTOM_ELT_QNAME);
+ assertNotNull(customElt);
+
+ }
+
+ //remove our system property
+
System.getProperties().remove(Constants.SystemConstants.EXTENSION_REGISTRY_KEY);
+
+ }
+}
Added:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtensionRegistry.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtensionRegistry.java?view=auto&rev=523905
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtensionRegistry.java
(added)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtensionRegistry.java
Thu Mar 29 18:55:41 2007
@@ -0,0 +1,18 @@
+package tests.customext.elt;
+
+import org.apache.ws.commons.schema.extensions.ExtensionRegistry;
+
+/**
+ * @author : Ajith Ranabahu
+ * Date: Mar 29, 2007
+ * Time: 9:21:40 PM
+ */
+public class CustomExtensionRegistry extends ExtensionRegistry {
+
+ public CustomExtensionRegistry() {
+ //register our custom type
+ registerDeserializer(CustomElement.CUSTOM_ELT_QNAME,new
CustomElementDeserializer());
+ registerSerializer(CustomElement.class,new
CustomElementSerializer());
+ }
+
+}
Added:
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/external/externalElementAnnotations.xsd
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/external/externalElementAnnotations.xsd?view=auto&rev=523905
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/external/externalElementAnnotations.xsd
(added)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/external/externalElementAnnotations.xsd
Thu Mar 29 18:55:41 2007
@@ -0,0 +1,22 @@
+<schema
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ xmlns:ext="http://customattrib.org"
+ targetNamespace="http://soapinterop.org/types">
+
+ <complexType name="Struct">
+ <ext:customElt prefix="ext" suffix="type"/>
+ <sequence>
+ <element name="varString" type="xsd:string"/>
+ <element name="varInt" type="xsd:int" />
+ <element name="varFloat" type="xsd:float" />
+ <element name="varStruct" type="tns:Struct" />
+ </sequence>
+ </complexType>
+
+ <element name="attrTest" type="tns:Struct" >
+ <ext:customElt prefix="ext" suffix="elt"/>
+ </element>
+
+</schema>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]