You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2013/07/11 22:47:55 UTC

svn commit: r1502355 - in /cxf/trunk: api/src/main/java/org/apache/cxf/common/xmlschema/ rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/ rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/service/ rt/javascript/jav...

Author: dkulp
Date: Thu Jul 11 20:47:54 2013
New Revision: 1502355

URL: http://svn.apache.org/r1502355
Log:
Move some utility methods that are ONLY used by javascript to javascript

Removed:
    cxf/trunk/api/src/main/java/org/apache/cxf/common/xmlschema/UnsupportedConstruct.java
Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
    cxf/trunk/api/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java
    cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/AttributeInfo.java
    cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java
    cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/Messages.properties
    cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/ParticleInfo.java
    cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
    cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java?rev=1502355&r1=1502354&r2=1502355&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java Thu Jul 11 20:47:54 2013
@@ -300,13 +300,13 @@ public class SchemaCollection {
             // could it be a choice or something else?
             
             if (complexType.getParticle() instanceof XmlSchemaChoice) {
-                XmlSchemaChoice choice = XmlSchemaUtils.getChoice(complexType);
+                XmlSchemaChoice choice = (XmlSchemaChoice)complexType.getParticle();
                 addCrossImports(schema, choice);
             } else if (complexType.getParticle() instanceof XmlSchemaAll) {
-                XmlSchemaAll all = XmlSchemaUtils.getAll(complexType);
+                XmlSchemaAll all = (XmlSchemaAll)complexType.getParticle();
                 addCrossImports(schema, all);
-            } else {
-                XmlSchemaSequence sequence = XmlSchemaUtils.getSequence(complexType);
+            } else if (complexType.getParticle() instanceof XmlSchemaSequence) {
+                XmlSchemaSequence sequence = (XmlSchemaSequence)complexType.getParticle();
                 addCrossImports(schema, sequence);
             }
         }

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java?rev=1502355&r1=1502354&r2=1502355&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java Thu Jul 11 20:47:54 2013
@@ -25,16 +25,11 @@ import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;
 
-import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaAll;
 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.XmlSchemaAttributeOrGroupRef;
-import org.apache.ws.commons.schema.XmlSchemaChoice;
 import org.apache.ws.commons.schema.XmlSchemaComplexContentExtension;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaContent;
@@ -45,14 +40,10 @@ import org.apache.ws.commons.schema.XmlS
 import org.apache.ws.commons.schema.XmlSchemaFacet;
 import org.apache.ws.commons.schema.XmlSchemaForm;
 import org.apache.ws.commons.schema.XmlSchemaImport;
-import org.apache.ws.commons.schema.XmlSchemaObject;
 import org.apache.ws.commons.schema.XmlSchemaParticle;
-import org.apache.ws.commons.schema.XmlSchemaSequence;
-import org.apache.ws.commons.schema.XmlSchemaSequenceMember;
 import org.apache.ws.commons.schema.XmlSchemaSimpleType;
 import org.apache.ws.commons.schema.XmlSchemaSimpleTypeContent;
 import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
