//////////////////////////////////////////////////////////////////////////////
// 
//                    Copyright 2012, Cornutum Project
//                             www.cornutum.org
//
//////////////////////////////////////////////////////////////////////////////

package org.cornutum.tcases.util;

import java.io.OutputStream;
import java.io.Writer;
  
/**
 * Supports creation of an XML document stream.
 *
 */
public class XmlWriter extends IndentedWriter
  {
  /**
   * Creates a new XmlWriter object.
   */
  public XmlWriter( OutputStream output)
    {
    super( output);
    }

  /**
   * Creates a new XmlWriter object.
   */
  public XmlWriter( Writer writer)
    {
    super( writer);
    }

  /**
   * Writes the standard XML document declaration
   */
  public void writeDeclaration( String encoding)
    {
    print( "<?xml version=\"1.0\"");
    if( encoding != null)
      {
      writeAttribute( "encoding", encoding);
      }
    println( "?>");
    }

  /**
   * Writes the standard XML document declaration
   */
  public void writeDeclaration()
    {
    writeDeclaration( null);
    }

  /**
   * Begins an element start tag.
   */
  public void writeTagStart( String tag)
    {
    startLine();
    print( "<");
    print( tag);
    }

  /**
   * Completes an element start tag.
   */
  public void writeTagEnd()
    {
    print( ">");
    println();
    }

  /**
   * Writes an element start tag.
   */
  public void writeElementStart( String tag)
    {
    startLine();
    print( "<");
    print( tag);
    print( ">");
    println();
    }

  /**
   * Writes an element end tag.
   */
  public void writeElementEnd( String tag)
    {
    startLine();
    print( "</");
    print( tag);
    print( ">");
    println();
    }

  /**
   * Writes the end of an empty element.
   */
  public void writeEmptyElementEnd()
    {
    print( "/>");
    println();
    }

  /**
   * Writes an attribute definition.
   */
  public void writeAttribute( String name, String value)
    {
    print( " ");
    print( name);
    print( "=\"");
    print( value);
    print( "\"");
    }
  }

@@ -1371,32 +1371,294 @@
 intln();%0A    %7D%0A%0A
+  /**%0A   * Writes an element on a single line.%0A   */%0A  public void writeElement( String tag, String content)%0A    %7B%0A    startLine();%0A    print( %22%3C%22); print( tag); print( %22%3E%22);%0A    print( content);%0A    print( %22%3C/%22); print( tag); print( %22%3E%22);%0A    println();%0A    %7D%0A%0A
   /**%0A   * Write

Add method=writeElement