Program: 23013
Project: 23013
Buggy source:
private void composeElement(IXMLWriter xml,Element element,String elementName) throws IOException {
  for (  String s : element.getComments()) {
    xml.comment(s,true);
  }
  if (isText(element.getProperty())) {
    if (linkResolver != null)     xml.link(linkResolver.resolveProperty(element.getProperty()));
    xml.enter(elementName);
    xml.text(element.getValue());
    xml.exit(elementName);
  }
 else   if (element.isPrimitive() || (element.hasType() && isPrimitive(element.getType()))) {
    if (element.getType().equals("String_Node_Str")) {
      xml.escapedText(element.getValue());
    }
 else     if (isText(element.getProperty())) {
      if (linkResolver != null)       xml.link(linkResolver.resolveProperty(element.getProperty()));
      xml.text(element.getValue());
    }
 else {
      if (element.hasValue()) {
        if (linkResolver != null)         xml.link(linkResolver.resolveType(element.getType()));
        xml.attribute("String_Node_Str",element.getValue());
      }
      if (linkResolver != null)       xml.link(linkResolver.resolveProperty(element.getProperty()));
      if (element.hasChildren()) {
        xml.enter(elementName);
        for (        Element child : element.getChildren())         composeElement(xml,child,child.getName());
        xml.exit(elementName);
      }
 else       xml.element(elementName);
    }
  }
 else {
    for (    Element child : element.getChildren()) {
      if (isAttr(child.getProperty())) {
        if (linkResolver != null)         xml.link(linkResolver.resolveType(child.getType()));
        xml.attribute(child.getName(),child.getValue());
      }
    }
    if (linkResolver != null)     xml.link(linkResolver.resolveProperty(element.getProperty()));
    xml.enter(elementName);
    if (element.getSpecial() != null) {
      if (linkResolver != null)       xml.link(linkResolver.resolveProperty(element.getProperty()));
      xml.enter(element.getType());
    }
    for (    Element child : element.getChildren()) {
      if (isText(child.getProperty())) {
        if (linkResolver != null)         xml.link(linkResolver.resolveProperty(element.getProperty()));
        xml.text(child.getValue());
      }
 else       if (!isAttr(child.getProperty()))       composeElement(xml,child,child.getName());
    }
    if (element.getSpecial() != null)     xml.exit(element.getType());
    xml.exit(elementName);
  }
}

Fixed version (ground truth):
private void composeElement(IXMLWriter xml,Element element,String elementName,boolean root) throws IOException {
  for (  String s : element.getComments()) {
    xml.comment(s,true);
  }
  if (isText(element.getProperty())) {
    if (linkResolver != null)     xml.link(linkResolver.resolveProperty(element.getProperty()));
    xml.enter(elementName);
    xml.text(element.getValue());
    xml.exit(elementName);
  }
 else   if (element.isPrimitive() || (element.hasType() && isPrimitive(element.getType()))) {
    if (element.getType().equals("String_Node_Str")) {
      xml.escapedText(element.getValue());
    }
 else     if (isText(element.getProperty())) {
      if (linkResolver != null)       xml.link(linkResolver.resolveProperty(element.getProperty()));
      xml.text(element.getValue());
    }
 else {
      if (element.hasValue()) {
        if (linkResolver != null)         xml.link(linkResolver.resolveType(element.getType()));
        xml.attribute("String_Node_Str",element.getValue());
      }
      if (linkResolver != null)       xml.link(linkResolver.resolveProperty(element.getProperty()));
      if (element.hasChildren()) {
        xml.enter(elementName);
        for (        Element child : element.getChildren())         composeElement(xml,child,child.getName(),false);
        xml.exit(elementName);
      }
 else       xml.element(elementName);
    }
  }
 else {
    for (    Element child : element.getChildren()) {
      if (isAttr(child.getProperty())) {
        if (linkResolver != null)         xml.link(linkResolver.resolveType(child.getType()));
        xml.attribute(child.getName(),child.getValue());
      }
    }
    if (linkResolver != null)     xml.link(linkResolver.resolveProperty(element.getProperty()));
    xml.enter(elementName);
    if (!root && element.getSpecial() != null) {
      if (linkResolver != null)       xml.link(linkResolver.resolveProperty(element.getProperty()));
      xml.enter(element.getType());
    }
    for (    Element child : element.getChildren()) {
      if (isText(child.getProperty())) {
        if (linkResolver != null)         xml.link(linkResolver.resolveProperty(element.getProperty()));
        xml.text(child.getValue());
      }
 else       if (!isAttr(child.getProperty()))       composeElement(xml,child,child.getName(),false);
    }
    if (!root && element.getSpecial() != null)     xml.exit(element.getType());
    xml.exit(elementName);
  }
}