private void writeElementType(ElementType elementType)
      throws IOException
   {
      ElementType child;

      if (pretty)
      {
         writer.write(RETURN);
         writer.write(RETURN);
      }

      writer.write(DECLSTART);
      writer.write(DTDConst.KEYWD_ELEMENT);
      writer.write(SPACE);
      writer.write(elementType.name.getQualifiedName());
      writer.write(SPACE);

      switch (elementType.contentType)
      {
         case ElementType.CONTENT_EMPTY:
            writer.write(DTDConst.KEYWD_EMPTY);
            break;

         case ElementType.CONTENT_ANY:
            writer.write(DTDConst.KEYWD_ANY);
            break;

         case ElementType.CONTENT_PCDATA:
            writer.write(GROUPSTART);
            writer.write(POUND);
            writer.write(DTDConst.KEYWD_PCDATA);
            writer.write(GROUPEND);
            break;

         case ElementType.CONTENT_MIXED:
            writer.write(GROUPSTART);
            writer.write(POUND);
            writer.write(DTDConst.KEYWD_PCDATA);

            // Write the children -- assume there is at least one...

            Enumeration e = elementType.children.elements();
            while (e.hasMoreElements())
            {
               writer.write(CHOICESEPARATOR);
               child = (ElementType)e.nextElement();
               writer.write(child.name.getQualifiedName());
            }

            writer.write(GROUPEND);
            writer.write(ZEROORMORE);
            break;

         case ElementType.CONTENT_ELEMENT:
            if (elementType.content.type == Particle.TYPE_ELEMENTTYPEREF)
            {
               // If the content model is a single element type reference,
               // we need to write the surrounding parentheses ourselves.
               // Otherwise, these are taken care of by writeGroup().

               writer.write(GROUPSTART);
               writeParticle(elementType.content);
               writer.write(GROUPEND);
            }
            else
            {
               writeParticle(elementType.content);
            }
            break;
      }
      writer.write(DECLEND);

      writeAttributes(elementType);
   }