cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r701636 - in /cxf/branches/2.1.x-fixes: ./ common/common/src/main/java/org/apache/cxf/common/xmlschema/ rt/javascript/src/main/java/org/apache/cxf/javascript/
Date Sat, 04 Oct 2008 12:29:00 GMT
Author: dkulp
Date: Sat Oct  4 05:29:00 2008
New Revision: 701636

URL: http://svn.apache.org/viewvc?rev=701636&view=rev
Log:
Merged revisions 700981 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r700981 | bimargulies | 2008-10-01 21:30:27 -0400 (Wed, 01 Oct 2008) | 2 lines
  
  Incremental creeping toward attribute support in Javascript. As usual, in spite of the XmlSchema
situation.
........

Added:
    cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/AttributeInfo.java
      - copied unchanged from r700981, cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/AttributeInfo.java
Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
    cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties
    cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/NamespacePrefixAccumulator.java
    cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Oct  4 05:29:00 2008
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,701316
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java?rev=701636&r1=701635&r2=701636&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
(original)
+++ cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
Sat Oct  4 05:29:00 2008
@@ -31,8 +31,10 @@
 
 import org.apache.ws.commons.schema.ValidationEventHandler;
 import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaAttribute;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObjectTable;
 import org.apache.ws.commons.schema.XmlSchemaSimpleType;
 import org.apache.ws.commons.schema.XmlSchemaType;
 import org.apache.ws.commons.schema.extensions.ExtensionRegistry;
@@ -85,6 +87,20 @@
         return schemaCollection.getElementByQName(qname);
     }
 
+    public XmlSchemaAttribute getAttributeByQName(QName qname) {
+        String uri = qname.getNamespaceURI();
+        for (XmlSchema schema : schemaCollection.getXmlSchemas()) {
+            if (uri.equals(schema.getTargetNamespace())) {
+                XmlSchemaObjectTable attributes = schema.getAttributes();
+                XmlSchemaAttribute attribute = (XmlSchemaAttribute)attributes.getItem(qname);
+                if (attribute != null) {
+                    return attribute;
+                }
+            }
+        }
+        return null;
+    }
+
     public ExtensionRegistry getExtReg() {
         return schemaCollection.getExtReg();
     }

Modified: cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties?rev=701636&r1=701635&r2=701636&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties
(original)
+++ cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties
Sat Oct  4 05:29:00 2008
@@ -21,6 +21,8 @@
 NON_SEQUENCE_PARTICLE=JavaScript limitation: Type {0} is not defined as a sequence. {1}
 NON_ELEMENT_CHILD=JavaScript limitation: Non-Element sequence member {0} of {1}. {2}
 NON_PARTICLE_CHILD=JavaScript limitation: Non-particle sequence member {0} of {1}. {2}
+NON_ANNOTATED_ATTRIBUTE=JavaScript limitation: Non-attribute member {0} or {1}. {2}
+EXOTIC_ATTRIBUTE=JavaScript limitation: unsupported non-attribute {0} found in {1}. {2}
 GROUP_CHILD=JavaScript limitation: unsupported xs:group {0} found in {1}. {2}
 ABSTRACT_ELEMENT=JavaScript limitation: Abstract element {0} of {1}. {2}
 ELEMENT_HAS_NO_TYPE=Element {0} has no type in the schema. {1}
@@ -28,3 +30,4 @@
 ELEMENT_SCHEMA_MISSING=Element {0} contained in missing schema.
 IMPOSSIBLE_GLOBAL_ITEM= JavaScript limitation: Element or xs:any at {0} used in a context
that requires a global name, but it, and its type, are anonymous.
 MISSING_TYPE=Type {0} is missing from the WSDL schema for element {1}. {2}
+ATTRIBUTE_DANGLING_REFERENCE=Attribute {0} refers to undefined attribute {1}.

Modified: cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/NamespacePrefixAccumulator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/NamespacePrefixAccumulator.java?rev=701636&r1=701635&r2=701636&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/NamespacePrefixAccumulator.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/NamespacePrefixAccumulator.java
Sat Oct  4 05:29:00 2008
@@ -27,6 +27,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.common.xmlschema.SchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaAttribute;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 
 public class NamespacePrefixAccumulator {
@@ -90,6 +91,24 @@
         return element.getName(); // use the non-qualified name.
     }
     
