use of javax.xml.parsers.SAXParser in project jmeter by apache.
the class DefaultSamplerCreator method isPotentialXml.
/**
* Tries parsing to see if content is xml
* @param postData String
* @return boolean
*/
private static boolean isPotentialXml(String postData) {
try {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser saxParser = spf.newSAXParser();
XMLReader xmlReader = saxParser.getXMLReader();
ErrorDetectionHandler detectionHandler = new ErrorDetectionHandler();
xmlReader.setContentHandler(detectionHandler);
xmlReader.setErrorHandler(detectionHandler);
xmlReader.parse(new InputSource(new StringReader(postData)));
return !detectionHandler.isErrorDetected();
} catch (ParserConfigurationException | SAXException | IOException e) {
return false;
}
}
use of javax.xml.parsers.SAXParser in project maven-plugins by apache.
the class JiraXML method parse.
void parse(InputSource xmlSource) throws MojoExecutionException {
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
saxParser.parse(xmlSource, this);
} catch (Throwable t) {
throw new MojoExecutionException("Failed to parse JIRA XML.", t);
}
}
use of javax.xml.parsers.SAXParser in project intellij-community by JetBrains.
the class ImportedToGeneralTestEventsConverter method parseTestResults.
public static void parseTestResults(Reader reader, final DefaultHandler contentHandler) throws IOException {
try {
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
parser.parse(new InputSource(reader), contentHandler);
} catch (ParserConfigurationException | SAXException e) {
throw new IOException(e);
} finally {
reader.close();
}
}
use of javax.xml.parsers.SAXParser in project intellij-community by JetBrains.
the class EclipseXmlProfileReader method readSettings.
/**
* Reads either basic profile info (name) or all the settings depending on whether <code>settings</code> parameter is null.
*
* @param input The input stream to read from.
* @throws SchemeImportException
*/
protected void readSettings(InputStream input) throws SchemeImportException {
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setValidating(false);
SAXParser parser;
try {
parser = spf.newSAXParser();
parser.parse(input, this);
} catch (Exception e) {
if (e.getCause() instanceof NonEclipseXmlFileException) {
throw new SchemeImportException("The input file is not a valid Eclipse XML profile.");
} else {
throw new SchemeImportException(e);
}
}
}
use of javax.xml.parsers.SAXParser in project intellij-community by JetBrains.
the class EclipseThemeReader method readSettings.
protected void readSettings(InputStream input) throws SchemeImportException {
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setValidating(false);
SAXParser parser;
try {
parser = spf.newSAXParser();
parser.parse(input, this);
} catch (Exception e) {
if (e.getCause() instanceof NotAnEclipseThemeException) {
throw new SchemeImportException("The input file is not a valid Eclipse theme.");
} else {
throw new SchemeImportException(e);
}
}
}
Aggregations