-import org.apache.ws.commons.schema.XmlSchemaType;
 import org.apache.ws.commons.schema.constants.Constants;
 
 /**
@@ -62,9 +53,6 @@ public final class XmlSchemaUtils {
     public static final String XSI_NIL = "xsi:nil='true'";
     
     private static final Logger LOG = LogUtils.getL7dLogger(XmlSchemaUtils.class);
-    private static final XmlSchemaSequence EMPTY_SEQUENCE = new XmlSchemaSequence();
-    private static final XmlSchemaChoice EMPTY_CHOICE = new XmlSchemaChoice();
-    private static final XmlSchemaAll EMPTY_ALL = new XmlSchemaAll();
 
     private XmlSchemaUtils() {
     }
@@ -270,61 +258,6 @@ public final class XmlSchemaUtils {
         }
     }
 
-    public static List<XmlSchemaObject> getContentElements(XmlSchemaComplexType type,
-                                                           SchemaCollection collection) {
-        List<XmlSchemaObject> results = new ArrayList<XmlSchemaObject>();
-        QName baseTypeName = getBaseType(type);
-        if (baseTypeName != null) {
-            XmlSchemaComplexType baseType = (XmlSchemaComplexType)collection.getTypeByQName(baseTypeName);
-            // recurse onto the base type ...
-            results.addAll(getContentElements(baseType, collection));
-            // and now process our sequence.
-            XmlSchemaSequence extSequence = getContentSequence(type);
-            if (extSequence != null) {
-                for (XmlSchemaSequenceMember item : extSequence.getItems()) {
-                    /*
-                     * For now, leave the return type alone. Fix some day.
-                     */
-                    results.add((XmlSchemaObject)item);
-                }
-            }
-            return results;
-        } else {
-            // no base type, the simple case.
-            XmlSchemaSequence sequence = getSequence(type);
-            for (XmlSchemaSequenceMember item : sequence.getItems()) {
-                results.add((XmlSchemaObject)item);
-            }
-            return results;
-        }
-    }
-
-    public static XmlSchemaSequence getContentSequence(XmlSchemaComplexType type) {
-        XmlSchemaContentModel model = type.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;
-        XmlSchemaParticle particle = ext.getParticle();
-        if (particle == null) {
-            return null;
-        }
-        XmlSchemaSequence sequence = null;
-        try {
-            sequence = (XmlSchemaSequence) particle;
-        } catch (ClassCastException cce) {
-            unsupportedConstruct("NON_SEQUENCE_PARTICLE", type);
-        }
-        return sequence;
-    }
 
     /**
      * By convention, an element that is named in its schema's TNS can have a 'name' but
@@ -344,154 +277,7 @@ public final class XmlSchemaUtils {
         }
     }
 
-    /**
-     * Follow a chain of references from element to element until we can obtain
-     * a type.
-     *
-     * @param element
-     */
-    public static XmlSchemaType getElementType(SchemaCollection xmlSchemaCollection,
-                                               String referencingURI,
-                                               XmlSchemaElement element,
-                                               XmlSchemaType containingType) {
-        assert element != null;
-        if (element.getSchemaTypeName() != null) {
-            XmlSchemaType type = xmlSchemaCollection.getTypeByQName(element.getSchemaTypeName());
-            if (type == null) {
-                Message message = new Message("ELEMENT_TYPE_MISSING", LOG, element.getQName(),
-                                              element.getSchemaTypeName().toString());
-                throw new UnsupportedConstruct(message);
-            }
-            return type;
-        }
-        // The referencing URI only helps if there is a schema that points to
-        // it.
-        // It might be the URI for the wsdl TNS, which might have no schema.
-        if (xmlSchemaCollection.getSchemaByTargetNamespace(referencingURI) == null) {
-            referencingURI = null;
-        }
-
-        if (referencingURI == null && containingType != null) {
-            referencingURI = containingType.getQName().getNamespaceURI();
-        }
-
-        XmlSchemaElement originalElement = element;
-        while (element.getSchemaType() == null && element.isRef()) {
-            /*
-             * This code assumes that all schemas are in the collection.
-             */
-            XmlSchemaElement nextElement = element.getRef().getTarget();
-            assert nextElement != null;
-            element = nextElement;
-        }
-        if (element.getSchemaType() == null) {
-            unsupportedConstruct("ELEMENT_HAS_NO_TYPE",
-                                                originalElement.getName(),
-                                                containingType.getQName(),
-                                                containingType);
-        }
-        return element.getSchemaType();
-    }
-
-    /**
-     * 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
-     */
-    public static XmlSchemaAnnotated getObjectAnnotated(XmlSchemaObject object, QName contextName) {
-
-        if (!(object instanceof XmlSchemaAnnotated)) {
-            unsupportedConstruct("NON_ANNOTATED_ATTRIBUTE",
-                                                object.getClass().getSimpleName(),
-                                                contextName, object);
-        }
-        if (!(object instanceof XmlSchemaAttribute)
-            && !(object instanceof XmlSchemaAnyAttribute)) {
-            unsupportedConstruct("EXOTIC_ATTRIBUTE",
-                                                object.getClass().getSimpleName(), contextName,
-                                                object);
-        }
-
-        return (XmlSchemaAnnotated) object;
-    }
-
-    /**
-     * 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.
-     * @param object
-     */
-    public static XmlSchemaParticle getObjectParticle(XmlSchemaObject object, QName contextName) {
-
-        if (!(object instanceof XmlSchemaParticle)) {
-            unsupportedConstruct("NON_PARTICLE_CHILD",
-                                                object.getClass().getSimpleName(),
-                                                contextName, object);
-        }
-        if (!(object instanceof XmlSchemaElement)
-            && !(object instanceof XmlSchemaAny)) {
-            unsupportedConstruct("GROUP_CHILD",
-                                                object.getClass().getSimpleName(), contextName,
-                                                object);
-        }
-
-        return (XmlSchemaParticle) object;
-    }
-
-    public static XmlSchemaSequence getSequence(XmlSchemaComplexType type) {
-        XmlSchemaParticle particle = type.getParticle();
-        XmlSchemaSequence sequence = null;
-
-        if (particle == null) {
-            // the code that uses this wants to iterate. An empty one is more useful than
-            // a null pointer, and certainly an exception.
-            return EMPTY_SEQUENCE;
-        }
-
-        try {
-            sequence = (XmlSchemaSequence) particle;
-        } catch (ClassCastException cce) {
-            unsupportedConstruct("NON_SEQUENCE_PARTICLE", type);
-        }
-
-        return sequence;
-    }
-    public static XmlSchemaChoice getChoice(XmlSchemaComplexType type) {
-        XmlSchemaParticle particle = type.getParticle();
-        XmlSchemaChoice choice = null;
-
-        if (particle == null) {
-            // the code that uses this wants to iterate. An empty one is more useful than
-            // a null pointer, and certainly an exception.
-            return EMPTY_CHOICE;
-        }
-
-        try {
-            choice = (XmlSchemaChoice) particle;
-        } catch (ClassCastException cce) {
-            unsupportedConstruct("NON_CHOICE_PARTICLE", type);
-        }
-
-        return choice;
-    }
-    public static XmlSchemaAll getAll(XmlSchemaComplexType type) {
-        XmlSchemaParticle particle = type.getParticle();
-        XmlSchemaAll all = null;
-
-        if (particle == null) {
-            // the code that uses this wants to iterate. An empty one is more useful than
-            // a null pointer, and certainly an exception.
-            return EMPTY_ALL;
-        }
-
-        try {
-            all = (XmlSchemaAll) particle;
-        } catch (ClassCastException cce) {
-            unsupportedConstruct("NON_CHOICE_PARTICLE", type);
-        }
 
-        return all;
-    }
     public static boolean isAttributeNameQualified(XmlSchemaAttribute attribute, XmlSchema schema) {
         if (attribute.isRef()) {
             throw new RuntimeException("isElementNameQualified on element with ref=");
@@ -605,30 +391,4 @@ public final class XmlSchemaUtils {
         return particle.getMinOccurs() == 0 && particle.getMaxOccurs() == 1;
     }
 
-    public static void unsupportedConstruct(String messageKey,
-                                            String what,
-                                            QName subjectName,
-                                            XmlSchemaObject subject) {
-        Message message = new Message(messageKey, LOG, what,
-                                      subjectName == null ? "anonymous" : subjectName,
-                                      cleanedUpSchemaSource(subject));
-        LOG.severe(message.toString());
-        throw new UnsupportedConstruct(message);
-
-    }
-
-    public static void unsupportedConstruct(String messageKey, XmlSchemaType subject) {
-        Message message = new Message(messageKey, LOG, subject.getQName(),
-                                      cleanedUpSchemaSource(subject));
-        LOG.severe(message.toString());
-        throw new UnsupportedConstruct(message);
-    }
-
-    public static String cleanedUpSchemaSource(XmlSchemaObject subject) {
-        if (subject == null || subject.getSourceURI() == null) {
-            return "";
-        } else {
-            return subject.getSourceURI() + ":" + subject.getLineNumber();
-        }
-    }
 }

Modified: cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/AttributeInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/AttributeInfo.java?rev=1502355&r1=1502354&r2=1502355&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/AttributeInfo.java (original)
+++ cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/AttributeInfo.java Thu Jul 11 20:47:54 2013
@@ -90,7 +90,7 @@ public final class AttributeInfo impleme
                                              XmlSchema currentSchema,
                                             SchemaCollection schemaCollection,
                                             NamespacePrefixAccumulator prefixAccumulator, QName contextName) {
-        XmlSchemaAnnotated annotated = XmlSchemaUtils.getObjectAnnotated(sequenceObject, contextName);
+        XmlSchemaAnnotated annotated = JavascriptUtils.getObjectAnnotated(sequenceObject, contextName);
         AttributeInfo attributeInfo = new AttributeInfo();
         XmlSchemaAnnotated realAnnotated = annotated;
 
@@ -169,7 +169,7 @@ public final class AttributeInfo impleme
                 if (attributeInfo.type == null
                     && !element.getSchemaTypeName()
                             .getNamespaceURI().equals(Constants.URI_2001_SCHEMA_XSD)) {
-                    XmlSchemaUtils.unsupportedConstruct("MISSING_TYPE", element.getSchemaTypeName()
+                    JavascriptUtils.unsupportedConstruct("MISSING_TYPE", element.getSchemaTypeName()
                             .toString(), element.getQName(), element);
                 }
             }

Modified: cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java?rev=1502355&r1=1502354&r2=1502355&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java (original)
+++ cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java Thu Jul 11 20:47:54 2013
@@ -19,23 +19,40 @@
 
 package org.apache.cxf.javascript;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.Stack;
+import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;
 
 import org.w3c.dom.Attr;
 
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.xmlschema.SchemaCollection;
 import org.apache.cxf.common.xmlschema.XmlSchemaUtils;
 import org.apache.cxf.databinding.source.mime.MimeAttribute;
 import org.apache.cxf.wsdl.WSDLConstants;
+import org.apache.ws.commons.schema.XmlSchemaAll;
+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.XmlSchemaChoice;
+import org.apache.ws.commons.schema.XmlSchemaComplexContentExtension;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaContent;
+import org.apache.ws.commons.schema.XmlSchemaContentModel;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.XmlSchemaParticle;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaSequenceMember;
 import org.apache.ws.commons.schema.XmlSchemaSimpleContent;
 import org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension;
 import org.apache.ws.commons.schema.XmlSchemaSimpleType;
@@ -48,6 +65,13 @@ import org.apache.ws.commons.schema.cons
  * type utilities.
  */
 public class JavascriptUtils {
+    private static final XmlSchemaSequence EMPTY_SEQUENCE = new XmlSchemaSequence();
+    private static final XmlSchemaChoice EMPTY_CHOICE = new XmlSchemaChoice();
+    private static final XmlSchemaAll EMPTY_ALL = new XmlSchemaAll();
+    
+    
+    private static final Logger LOG = LogUtils.getL7dLogger(JavascriptUtils.class);
+
     private static final String NL = "\n";
     private static int anyTypePrefixCounter;
     private StringBuilder code;
@@ -503,4 +527,185 @@ public class JavascriptUtils {
         endBlock(); // for raw
     }
 
+    /**
+     * 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
+     */
+    public static XmlSchemaAnnotated getObjectAnnotated(XmlSchemaObject object, QName contextName) {
+
+        if (!(object instanceof XmlSchemaAnnotated)) {
+            unsupportedConstruct("NON_ANNOTATED_ATTRIBUTE",
+                                                object.getClass().getSimpleName(),
+                                                contextName, object);
+        }
+        if (!(object instanceof XmlSchemaAttribute)
+            && !(object instanceof XmlSchemaAnyAttribute)) {
+            unsupportedConstruct("EXOTIC_ATTRIBUTE",
+                                                object.getClass().getSimpleName(), contextName,
+                                                object);
+        }
+
+        return (XmlSchemaAnnotated) object;
+    }
+    
+    /**
+     * 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.
+     * @param object
+     */
+    public static XmlSchemaParticle getObjectParticle(XmlSchemaObject object, QName contextName) {
+
+        if (!(object instanceof XmlSchemaParticle)) {
+            unsupportedConstruct("NON_PARTICLE_CHILD",
+                                                object.getClass().getSimpleName(),
+                                                contextName, object);
+        }
+        if (!(object instanceof XmlSchemaElement)
+            && !(object instanceof XmlSchemaAny)) {
+            unsupportedConstruct("GROUP_CHILD",
+                                                object.getClass().getSimpleName(), contextName,
+                                                object);
+        }
+
+        return (XmlSchemaParticle) object;
+    }
+
+    public static XmlSchemaSequence getSequence(XmlSchemaComplexType type) {
+        XmlSchemaParticle particle = type.getParticle();
+        XmlSchemaSequence sequence = null;
+
+        if (particle == null) {
+            // the code that uses this wants to iterate. An empty one is more useful than
+            // a null pointer, and certainly an exception.
+            return EMPTY_SEQUENCE;
+        }
+
+        try {
+            sequence = (XmlSchemaSequence) particle;
+        } catch (ClassCastException cce) {
+            unsupportedConstruct("NON_SEQUENCE_PARTICLE", type);
+        }
+
+        return sequence;
+    }
+    public static XmlSchemaChoice getChoice(XmlSchemaComplexType type) {
+        XmlSchemaParticle particle = type.getParticle();
+        XmlSchemaChoice choice = null;
+
+        if (particle == null) {
+            // the code that uses this wants to iterate. An empty one is more useful than
+            // a null pointer, and certainly an exception.
+            return EMPTY_CHOICE;
+        }
+
+        try {
+            choice = (XmlSchemaChoice) particle;
+        } catch (ClassCastException cce) {
+            unsupportedConstruct("NON_CHOICE_PARTICLE", type);
+        }
+
+        return choice;
+    }
+    public static XmlSchemaAll getAll(XmlSchemaComplexType type) {
+        XmlSchemaParticle particle = type.getParticle();
+        XmlSchemaAll all = null;
+
+        if (particle == null) {
+            // the code that uses this wants to iterate. An empty one is more useful than
+            // a null pointer, and certainly an exception.
+            return EMPTY_ALL;
+        }
+
+        try {
+            all = (XmlSchemaAll) particle;
+        } catch (ClassCastException cce) {
+            unsupportedConstruct("NON_CHOICE_PARTICLE", type);
+        }
+
+        return all;
+    }
+    
+    
+    public static List<XmlSchemaObject> getContentElements(XmlSchemaComplexType type,
+                                                           SchemaCollection collection) {
+        List<XmlSchemaObject> results = new ArrayList<XmlSchemaObject>();
+        QName baseTypeName = XmlSchemaUtils.getBaseType(type);
+        if (baseTypeName != null) {
+            XmlSchemaComplexType baseType = (XmlSchemaComplexType)collection.getTypeByQName(baseTypeName);
+            // recurse onto the base type ...
+            results.addAll(getContentElements(baseType, collection));
+            // and now process our sequence.
+            XmlSchemaSequence extSequence = getContentSequence(type);
+            if (extSequence != null) {
+                for (XmlSchemaSequenceMember item : extSequence.getItems()) {
+                    /*
+                     * For now, leave the return type alone. Fix some day.
+                     */
+                    results.add((XmlSchemaObject)item);
+                }
+            }
+            return results;
+        } else {
+            // no base type, the simple case.
+            XmlSchemaSequence sequence = getSequence(type);
+            for (XmlSchemaSequenceMember item : sequence.getItems()) {
+                results.add((XmlSchemaObject)item);
+            }
+            return results;
+        }
+    }
+
+    public static XmlSchemaSequence getContentSequence(XmlSchemaComplexType type) {
+        XmlSchemaContentModel model = type.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;
+        XmlSchemaParticle particle = ext.getParticle();
+        if (particle == null) {
+            return null;
+        }
+        XmlSchemaSequence sequence = null;
+        try {
+            sequence = (XmlSchemaSequence) particle;
+        } catch (ClassCastException cce) {
+            unsupportedConstruct("NON_SEQUENCE_PARTICLE", type);
+        }
+        return sequence;
+    }
+    
+    static void unsupportedConstruct(String messageKey,
+                                             String what,
+                                             QName subjectName,
+                                             XmlSchemaObject subject) {
+        Message message = new Message(messageKey, LOG, what,
+                                      subjectName == null ? "anonymous" : subjectName,
+                                      cleanedUpSchemaSource(subject));
+        throw new UnsupportedConstruct(message);
+    }
+
+    
+    static void unsupportedConstruct(String messageKey, XmlSchemaType subject) {
+        Message message = new Message(messageKey, LOG, subject.getQName(),
+                                      cleanedUpSchemaSource(subject));
+        throw new UnsupportedConstruct(message);
+    }
+    
+    static String cleanedUpSchemaSource(XmlSchemaObject subject) {
+        if (subject == null || subject.getSourceURI() == null) {
+            return "";
+        } else {
+            return subject.getSourceURI() + ":" + subject.getLineNumber();
+        }
+    }    
 }

Modified: cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/Messages.properties?rev=1502355&r1=1502354&r2=1502355&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/Messages.properties (original)
+++ cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/Messages.properties Thu Jul 11 20:47:54 2013
@@ -20,7 +20,7 @@
 #
 NON_SEQUENCE_PARTICLE=JavaScript limitation: Type {0} is not defined as a sequence. {1}
 ABSTRACT_ELEMENT=JavaScript limitation: Abstract element {0} of {1}. {2}
-]ELEMENT_SCHEMA_MISSING=Element {0} contained in missing schema.
+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}
 ELEMENT_DANGLING_REFERENCE= Element {0} refers to undefined element {1}.

