public void write(SenateResponse response, OutputStream out) throws IOException {
    Element root = new Element("results");
    root.setAttribute("total", response.getMetadata().get("totalresults").toString());
    for (Result result : response.getResults()) {
      Element resultNode = new Element("result");
      resultNode.setAttribute("type", result.getOtype());
      resultNode.setAttribute("id", result.getOid());
      resultNode.setAttribute("title", result.getTitle());
      if (result.getOtype().equals("action")) {
        Action action = (Action) result.getObject();
        resultNode.setAttribute("billno", action.getBill().getBillId());
      } else if (result.getOtype().equals("vote")) {
        Vote vote = (Vote) result.getObject();
        resultNode.setAttribute("billno", vote.getBill().getBillId());
        resultNode.setAttribute("sponsor", vote.getBill().getSponsor().getFullname());
      } else if (result.getOtype().equals("bill")) {
        root.setName("docket");
        resultNode.setName("bill");
        Bill bill = (Bill) result.getObject();
        resultNode.setAttribute("billId", bill.getBillId());
        resultNode.setAttribute("senateId", bill.getBillId());
        resultNode.setAttribute("year", String.valueOf(bill.getYear()));
        resultNode.setAttribute("law", bill.getLaw());
        resultNode.setAttribute("lawSection", bill.getLawSection());
        resultNode.setAttribute("sponsor", bill.getSponsor().getFullname());
        resultNode.setAttribute("assemblySameAs", bill.getSameAs());
        resultNode.setAttribute("sameAs", bill.getSameAs());

        Element cosponsorsNode = new Element("cosponsors");
        for (Person cosponsor : bill.getCoSponsors()) {
          Element cosponsorNode = new Element("cosponsor");
          cosponsorNode.addContent(cosponsor.getFullname());
        }
        resultNode.addContent(cosponsorsNode);

        Element summaryNode = new Element("summary");
        summaryNode.addContent(bill.getSummary());
        resultNode.addContent(summaryNode);

        Element committeeNode = new Element("committee");
        committeeNode.addContent(bill.getCurrentCommittee());
        resultNode.addContent(committeeNode);
      } else if (result.getOtype().equals("meeting")) {
        Meeting meeting = (Meeting) result.getObject();
        resultNode.setAttribute("committee", meeting.getCommitteeName());
        resultNode.setAttribute("location", meeting.getLocation());
        resultNode.setAttribute("chair", meeting.getCommitteeChair());
      } else if (result.getOtype().equals("transcript")) {
        Transcript transcript = (Transcript) result.getObject();
        resultNode.setAttribute("location", transcript.getLocation());
      } else if (result.getOtype().equals("calendar")) {
        // no additional fields.
      }
      root.addContent(resultNode);
    }
    write(root, out);
  }
 public static Element getElement(ValidationTechnique validationTechnique) {
   Element element = ParameterOwnerXML.getElement(validationTechnique);
   element.setName(ELEMENT_NAME);
   return element;
 }