code: public void writeTo(Writer destination) {
          Element eltRuleset = new Element("ruleset");
          addAttribute(eltRuleset, "name", name);
          addChild(eltRuleset, "description", description);
          for (PmdRule pmdRule : rules) {
              Element eltRule = new Element("rule");
              addAttribute(eltRule, "ref", pmdRule.getRef());
              addAttribute(eltRule, "class", pmdRule.getClazz());
              addAttribute(eltRule, "message", pmdRule.getMessage());
              addAttribute(eltRule, "name", pmdRule.getName());
              addAttribute(eltRule, "language", pmdRule.getLanguage());
              addChild(eltRule, "priority", String.valueOf(pmdRule.getPriority()));
              if (pmdRule.hasProperties()) {
                  Element ruleProperties = processRuleProperties(pmdRule);
                  if (ruleProperties.getContentSize() > 0) {
                      eltRule.addContent(ruleProperties);
                  }
              }
              eltRuleset.addContent(eltRule);
          }
          XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
          try {
              serializer.output(new Document(eltRuleset), destination);
          } catch (IOException e) {
              throw new IllegalStateException("An exception occurred while serializing PmdRuleSet.", e);
          }
      }
docs: Serializes this RuleSet in an XML document.
  
  @param destination The writer to which the XML document shall be written.