cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r731282 - in /cxf/sandbox/benson/aegis_xmlschema/rt: databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ javascript/src/main/java/org/apache/cxf/javascript/ javascript/src/main/java/org/apache/cxf/javascript/types/ javascript/s...
Date Sun, 04 Jan 2009 16:05:10 GMT
Author: bimargulies
Date: Sun Jan  4 08:05:09 2009
New Revision: 731282

URL: http://svn.apache.org/viewvc?rev=731282&view=rev
Log:
Patch up inconsistencies in XmlSchemaElement name management vis.a.vis. Javascript generator.

Modified:
    cxf/sandbox/benson/aegis_xmlschema/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java
    cxf/sandbox/benson/aegis_xmlschema/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
    cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/NamespacePrefixAccumulator.java
    cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java
    cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java
    cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
    cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/test/java/org/apache/cxf/javascript/AegisTest.java

Modified: cxf/sandbox/benson/aegis_xmlschema/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/benson/aegis_xmlschema/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java?rev=731282&r1=731281&r2=731282&view=diff
==============================================================================
--- cxf/sandbox/benson/aegis_xmlschema/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java
(original)
+++ cxf/sandbox/benson/aegis_xmlschema/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java
Sun Jan  4 08:05:09 2009
@@ -284,8 +284,8 @@
 
         Type componentType = getComponentType();
         XmlSchemaElement element = new XmlSchemaElement();
-        element.setSchemaTypeName(componentType.getSchemaType());
         element.setName(componentType.getSchemaType().getLocalPart());
+        element.setSchemaTypeName(componentType.getSchemaType());
         seq.getItems().add(element);
 
         if (componentType.isNillable()) {

Modified: cxf/sandbox/benson/aegis_xmlschema/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/benson/aegis_xmlschema/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java?rev=731282&r1=731281&r2=731282&view=diff
==============================================================================
--- cxf/sandbox/benson/aegis_xmlschema/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
(original)
+++ cxf/sandbox/benson/aegis_xmlschema/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
Sun Jan  4 08:05:09 2009
@@ -660,6 +660,7 @@
             }
 
             XmlSchemaElement element = new XmlSchemaElement();
+            element.setName(name.getLocalPart());
             sequence.getItems().add(element);
 
             Type type = getType(inf, name);

Modified: cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/NamespacePrefixAccumulator.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/NamespacePrefixAccumulator.java?rev=731282&r1=731281&r2=731282&view=diff
==============================================================================
--- cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/NamespacePrefixAccumulator.java
(original)
+++ cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/NamespacePrefixAccumulator.java
Sun Jan  4 08:05:09 2009
@@ -28,7 +28,6 @@
 
 import org.apache.cxf.common.xmlschema.SchemaCollection;
 import org.apache.ws.commons.schema.XmlSchemaAttribute;
