axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/encoding SerializationContext.java
Date Sat, 04 Aug 2001 03:50:55 GMT
rubys       01/08/03 20:50:55

  Modified:    java/src/org/apache/axis/encoding SerializationContext.java
  Log:
  Format the XML
  
  Revision  Changes    Path
  1.26      +16 -4     xml-axis/java/src/org/apache/axis/encoding/SerializationContext.java
  
  Index: SerializationContext.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SerializationContext.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- SerializationContext.java	2001/08/02 12:54:16	1.25
  +++ SerializationContext.java	2001/08/04 03:50:55	1.26
  @@ -80,6 +80,8 @@
       public NSStack nsStack = new NSStack();
                                           
       boolean writingStartTag = false;
  +    boolean onlyXML = true;
  +    int indent=0;
       boolean startOfDocument = true;
       
       Stack elementStack = new Stack();
  @@ -292,14 +294,16 @@
           }
   
           if (startOfDocument && sendXMLDecl) {
  -            writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  +            writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
               startOfDocument = false;
           }
           
           if (writingStartTag) {
  -            writer.write(">");
  +            writer.write(">\n");
  +            indent++;
           }
           
  +        for (int i=0; i<indent; i++) writer.write(' ');
           StringBuffer buf = new StringBuffer();
           String elementQName = qName2String(qName);
           buf.append("<");
  @@ -330,6 +334,7 @@
   
           writer.write(buf.toString());
           writer.flush();
  +        onlyXML=true;
       }
       
       public void endElement()
  @@ -345,15 +350,20 @@
           nsStack.peek().clear();
   
           if (writingStartTag) {
  -            writer.write("/>");
  +            writer.write("/>\n");
               writingStartTag = false;
               return;
           }
           
  +        if (onlyXML) {
  +          indent--;
  +          for (int i=0; i<indent; i++) writer.write(' ');
  +        }
           StringBuffer buf = new StringBuffer();
  -        buf.append("</" + elementQName + ">");
  +        buf.append("</" + elementQName + ">\n");
           writer.write(buf.toString());
           writer.flush();
  +        onlyXML=true;
       }
       
       public void writeChars(char [] p1, int p2, int p3)
  @@ -365,6 +375,7 @@
           }
           writer.write(p1, p2, p3);
           writer.flush();
  +        onlyXML=false;
       }
   
       public void writeString(String string)
  @@ -376,6 +387,7 @@
           }
           writer.write(string);
           writer.flush();
  +        onlyXML=false;
       }
   
       public void writeSafeString(String string)
  
  
  

Mime
View raw message