Modified: cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/ParticleInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/ParticleInfo.java?rev=1502355&r1=1502354&r2=1502355&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/ParticleInfo.java (original)
+++ cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/ParticleInfo.java Thu Jul 11 20:47:54 2013
@@ -131,7 +131,7 @@ public final class ParticleInfo implemen
                                             SchemaCollection schemaCollection,
                                             NamespacePrefixAccumulator prefixAccumulator, QName contextName) {
         XmlSchemaParticle sequenceParticle =
-            XmlSchemaUtils.getObjectParticle(sequenceObject, contextName);
+            JavascriptUtils.getObjectParticle(sequenceObject, contextName);
         ParticleInfo elementInfo = new ParticleInfo();
         XmlSchemaParticle realParticle = sequenceParticle;
 
@@ -255,7 +255,7 @@ public final class ParticleInfo implemen
                 if (elementInfo.type == null
                     && !element.getSchemaTypeName()
                             .getNamespaceURI().equals(Constants.URI_2001_SCHEMA_XSD)) {
-                    XmlSchemaUtils.unsupportedConstruct("MISSING_TYPE", element.getSchemaTypeName()
+                    JavascriptUtils.unsupportedConstruct("MISSING_TYPE", element.getSchemaTypeName()
                             .toString(), element.getQName(), element);
                 }
             }
@@ -284,8 +284,7 @@ public final class ParticleInfo implemen
                 return element.getQName();
             }
         }
