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 bi...@apache.org on 2008/11/17 19:42:41 UTC

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

Author: bimargulies
Date: Mon Nov 17 10:42:40 2008
New Revision: 718320

URL: http://svn.apache.org/viewvc?rev=718320&view=rev
Log:
Merged revisions 717973,718061,718067,718092,718274 via svnmerge from 
https://svn.apache.org/repos/asf/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH

........
  r717973 | bimargulies | 2008-11-15 22:27:01 -0500 (Sat, 15 Nov 2008) | 2 lines
  
  WSCOMMONS-401
........
  r718061 | bimargulies | 2008-11-16 12:21:23 -0500 (Sun, 16 Nov 2008) | 2 lines
  
  WSCOMMONS-353
........
  r718067 | bimargulies | 2008-11-16 12:34:05 -0500 (Sun, 16 Nov 2008) | 2 lines
  
  WSCOMMONS-365
........
  r718092 | bimargulies | 2008-11-16 14:44:48 -0500 (Sun, 16 Nov 2008) | 2 lines
  
  Address WSCOMMONS-163 by implementing a useful alternative.
........
  r718274 | dims | 2008-11-17 11:55:28 -0500 (Mon, 17 Nov 2008) | 13 lines
  
  Don't serialize to '<anyAttribute processContents="none"/>'
  
  XML Schema spec says
  
  <anyAttribute
    id = ID 
    namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local))) : ##any 
    processContents = (lax | skip | strict): strict 
    {any attributes with non-schema Namespace...}>
  Content: (annotation?)
  </anyAttribute>
........

Added:
    webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/anyAttribute.xsd
      - copied unchanged from r718274, webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/test-resources/anyAttribute.xsd
Modified:
    webservices/commons/trunk/modules/XmlSchema/   (props changed)
    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/XmlSchemaComplexType.java
    webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
    webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaType.java
    webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnyTest.java

Propchange: webservices/commons/trunk/modules/XmlSchema/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Nov 17 10:42:40 2008
@@ -1 +1 @@
-/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH:1-717970
+/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH:1-718319

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?rev=718320&r1=718319&r2=718320&view=diff
==============================================================================
--- 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 Nov 17 10:42:40 2008
@@ -1879,6 +1879,10 @@
 			}
 			final String systemId = source.getSystemId() == null ? schemaLocation
 					: source.getSystemId();
+			// Push repaired system id back into source where read sees it.
+			// It is perhaps a bad thing to patch the source, but this fixes
+			// a problem.
+			source.setSystemId(systemId);
 			final SchemaKey key = new XmlSchemaCollection.SchemaKey(
 					targetNamespace, systemId);
 			XmlSchema schema = collection.getSchema(key);
@@ -1916,6 +1920,7 @@
 	 */
 	XmlSchema resolveXmlSchema(String targetNamespace, String schemaLocation,
 			TargetNamespaceValidator validator) {
+
 		return resolveXmlSchema(targetNamespace, schemaLocation,
 				collection.baseUri, validator);
 

Modified: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexType.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexType.java?rev=718320&r1=718319&r2=718320&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexType.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexType.java Mon Nov 17 10:42:40 2008
@@ -19,6 +19,8 @@
 
 package org.apache.ws.commons.schema;
 
+import javax.xml.namespace.QName;
+
 import org.apache.ws.commons.schema.constants.Constants;
 
 /**
@@ -153,4 +155,27 @@
         xml += "</" + prefix + "complexType>\n";
         return xml;
     }
+
+    /**
+     * Return the QName of the base schema type, if any, as defined in the content model.
+     */
+	public QName getBaseSchemaTypeName() {
+		XmlSchemaContentModel model = getContentModel();
+		if (model == null) {
+			return null;
+		}
+		XmlSchemaContent content = model.getContent();
+		if (content == null) {
+			return null;
+		}
+
+		if (!(content instanceof XmlSchemaComplexContentExtension)) {
+			return null;
+		}
+
+		XmlSchemaComplexContentExtension ext = (XmlSchemaComplexContentExtension) content;
+		return ext.getBaseTypeName();
+	}
+
+
 }

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?rev=718320&r1=718319&r2=718320&view=diff
==============================================================================
--- 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 Nov 17 10:42:40 2008
@@ -943,6 +943,12 @@
         XmlSchemaObjectCollection attrColl = complexTypeObj.attributes;
         if (attrColl.getCount() > 0)
             setupAttr(doc, attrColl, schema, serializedComplexType);
