axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/utils XMLUtils.java QName.java
Date Sat, 05 May 2001 09:06:29 GMT
jmsnell     01/05/05 02:06:29

  Modified:    java/src/org/apache/axis/utils XMLUtils.java QName.java
  Log:
  Slight modifications made to support the changes made to the deployment registry classes
  
  Revision  Changes    Path
  1.5       +58 -2     xml-axis/java/src/org/apache/axis/utils/XMLUtils.java
  
  Index: XMLUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/XMLUtils.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XMLUtils.java	2001/04/29 17:35:01	1.4
  +++ XMLUtils.java	2001/05/05 09:06:29	1.5
  @@ -141,7 +141,47 @@
       }
     }
   
  -  public static String getPrefix(String uri, Element e) {
  +  public static String ElementToString(Element element) {
  +      try {
  +          StringWriter sw = new StringWriter();
  +          OutputFormat format = new OutputFormat();
  +          format.setPreserveSpace(true);
  +          format.setOmitXMLDeclaration(true);
  +          XMLSerializer xs = new XMLSerializer(sw, format);
  +          xs.serialize((Element)element);
  +          sw.close();
  +          return(sw.toString() );
  +      } 
  +      catch( Exception e) {
  +          e.printStackTrace();
  +      }
  +      return( null );
  +  }
  +  
  +  public static void ElementToStream(Element element, OutputStream out) {
  +    try {
  +      OutputFormat format = new OutputFormat();
  +      format.setPreserveSpace(true);
  +      XMLSerializer  xs = new XMLSerializer( out, format );
  +      xs.serialize((Element)element);
  +    }
  +    catch( Exception e ) {
  +      e.printStackTrace();
  +    }      
  +  }
  +  
  +  public static String getInnerXMLString(Element element) {
  +      String elementString = ElementToString(element);
  +      int start, end;
  +      start = elementString.indexOf(">") + 1;
  +      end = elementString.lastIndexOf("</");
  +      if (end > 0) 
  +          return elementString.substring(start,end);
  +      else 
  +          return null;
  +  }
  +  
  +  public static String getPrefix(String uri, Node e) {
         while (e != null && (e.getNodeType() == Element.ELEMENT_NODE)) {
             NamedNodeMap attrs = e.getAttributes();
             for (int n = 0; n < attrs.getLength(); n++) {
  @@ -152,7 +192,23 @@
                     return name.substring(6);
                 }
             }
  -          e = (Element)e.getParentNode();
  +          e = e.getParentNode();
  +      }
  +      return null;
  +  }
  +
  +  public static String getNamespace(String prefix, Node e) {
  +      while (e != null && (e.getNodeType() == Node.ELEMENT_NODE)) {
  +          NamedNodeMap attrs = e.getAttributes();
  +          for (int n = 0; n < attrs.getLength(); n++) {
  +              Attr a = (Attr)attrs.item(n);
  +              String name;
  +              if ((name = a.getName()).equals("xmlns:" + prefix)) {
  +                  return a.getNodeValue();
  +              }
  +          }
  +          
  +          e = e.getParentNode();
         }
         return null;
     }
  
  
  
  1.8       +24 -2     xml-axis/java/src/org/apache/axis/utils/QName.java
  
  Index: QName.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/QName.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- QName.java	2001/05/04 11:59:13	1.7
  +++ QName.java	2001/05/05 09:06:29	1.8
  @@ -55,6 +55,8 @@
   
   package org.apache.axis.utils ;
   
  +import org.w3c.dom.Element;
  +
   /**
    * @author Doug Davis (dug@us.ibm.com)
    * @author James Snell (jasnell@us.ibm.com)
  @@ -68,8 +70,24 @@
       public QName(String namespaceURI, String localPart) {
           setNamespaceURI(namespaceURI);
           setLocalPart(localPart);
  +    }
  +    
  +    public QName(String qName, Element element) {
  +        if (qName != null){            
  +            int i = qName.indexOf(":");
  +            if (i < 0) {
  +                setLocalPart(qName);
  +                setNamespaceURI(null);
  +            } else {
  +                String prefix = qName.substring(0,i);
  +                String local = qName.substring(i+1);
  +                setLocalPart(local);
  +                setNamespaceURI(XMLUtils.getNamespace(prefix, element));
  +            }
  +        }
       }
  -  
  +    
  +    
       public void setNamespaceURI(String namespaceURI) {
           this.namespaceURI = namespaceURI ;
       };
  @@ -87,7 +105,11 @@
       };
       
       public String toString() {
  -        return namespaceURI + ":" + localPart;
  +        if (namespaceURI == null) {
  +            return localPart;
  +        } else {
  +            return namespaceURI + ":" + localPart;
  +        }
       };
       
       public boolean equals(Object p1) {
  
  
  

Mime
View raw message