-        Message message = new Message("IMPOSSIBLE_GLOBAL_ITEM", LOG, XmlSchemaUtils
-            .cleanedUpSchemaSource(particle));
+        Message message = new Message("IMPOSSIBLE_GLOBAL_ITEM", LOG, JavascriptUtils.cleanedUpSchemaSource(particle));
         LOG.severe(message.toString());
         throw new UnsupportedConstruct(message);
     }

Modified: cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java?rev=1502355&r1=1502354&r2=1502355&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java (original)
+++ cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java Thu Jul 11 20:47:54 2013
@@ -304,7 +304,7 @@ public class ServiceJavascriptBuilder ex
             if (contextQName == null) {
                 contextQName = inputWrapperElement.getQName();
             }
-            XmlSchemaSequence sequence = XmlSchemaUtils.getSequence(inputWrapperComplexType);
+            XmlSchemaSequence sequence = JavascriptUtils.getSequence(inputWrapperComplexType);
             XmlSchema wrapperSchema =
                 xmlSchemaCollection.getSchemaByTargetNamespace(contextQName.getNamespaceURI());
 
@@ -701,10 +701,10 @@ public class ServiceJavascriptBuilder ex
                 diagnosticName = element.getQName();
                 type = element.getSchemaType();
                 if (type == null) {
-                    type = XmlSchemaUtils.getElementType(xmlSchemaCollection,
-                                                         null,
-                                                         element,
-                                                         null);
+                    type = getElementType(xmlSchemaCollection,
+                                          null,
+                                          element,
+                                          null);
                 }
             } else {
                 // RPC (!isElement)
@@ -760,10 +760,10 @@ public class ServiceJavascriptBuilder ex
             // the null name is probably something awful in RFSB.
             if (inputWrapperComplexType == null) {
                 inputWrapperComplexType = (XmlSchemaComplexType)
-                    XmlSchemaUtils.getElementType(xmlSchemaCollection,
-                                                  serviceInfo.getTargetNamespace(),
-                                                  inputWrapperElement,
-                                                  null);
+                    getElementType(xmlSchemaCollection,
+                                   serviceInfo.getTargetNamespace(),
+                                   inputWrapperElement,
+                                   null);
             }
             if (inputWrapperComplexType == null) {
                 unsupportedConstruct("MISSING_WRAPPER_TYPE",
@@ -802,10 +802,10 @@ public class ServiceJavascriptBuilder ex
             outputWrapperComplexType = (XmlSchemaComplexType)outputWrapperElement.getSchemaType();
             if (outputWrapperComplexType == null) {
                 outputWrapperComplexType = (XmlSchemaComplexType)
-                    XmlSchemaUtils.getElementType(xmlSchemaCollection,
-                                                  serviceInfo.getTargetNamespace(),
-                                                  outputWrapperElement,
-                                                  null);
+                    getElementType(xmlSchemaCollection,
+                                   serviceInfo.getTargetNamespace(),
+                                   outputWrapperElement,
+                                   null);
             }
         }
     }
@@ -933,5 +933,81 @@ public class ServiceJavascriptBuilder ex
         code.append(portClassName + ".prototype = new " + currentInterfaceClassName + ";\n");
     }
 