+        
+        XmlSchemaAnyAttribute anyAttribute = complexTypeObj.getAnyAttribute();
+        if(anyAttribute != null) {
+        	serializedComplexType.appendChild(serializeAnyAttribute(doc, anyAttribute, schema));
+        }
+        
 
             //process extension
         processExtensibilityComponents(complexTypeObj,serializedComplexType);
@@ -2002,6 +2008,14 @@
                         Text t = doc.createTextNode(n.getNodeValue());
                         documentationEl.appendChild(t);
                         break;
+                    case Node.CDATA_SECTION_NODE:
+                    	CDATASection s = doc.createCDATASection(n.getNodeValue());
+                    	documentationEl.appendChild(s);
+                    	break;
+                    case Node.COMMENT_NODE:
+                    	Comment c = doc.createComment(n.getNodeValue());
+                    	documentationEl.appendChild(c);
+                    	break;
                     default:
                         break;
                 }
@@ -2544,6 +2558,10 @@
                 String nValue = n.getNodeValue();
                 Text t = doc.createTextNode(nValue);
                 el.appendChild(t);
+	    } else if (nodeType == Node.CDATA_SECTION_NODE) {
+		String nValue = n.getNodeValue();
+		CDATASection s = doc.createCDATASection(nValue);
+		el.appendChild(s);
             } else if (nodeType == Node.ELEMENT_NODE) {
                 appendElement(doc, el, n, schema);
             }

Modified: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaType.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaType.java?rev=718320&r1=718319&r2=718320&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaType.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaType.java Mon Nov 17 10:42:40 2008
@@ -51,12 +51,21 @@
     /**
      * This function returns null. It is intended at some point to return the base type in the event of a restriction,
      * but that functionality is not implemented.
+     * @see #getBaseSchemaTypeName()
      * @return null
      */
     public Object getBaseSchemaType() {
         return baseSchemaType;
     }
 
+    /**
+     * If there is a base schema type, which by definition has to have a global name, return it.
+     * @return the qualified name of the base schema type. Return null if none (e.g. for simple types).
+     */
+    public QName getBaseSchemaTypeName() {
+    	return null;
+    }
+
     public XmlSchemaDatatype getDataType() {
         return dataType;
     }

Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnyTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnyTest.java?rev=718320&r1=718319&r2=718320&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnyTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnyTest.java Mon Nov 17 10:42:40 2008
@@ -21,6 +21,7 @@
 
 import junit.framework.TestCase;
 import org.apache.ws.commons.schema.*;
+import org.xml.sax.InputSource;
 
 import javax.xml.namespace.QName;
 import javax.xml.transform.stream.StreamSource;
@@ -87,6 +88,33 @@
         verifyAccuracy(ELEMENT_QNAME, schemaCol,5L,10L);
 
     }
+    
+    public void testAnyAttribute() throws Exception {
+        InputStream is = new FileInputStream(Resources.asURI("anyAttribute.xsd"));
+        XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+        schemaCol.read(new StreamSource(is), null);
+        
+        XmlSchema[] schemas = schemaCol.getXmlSchemas();
+        XmlSchema schema = null;
+        for(int x = 0; x < schemas.length; x ++) {
+        	if("http://soapinterop.org/types".equals(schemas[x].getTargetNamespace())) {
+        		schema = schemas[x];
+        	}
+        }
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        schema.write(baos);
+        baos.close();
+        byte[] bytes = baos.toByteArray();
+        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+        schemaCol = new XmlSchemaCollection();
+        schemaCol.read(new InputSource(bais), null);
+        XmlSchemaType type = schemaCol.getTypeByQName(new QName("http://soapinterop.org/types",
+                "OccuringStructWithAnyAttribute"));
+        XmlSchemaComplexType complexType = (XmlSchemaComplexType) type;
+        XmlSchemaAnyAttribute aa = complexType.getAnyAttribute();
+        assertNotNull(aa);
+    }
 
     
     public void testAnyZeroOccurs() throws Exception {