// if we're immediately under the form tag
// and parent "ref" attribute is not available
if (refStack.isEmpty()) {
for (Iterator it = violations.iterator(); it.hasNext(); ) {
Violation violation = (Violation) it.next();
// render <violation> tag
// set the ref attribute
AttributesImpl atts;
if ((attributes==null) || (attributes.getLength()==0)) {
atts = new AttributesImpl();
} else {
atts = new AttributesImpl(attributes);
}
// atts.addAttribute( NS, TAG_COMMON_ATTR_REF, NS_PREFIX + ":" + TAG_COMMON_ATTR_REF, "CDATA", violation.getPath());
atts.addAttribute(null, TAG_COMMON_ATTR_REF,
TAG_COMMON_ATTR_REF, "CDATA",
violation.getPath());
// now start the element
super.startElement(uri, TAG_VIOLATION,
NS_PREFIX+":"+TAG_VIOLATION, atts);
// set message
String vm = violation.getMessage();
super.characters(vm.toCharArray(), 0, vm.length());
super.endElement(uri, TAG_VIOLATION,
NS_PREFIX+":"+TAG_VIOLATION);
}
} // end if (currentRef_ == null)
else {
Entry entry = (Entry) refStack.peek();
String currentRef = (String) entry.getValue();
Violation v = new Violation();
v.setPath(currentRef);
Collection restViolations = violations.tailSet(v);
Iterator rviter = restViolations.iterator();
while (rviter.hasNext()) {
Violation nextViolation = (Violation) rviter.next();
// we're only interested in violations
// with matching reference
if ( !currentRef.equals(nextViolation.getPath())) {
break;
}
// render <violation> tag
super.startElement(uri, TAG_VIOLATION,
NS_PREFIX+":"+TAG_VIOLATION, attributes);
// set message
String vm = nextViolation.getMessage();
super.characters(vm.toCharArray(), 0, vm.length());
super.endElement(uri, TAG_VIOLATION,
NS_PREFIX+":"+TAG_VIOLATION);
}