+    
+    /**
+     * Follow a chain of references from element to element until we can obtain
+     * a type.
+     *
+     * @param element
+     */
+    public static XmlSchemaType getElementType(SchemaCollection xmlSchemaCollection,
+                                               String referencingURI,
+                                               XmlSchemaElement element,
+                                               XmlSchemaType containingType) {
+        assert element != null;
+        if (element.getSchemaTypeName() != null) {
+            XmlSchemaType type = xmlSchemaCollection.getTypeByQName(element.getSchemaTypeName());
+            if (type == null) {
+                Message message = new Message("ELEMENT_TYPE_MISSING", LOG, element.getQName(),
+                                              element.getSchemaTypeName().toString());
+                throw new UnsupportedConstruct(message);
+            }
+            return type;
+        }
+        // The referencing URI only helps if there is a schema that points to
+        // it.
+        // It might be the URI for the wsdl TNS, which might have no schema.
+        if (xmlSchemaCollection.getSchemaByTargetNamespace(referencingURI) == null) {
+            referencingURI = null;
+        }
+
+        if (referencingURI == null && containingType != null) {
+            referencingURI = containingType.getQName().getNamespaceURI();
+        }
+
+        XmlSchemaElement originalElement = element;
+        while (element.getSchemaType() == null && element.isRef()) {
+            /*
+             * This code assumes that all schemas are in the collection.
+             */
+            XmlSchemaElement nextElement = element.getRef().getTarget();
+            assert nextElement != null;
+            element = nextElement;
+        }
+        if (element.getSchemaType() == null) {
+            unsupportedConstruct("ELEMENT_HAS_NO_TYPE",
+                                                originalElement.getName(),
+                                                containingType.getQName(),
+                                                containingType);
+        }
+        return element.getSchemaType();
+    }
+    
+    public static void unsupportedConstruct(String messageKey,
+                                            String what,
+                                            QName subjectName,
+                                            XmlSchemaObject subject) {
+        Message message = new Message(messageKey, LOG, what,
+                                      subjectName == null ? "anonymous" : subjectName,
+                                      cleanedUpSchemaSource(subject));
+        LOG.severe(message.toString());
+        throw new UnsupportedConstruct(message);
+
+    }
+
+    public static void unsupportedConstruct(String messageKey, XmlSchemaType subject) {
+        Message message = new Message(messageKey, LOG, subject.getQName(),
+                                      cleanedUpSchemaSource(subject));
+        LOG.severe(message.toString());
+        throw new UnsupportedConstruct(message);
+    }
+
+    public static String cleanedUpSchemaSource(XmlSchemaObject subject) {
+        if (subject == null || subject.getSourceURI() == null) {
+            return "";
+        } else {
+            return subject.getSourceURI() + ":" + subject.getLineNumber();
+        }
+    }    
 
 }

