use of org.xml.sax.SAXParseException in project gocd by gocd.
the class GoPluginDescriptorParser method initDigester.
private static Digester initDigester() throws SAXNotRecognizedException, SAXNotSupportedException {
Digester digester = new Digester();
digester.setValidating(true);
digester.setErrorHandler(new ErrorHandler() {
@Override
public void warning(SAXParseException exception) throws SAXException {
throw new SAXException("XML Schema validation of Plugin Descriptor(plugin.xml) failed", exception);
}
@Override
public void error(SAXParseException exception) throws SAXException {
throw new SAXException("XML Schema validation of Plugin Descriptor(plugin.xml) failed", exception);
}
@Override
public void fatalError(SAXParseException exception) throws SAXException {
throw new SAXException("XML Schema validation of Plugin Descriptor(plugin.xml) failed", exception);
}
});
digester.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", XMLConstants.W3C_XML_SCHEMA_NS_URI);
digester.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", GoPluginDescriptorParser.class.getResourceAsStream("/plugin-descriptor.xsd"));
return digester;
}
use of org.xml.sax.SAXParseException in project gocd by gocd.
the class XsdErrorTranslatorTest method shouldHumanizeErrorsDuringCommandSnippetValidationWhenInvalidTagFound.
@Test
public void shouldHumanizeErrorsDuringCommandSnippetValidationWhenInvalidTagFound() throws SAXException {
translator.error(new SAXParseException("cvc-elt.1: Cannot find the declaration of element 'invalidTag'.", null));
assertThat(translator.translate(), is("Invalid XML tag \"invalidTag\" found."));
}
use of org.xml.sax.SAXParseException in project gocd by gocd.
the class XsdErrorTranslatorTest method shouldDealWithPatternValidForAnonymousErrors.
@Test
public void shouldDealWithPatternValidForAnonymousErrors() throws SAXException {
translator.error(new SAXParseException("cvc-pattern-valid: Value 'Ethan's Work (TA)' is not facet-valid with respect to pattern '[^\\s]+' for type '#AnonType_projectIdentifiermingleType'.", null));
assertThat(translator.translate(), is("Project identifier in Mingle is invalid. \"Ethan's Work (TA)\" should conform to the pattern - [^\\s]+"));
}
use of org.xml.sax.SAXParseException in project gocd by gocd.
the class XsdErrorTranslatorTest method shouldReturnOriginalXsdErrorIfMappingNotDefined.
@Test
public void shouldReturnOriginalXsdErrorIfMappingNotDefined() throws Exception {
translator.error(new SAXParseException("cvc-elt.1: Cannot find the declaration of element 'element'", null));
assertThat(translator.translate(), is("Cannot find the declaration of element 'element'"));
}
use of org.xml.sax.SAXParseException in project drools by kiegroup.
the class PatternHandler method start.
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
final String objectType = attrs.getValue("object-type");
if (objectType == null || objectType.trim().equals("")) {
throw new SAXParseException("<pattern> requires an 'object-type' attribute", parser.getLocator());
}
PatternDescr patternDescr = null;
final String identifier = attrs.getValue("identifier");
if (identifier == null || identifier.trim().equals("")) {
patternDescr = new PatternDescr(objectType);
} else {
patternDescr = new PatternDescr(objectType, identifier);
}
return patternDescr;
}
Aggregations