axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: xml-axis/java/src/javax/xml/rpc/namespace QName.java
Date Fri, 11 Jan 2002 21:01:48 GMT
tomj        02/01/11 13:01:48

  Modified:    java/src/javax/xml/rpc/namespace QName.java
  Log:
  Set the namespace URI to "" when contructing with only a localname.
  
  When trying to resolve a qname string with an element,
  get the default namespace from an Element instead of setting it to null.
  
  Revision  Changes    Path
  1.9       +22 -1     xml-axis/java/src/javax/xml/rpc/namespace/QName.java
  
  Index: QName.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/javax/xml/rpc/namespace/QName.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- QName.java	10 Dec 2001 17:28:03 -0000	1.8
  +++ QName.java	11 Jan 2002 21:01:48 -0000	1.9
  @@ -55,6 +55,11 @@
   
   package javax.xml.rpc.namespace;
   
  +import org.apache.axis.Constants;
  +import org.w3c.dom.Element;
  +import org.w3c.dom.Attr;
  +import org.w3c.dom.Node;
  +
   /**
    * QName class represents a qualified name based on "Namespaces in XML" specification.
A QName is represented as: 
    * QName ::= (Prefix ':') ? LocalPart 
  @@ -80,6 +85,7 @@
        * @param localPart - Local part of the QName
        */
       public QName(String localPart) {
  +        setNamespaceURI("");
           setLocalPart(localPart);
       }
       
  @@ -218,7 +224,22 @@
   
               if (i < 0) {
                   setLocalPart(qName);
  -                setNamespaceURI(null);
  +                // Find default namespace
  +                while (element != null) {
  +                    Attr attr =
  +                        element.getAttributeNodeNS(Constants.NS_URI_XMLNS,
  +                                "xmlns");
  +                    if (attr != null) {
  +                        setNamespaceURI(attr.getValue());
  +                        return;
  +                    }
  +                    Node n = element.getParentNode();
  +                    if (! (n instanceof Element))
  +                        break;
  +                    element  = (Element)n;
  +                }
  +                // didn't find a namespace
  +                setNamespaceURI("");
               } else {
                   String prefix = qName.substring(0, i);
                   String local  = qName.substring(i + 1);
  
  
  

Mime
View raw message