+    /**
+     * Obtain a suitable name for use in Javascript for an attribute. This function
+     * is purely a tribute to the awful modularity of XmlSchema.
+     * @param attribute
+     * @param qualified
+     * @return
+     */
+    public String xmlAttributeString(XmlSchemaAttribute attribute, boolean qualified) {
+        if (qualified) {
+            // What if there were a prefix in the element's qname? This is not apparently

+            // something that happens in this environment.
+            String prefix = getPrefix(attribute.getQName().getNamespaceURI());
+            collect(prefix, attribute.getQName().getNamespaceURI());
+            return prefix + ":" + attribute.getName();
+        }
+        return attribute.getName(); // use the non-qualified name.
+    }
+    
     public String xmlElementString(QName name) { // used with part concrete names
         if ("".equals(name.getNamespaceURI())) {
             return name.getLocalPart();

Modified: cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java?rev=701636&r1=701635&r2=701636&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java
Sat Oct  4 05:29:00 2008
@@ -28,7 +28,10 @@
 import org.apache.cxf.common.xmlschema.SchemaCollection;
 import org.apache.cxf.wsdl.WSDLConstants;
 import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaAnnotated;
 import org.apache.ws.commons.schema.XmlSchemaAny;
+import org.apache.ws.commons.schema.XmlSchemaAnyAttribute;
+import org.apache.ws.commons.schema.XmlSchemaAttribute;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaForm;
@@ -196,6 +199,19 @@
         return schema.getElementFormDefault().equals(QUALIFIED);
     }
     
+    public static boolean isAttributeNameQualified(XmlSchemaAttribute attribute, XmlSchema
schema) {
+        if (attribute.getRefName() != null) {
+            throw new RuntimeException("isElementNameQualified on element with ref=");
+        }
+        if (attribute.getForm().equals(QUALIFIED)) {
+            return true;
+        }
+        if (attribute.getForm().equals(UNQUALIFIED)) {
+            return false;
+        }
+        return schema.getAttributeFormDefault().equals(QUALIFIED);
+    }
+    
     /**
      * due to a bug, feature, or just plain oddity of JAXB, it isn't good enough
      * to just check the form of an element and of its schema. If schema 'a'
@@ -234,7 +250,45 @@
             return isElementNameQualified(element, elementSchema);
         }
     }
-    
+    /**
+     * due to a bug, feature, or just plain oddity of JAXB, it isn't good enough
+     * to just check the form of an element and of its schema. If schema 'a'
+     * (default unqualified) has a complex type with an element with a ref= to
+     * schema (b) (default unqualified), JAXB seems to expect to see a
+     * qualifier, anyway. <br/> So, if the element is local to a complex type,
+     * all we care about is the default element form of the schema and the local
+     * form of the element. <br/> If, on the other hand, the element is global,
+     * we might need to compare namespaces. <br/>
+     * 
+     * @param attribute the attribute
+     * @param global if this element is a global element (complex type ref= to
+     *                it, or in a part)
+     * @param localSchema the schema of the complex type containing the
+     *                reference, only used for the 'odd case'.
+     * @param elementSchema the schema for the element.
+     * @return if the element needs to be qualified.
+     */
+    public static boolean isAttributeQualified(XmlSchemaAttribute attribute,
+                                             boolean global,
+                                             XmlSchema localSchema,
+                                             XmlSchema attributeSchema) {
+        if (attribute.getQName() == null) {
+            throw new RuntimeException("getSchemaQualifier on anonymous element.");
+        }
+        if (attribute.getRefName() != null) {
+            throw new RuntimeException("getSchemaQualified on the 'from' side of ref=.");
+        }
+            
+
+        if (global) {
+            return isAttributeNameQualified(attribute, attributeSchema)
+                || (localSchema != null 
+                    && !(attribute.getQName().getNamespaceURI().equals(localSchema.getTargetNamespace())));
+        } else {
+            return isAttributeNameQualified(attribute, attributeSchema);
+        }
+    }
+
     /**
      * If the object is an element or an any, return the particle. If it's not a particle,
or it's a group,
      * throw. We're not ready for groups yet.
@@ -258,6 +312,30 @@
         return (XmlSchemaParticle) object;
     }
     
+    /**
+     * If the object is an attribute or an anyAttribute, 
+     * return the 'Annotated'. If it's not one of those, or it's a group,
+     * throw. We're not ready for groups yet.
+     * @param object
+     * @return
+     */
+    public static XmlSchemaAnnotated getObjectAnnotated(XmlSchemaObject object, QName contextName)
{
+        
+        if (!(object instanceof XmlSchemaAnnotated)) {
+            XmlSchemaUtils.unsupportedConstruct("NON_ANNOTATED_ATTRIBUTE", 
+                                                object.getClass().getSimpleName(), 
+                                                contextName, object);
+        }
+        if (!(object instanceof XmlSchemaAttribute)
+            && !(object instanceof XmlSchemaAnyAttribute)) {
+            XmlSchemaUtils.unsupportedConstruct("EXOTIC_ATTRIBUTE", 
+                                                object.getClass().getSimpleName(), contextName,
+                                                object);
+        }
+        
+        return (XmlSchemaAnnotated) object;
+    }
+    
     public static boolean isParticleArray(XmlSchemaParticle particle) {
         return particle.getMaxOccurs() > 1;
     }



Mime
View raw message