}
if (validationNode != null &&
validationNode.getNodeType() == Node.ELEMENT_NODE &&
validationNode.getNodeName().equals(FORM_VALIDATESET_ELEMENT)) {
String validationXML = XMLUtils.serializeNodeToXML(validationNode);
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
conf = builder.build(new StringBufferInputStream(validationXML));
session.setAttribute(this.formName+"validate-set", conf);
}
}
} catch (SourceException se) {
throw new ProcessingException("Cannot resolve"+source, se);
} catch (ConfigurationException ce) {
throw new ProcessingException("Error building Configuration out of validate-set element", ce);
}
} else if (validationDoc != null) {
//validationDoc contains the validation rules inline
try {
validationDoc.normalize();
Node validationNode = validationDoc.getFirstChild();
while (validationNode.getNodeType() != Node.ELEMENT_NODE) {
validationNode = validationNode.getNextSibling();
if (validationNode == null) break;
}
if (validationNode != null &&
validationNode.getNodeType() == Node.ELEMENT_NODE &&
validationNode.getNodeName().equals("root")) {
String validationXML = XMLUtils.serializeNodeToXML(validationNode);
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
Configuration conf = null;
Session session = null;
conf = builder.build(new StringBufferInputStream(validationXML));
session = this.getSessionManager().getSession(true);
session.setAttribute(this.formName, conf);
//the constraint-set to validate is the first and single one
session.setAttribute(this.formName+"validate-set", conf.getChildren ("constraint-set")[0]);