private void toXml(XmppStreamWriter out, DataOption option)
      throws IOException, XMLStreamException {
    out.writeStartElement("option");

    if (option.getLabel() != null) out.writeAttribute("label", option.getLabel());

    DataValue[] values = option.getValue();
    if (values != null) {
      for (int i = 0; i < values.length; i++) {
        DataValue value = values[i];

        out.writeStartElement("value");
        out.writeCharacters(value.getValue());
        out.writeEndElement(); // </value>
      }
    }

    out.writeEndElement(); // </option>
  }
  private void toXml(XmppStreamWriter out, DataField field) throws IOException, XMLStreamException {
    out.writeStartElement("field");

    if (field.getLabel() != null) out.writeAttribute("label", field.getLabel());

    if (field.getType() != null) out.writeAttribute("type", field.getType());

    if (field.getVar() != null) out.writeAttribute("var", field.getVar());

    if (field.getDesc() != null) {
      out.writeStartElement("desc");
      out.writeCharacters(field.getDesc());
      out.writeEndElement(); // </desc>
    }

    if (field.isRequired()) {
      out.writeStartElement("required");
      out.writeEndElement(); // </required>
    }

    DataValue[] values = field.getValue();
    if (values != null) {
      for (int i = 0; i < values.length; i++) {
        DataValue value = values[i];

        out.writeStartElement("value");
        out.writeCharacters(value.getValue());
        out.writeEndElement(); // </value>
      }
    }

    DataOption[] options = field.getOption();
    if (options != null) {
      for (int i = 0; i < options.length; i++) {
        toXml(out, options[i]);
      }
    }

    out.writeEndElement(); // </field>
  }