code: public void writeElement(String name, int type) {
          StringBuffer nsdecl = new StringBuffer();
  
          if (_isRootElement) {
              for (Iterator<String> iter = _namespaces.keySet().iterator(); iter
                      .hasNext();) {
                  String fullName = (String) iter.next();
                  String abbrev = (String) _namespaces.get(fullName);
                  nsdecl.append(" xmlns:").append(abbrev).append("=\"").append(
                          fullName).append("\"");
              }
              _isRootElement = false;
          }
  
          int pos = name.lastIndexOf(':');
          if (pos >= 0) {
              // lookup prefix for namespace
              String fullns = name.substring(0, pos);
              String prefix = (String) _namespaces.get(fullns);
              if (prefix == null) {
                  // there is no prefix for this namespace
                  name = name.substring(pos + 1);
                  nsdecl.append(" xmlns=\"").append(fullns).append("\"");
              } else {
                  // there is a prefix
                  name = prefix + ":" + name.substring(pos + 1);
              }
          } else {
              throw new IllegalArgumentException(
                      "All XML elements must have a namespace");
          }
  
          switch (type) {
          case OPENING:
              _buffer.append("<");
              _buffer.append(name);
              _buffer.append( nsdecl);
              _buffer.append( ">");
              break;
          case CLOSING:
              _buffer.append("</");
              _buffer.append( name);
              _buffer.append( ">\n");
              break;
          case NO_CONTENT:
          default:
              _buffer.append("<");
              _buffer.append( name);
              _buffer.append( nsdecl);
              _buffer.append( "/>");
              break;
          }
      }
docs: Write an element.
  
  @param name
  Element name
  @param type
  Element type