Modified: cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java?rev=1502355&r1=1502354&r2=1502355&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java (original)
+++ cxf/trunk/rt/javascript/javascript-rt/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java Thu Jul 11 20:47:54 2013
@@ -174,7 +174,7 @@ public class SchemaJavascriptBuilder {
     public void complexTypeConstructorAndAccessors(QName name, XmlSchemaComplexType type) {
         accessors = new StringBuilder();
         utils = new JavascriptUtils(code);
-        List<XmlSchemaObject> items = XmlSchemaUtils.getContentElements(type, xmlSchemaCollection);
+        List<XmlSchemaObject> items = JavascriptUtils.getContentElements(type, xmlSchemaCollection);
         List<XmlSchemaAnnotated> attrs = XmlSchemaUtils.getContentAttributes(type, xmlSchemaCollection);
 
         final String elementPrefix = "this._";
@@ -336,7 +336,7 @@ public class SchemaJavascriptBuilder {
      */
     protected void complexTypeSerializerBody(XmlSchemaComplexType type, String elementPrefix,
                                              JavascriptUtils bodyUtils) {
-        List<XmlSchemaObject> items = XmlSchemaUtils.getContentElements(type, xmlSchemaCollection);
+        List<XmlSchemaObject> items = JavascriptUtils.getContentElements(type, xmlSchemaCollection);
         for (XmlSchemaObject sequenceItem : items) {
             ParticleInfo itemInfo = ParticleInfo.forLocalItem(sequenceItem, xmlSchema, xmlSchemaCollection,
                                                               prefixAccumulator, type.getQName());
@@ -366,7 +366,7 @@ public class SchemaJavascriptBuilder {
     public void domDeserializerFunction(QName name, XmlSchemaComplexType type) {
         utils = new JavascriptUtils(code);
 
-        List<XmlSchemaObject> contentElements = XmlSchemaUtils.getContentElements(type, xmlSchemaCollection);
+        List<XmlSchemaObject> contentElements = JavascriptUtils.getContentElements(type, xmlSchemaCollection);
         String typeObjectName = nameManager.getJavascriptName(name);
         code.append("function " + typeObjectName + "_deserialize (cxfjsutils, element) {\n");
         // create the object we are deserializing into.