axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/utils NSStack.java Mapping.java
Date Wed, 03 Apr 2002 21:44:41 GMT
gdaniels    02/04/03 13:44:41

  Modified:    java/src/org/apache/axis/deployment/wsdd WSDDService.java
               java/src/org/apache/axis/encoding
                        SerializationContextImpl.java
               java/src/org/apache/axis/utils NSStack.java Mapping.java
  Log:
  * Fix SerializationContextImpl to handle unqualified elements correctly.
    If there's an in-scope default namespace, use xmlns="" to shut it off.
    Later we should be smart about setting xmlns="" on elements whose
    schema indicates that they contain unqualified local elements.
  
  * Emit elements this way, do not emit attributes this way yet
  
  * Fix NSStack to avoid duplicate prefix mappings - currently last one
    wins, but we might also consider faulting...?
  
  Revision  Changes    Path
  1.52      +2 -1      xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java
  
  Index: WSDDService.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- WSDDService.java	3 Apr 2002 06:09:55 -0000	1.51
  +++ WSDDService.java	3 Apr 2002 21:44:41 -0000	1.52
  @@ -486,7 +486,8 @@
           }
   
           for (int i=0; i < namespaces.size(); i++ ) {
  -            context.startElement(new QName("", "namespace"), null);
  +            context.startElement(new QName(WSDDConstants.WSDD_NS, "namespace"),
  +                                 null);
               context.writeString((String)namespaces.get(i));
               context.endElement();
           }
  
  
  
  1.16      +35 -11    xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java
  
  Index: SerializationContextImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- SerializationContextImpl.java	1 Apr 2002 20:12:16 -0000	1.15
  +++ SerializationContextImpl.java	3 Apr 2002 21:44:41 -0000	1.16
  @@ -364,19 +364,38 @@
   
       /**
        * Convert QName to a string of the form <prefix>:<localpart>
  -     * @param QName
  +     * @param qName
        * @return prefixed qname representation for serialization.
        */
  -    public String qName2String(QName qName)
  +    public String qName2String(QName qName, boolean writeNS)
       {
  -        String prefix = getPrefixForURI(qName.getNamespaceURI());
  -        return (((prefix != null)&&(!prefix.equals(""))) ? prefix + ":" : "") +
  -               qName.getLocalPart();
  +        String prefix = null;
  +
  +        if (qName.getNamespaceURI().equals("")) {
  +            if (writeNS) {
  +                // If this is unqualified (i.e. prefix ""), set the default
  +                // namespace to ""
  +                String defaultNS = nsStack.getNamespaceURI("");
  +                if (defaultNS != null) {
  +                    registerPrefixForURI("", "");
  +                }
  +            }
  +        } else {
  +            prefix = getPrefixForURI(qName.getNamespaceURI());
  +        }
  +
  +        return (((prefix != null) && (!prefix.equals(""))) ?
  +                      prefix + ":" : "") +
  +           qName.getLocalPart();
       }
   
  +    public String qName2String(QName qName)
  +    {
  +        return qName2String(qName, false);
  +    }
       /**
        * Get the QName associated with the specified class.
  -     * @param Class of an object requiring serialization.
  +     * @param cls Class of an object requiring serialization.
        * @return appropriate QName associated with the class.
        */
       public QName getQNameForClass(Class cls)
  @@ -617,7 +636,7 @@
           }
   
           if (pretty) for (int i=0; i<indent; i++) writer.write(' ');
  -        String elementQName = qName2String(qName);
  +        String elementQName = qName2String(qName, true);
           writer.write("<");
   
           writer.write(elementQName);
  @@ -875,15 +894,20 @@
        * associated java.lang class.  So the javaType is needed to know that the value
        * is really a wrapped primitive.
        */
  -    public void serializeActual(QName name, Attributes attributes, Object value, Class
javaType)
  +    public void serializeActual(QName qName,
  +                                Attributes attributes,
  +                                Object value,
  +                                Class javaType)
           throws IOException
       {
           if (value != null) {
               TypeMapping tm = getTypeMapping();
   
               if (tm == null) {
  -                throw new IOException(JavaUtils.getMessage("noSerializer00",
  -                                                           value.getClass().getName(),
"" + this));
  +                throw new IOException(
  +                        JavaUtils.getMessage("noSerializer00",
  +                                             value.getClass().getName(),
  +                                             "" + this));
               }
   
               Class_Serializer pair = getSerializer(javaType, value);
  @@ -897,7 +921,7 @@
                   // in the interop tests.
                   //if (name.equals(multirefQName) && type != null)
                   //    name = type;
  -                pair.ser.serialize(name, attributes, value, this);
  +                pair.ser.serialize(qName, attributes, value, this);
                   return;
               }
   
  
  
  
  1.21      +9 -0      xml-axis/java/src/org/apache/axis/utils/NSStack.java
  
  Index: NSStack.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/NSStack.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- NSStack.java	13 Mar 2002 16:07:56 -0000	1.20
  +++ NSStack.java	3 Apr 2002 21:44:41 -0000	1.21
  @@ -60,6 +60,7 @@
   import java.util.ArrayList;
   import java.util.Enumeration;
   import java.util.Stack;
  +import java.util.Iterator;
   
   /**
    * @author: James Snell
  @@ -144,6 +145,14 @@
               table = new ArrayList();
               stack.pop();
               stack.push(table);
  +        }
  +        // Replace duplicate prefixes (last wins - this could also fault)
  +        for (Iterator i = table.iterator(); i.hasNext();) {
  +            Mapping mapping = (Mapping)i.next();
  +            if (mapping.getPrefix().equals(prefix)) {
  +                mapping.setNamespaceURI(namespaceURI);
  +                return;
  +            }
           }
           table.add(new Mapping(namespaceURI, prefix));
       }
  
  
  
  1.3       +5 -0      xml-axis/java/src/org/apache/axis/utils/Mapping.java
  
  Index: Mapping.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/Mapping.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Mapping.java	30 Oct 2001 14:19:32 -0000	1.2
  +++ Mapping.java	3 Apr 2002 21:44:41 -0000	1.3
  @@ -68,6 +68,11 @@
       {
           return namespaceURI;
       }
  +
  +    public void setNamespaceURI(String namespaceURI) {
  +        this.namespaceURI = namespaceURI;
  +    }
  +
       public String getPrefix()
       {
           return prefix;
  
  
  

Mime
View raw message