public void write(XmlVisitor xa) {
    ElementVisitor elementVisitor = xa.visitElement(name);

    // Attributes
    if (attributes != null) {
      for (Entry<String, TextWriter> entry : attributes.entrySet()) {
        String attrName = entry.getKey();
        TextWriter textWriter = entry.getValue();
        String value = textWriter.getText();
        if (value != null) elementVisitor.visitAttribute(attrName, value);
      }
    }

    // Body
    if (body != null && !body.isEmpty()) {
      XmlVisitor bodyVisitor = elementVisitor.visitBody();
      body.write(bodyVisitor);
      bodyVisitor.visitEndBody();
    }

    elementVisitor.visitEndElement();
  }
Esempio n. 2
0
 public String popTextWriter() {
   TextWriter textWriter = textWriterStack.pop();
   return textWriter.getText();
 }