-import org.apache.ws.commons.schema.XmlSchemaElement;
 
 public class NamespacePrefixAccumulator {
     private StringBuffer attributes;
@@ -76,19 +75,19 @@
     
     /**
      * This function obtains a name, perhaps namespace-qualified, for an element.
-     * @param element the element.
+     * @param elementQName the element.
      * @param qualified whether to qualify.
      * @return
      */
-    public String xmlElementString(XmlSchemaElement element, boolean qualified) {
+    public String xmlElementString(QName elementQName, 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(element.getQName().getNamespaceURI());
-            collect(prefix, element.getQName().getNamespaceURI());
-            return prefix + ":" + element.getName();
+            String prefix = getPrefix(elementQName.getNamespaceURI());
+            collect(prefix, elementQName.getNamespaceURI());
+            return prefix + ":" + elementQName.getLocalPart();
         }
-        return element.getName(); // use the non-qualified name.
+        return elementQName.getLocalPart(); // use the non-qualified name.
     }
     
     /**

Modified: cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java?rev=731282&r1=731281&r2=731282&view=diff
==============================================================================
--- cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java
(original)
+++ cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java
Sun Jan  4 08:05:09 2009
@@ -167,7 +167,9 @@
 
         if (particle instanceof XmlSchemaElement) {
             XmlSchemaElement element = (XmlSchemaElement)particle;
-            String elementNamespaceURI = element.getQName().getNamespaceURI();
+            QName elementQName = XmlSchemaUtils.getElementQualifiedName(element, currentSchema);
+            String elementNamespaceURI = elementQName.getNamespaceURI(); 
+                
             boolean elementNoNamespace = "".equals(elementNamespaceURI);
 
             XmlSchema elementSchema = null;
@@ -181,11 +183,11 @@
             boolean qualified = !elementNoNamespace
                                 && XmlSchemaUtils.isElementQualified(element, true,
currentSchema,
                                                                      elementSchema);
-            elementInfo.xmlName = prefixAccumulator.xmlElementString(element, qualified);
+            elementInfo.xmlName = prefixAccumulator.xmlElementString(elementQName, qualified);
             // we are assuming here that we are not dealing, in close proximity,
             // with elements with identical local names and different
             // namespaces.
-            elementInfo.javascriptName = element.getQName().getLocalPart();
+            elementInfo.javascriptName = elementQName.getLocalPart();
             elementInfo.defaultValue = element.getDefaultValue();
             factorySetupType(element, schemaCollection, elementInfo);
         } else { // any

Modified: cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java?rev=731282&r1=731281&r2=731282&view=diff
==============================================================================
--- cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java
(original)
+++ cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java
Sun Jan  4 08:05:09 2009
@@ -330,6 +330,25 @@
     }
     
     /**
+     * By convention, an element that is named in its schema's TNS can have a 'name' but
+     * no QName. This can get inconvenient for consumers who want to think about qualified
names.
+     * Unfortunately, XmlSchema elements, unlike types, don't store a reference to their
containing
+     * schema.
+     * @param element
+     * @param schema
+     * @return
+     */
+    public static QName getElementQualifiedName(XmlSchemaElement element, XmlSchema schema)
{
+        if (element.getQName() != null) {
+            return element.getQName();
+        } else if (element.getName() != null) {
+            return new QName(schema.getTargetNamespace(), element.getName());
+        } else {
+            return null;
+        }
+    }
+    
+    /**
      * 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
@@ -351,18 +370,19 @@
                                              boolean global,
                                              XmlSchema localSchema,
                                              XmlSchema elementSchema) {
-        if (element.getQName() == null) {
-            throw new RuntimeException("getSchemaQualifier on anonymous element.");
+        QName qn = XmlSchemaUtils.getElementQualifiedName(element, localSchema);
+        if (qn == null) {
+            throw new RuntimeException("isElementQualified on anonymous element.");
         }
         if (element.getRefName() != null) {
-            throw new RuntimeException("getSchemaQualified on the 'from' side of ref=.");
+            throw new RuntimeException("isElementQualified on the 'from' side of ref=.");
         }
             
 
         if (global) {
             return isElementNameQualified(element, elementSchema)
                 || (localSchema != null 
-                    && !(element.getQName().getNamespaceURI().equals(localSchema.getTargetNamespace())));
+                    && !(qn.getNamespaceURI().equals(localSchema.getTargetNamespace())));
         } else {
             return isElementNameQualified(element, elementSchema);
         }

Modified: cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java?rev=731282&r1=731281&r2=731282&view=diff
==============================================================================
--- cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
(original)
+++ cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
Sun Jan  4 08:05:09 2009
@@ -579,7 +579,8 @@
         String accessorName = "set" + StringUtils.capitalize(itemInfo.getJavascriptName());
         utils.appendLine("cxfjsutils.trace('processing " + itemInfo.getJavascriptName() +
"');");
         XmlSchemaElement element = (XmlSchemaElement) itemInfo.getParticle();
-        String elementNamespaceURI = element.getQName().getNamespaceURI();
+        QName elementQName = XmlSchemaUtils.getElementQualifiedName(element, schemaInfo.getSchema());

+        String elementNamespaceURI = elementQName.getNamespaceURI();
         boolean elementNoNamespace = "".equals(elementNamespaceURI);
         XmlSchema elementSchema = null;
         if (!elementNoNamespace) {
@@ -595,7 +596,7 @@
             elementNamespaceURI = "";
         }
         
-        String localName = element.getQName().getLocalPart();
+        String localName = elementQName.getLocalPart();
         String valueTarget = "item";
 
         if (itemInfo.isOptional() || itemInfo.isArray()) {

Modified: cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/test/java/org/apache/cxf/javascript/AegisTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/test/java/org/apache/cxf/javascript/AegisTest.java?rev=731282&r1=731281&r2=731282&view=diff
==============================================================================
--- cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/test/java/org/apache/cxf/javascript/AegisTest.java
(original)
+++ cxf/sandbox/benson/aegis_xmlschema/rt/javascript/src/test/java/org/apache/cxf/javascript/AegisTest.java
Sun Jan  4 08:05:09 2009
@@ -23,7 +23,6 @@
 import java.util.logging.Logger;
 
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.interceptor.LoggingInInterceptor;
 import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
 import org.apache.cxf.javascript.JavascriptTestUtilities.Notifier;
 import org.apache.cxf.javascript.fortest.AegisServiceImpl;
@@ -62,7 +61,6 @@
                    true);
         implementor = (AegisServiceImpl)rawImplementor;
         implementor.reset();
-        serverFactoryBean.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
     }
     
     private Void acceptAny(Context context) {



Mime
View raw message