本文整理汇总了Java中org.jdom.input.SAXBuilder.setValidation方法的典型用法代码示例。如果您正苦于以下问题:Java SAXBuilder.setValidation方法的具体用法?Java SAXBuilder.setValidation怎么用?Java SAXBuilder.setValidation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdom.input.SAXBuilder
的用法示例。
在下文中一共展示了SAXBuilder.setValidation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildDOM
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
public org.jdom.Document buildDOM(String fileName) throws DAOException {
if (fileName == null || "".equals(fileName)) {
throw new DAOException("Unable to load file. Null or empty path requested");
}
SAXBuilder builder = new SAXBuilder();
builder.setValidation(false);
org.jdom.Document document = null;
try {
fileName = checkFilePath(fileName);
document = builder.build(fileName);
return document;
} catch (org.jdom.JDOMException jde) {
logger.error(jde);
throw new DAOException(jde.getMessage());
} catch (java.io.IOException ioe) {
logger.error(ioe);
throw new DAOException(ioe.getMessage());
}
}
示例2: GenericXMLHandler
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
/**
* Constructor
*
* @param xmlFile
* The string representation of the xml data
*/
public GenericXMLHandler(String xmlFile) {
if (StringUtils.isNotEmpty(xmlFile)) {
this.xml = xmlFile;
try {
this.xmlFile = null;
this.xmlDocument = new org.jdom.Document();
SAXBuilder builder = new SAXBuilder();
builder.setValidation(false);
// LOG.debug("XML string to load: "+xmlFile);
xmlFile = xmlFile.substring(xmlFile.indexOf("<"));
this.xmlDocument = builder.build(new StringReader(xmlFile));
this.namespaces = new HashMap<String, String>();
InputSource is = new InputSource(new StringReader(xml));
this.dDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(is);
} catch (Exception ex) {
this.xmlDocument = null;
LOG.error("Error parsing xml Response: " + xmlFile + ": " + ex.getMessage());
}
}
}
示例3: testConvertFull
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
@Test
public void testConvertFull() throws Exception {
SAXBuilder builder = new SAXBuilder();
builder.setValidation(false);
builder.setFeature("http://xml.org/sax/features/validation", false);
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
InputStreamReader testIS = new InputStreamReader(ClassLoader.class.getResourceAsStream(testXML), "UTF-8");
Document document = builder.build(testIS);
Element sourceDocument = document.getRootElement();
String testText = NlmToDocumentTextConverter.getDocumentText(sourceDocument, null);
testIS.close();
InputStream expectedIS = ClassLoader.class.getResourceAsStream(testTXT);
String expectedText = IOUtils.toString(expectedIS, "UTF-8").replaceAll(System.getProperty("line.separator"), "\n");
expectedIS.close();
assertEquals(expectedText, testText);
}
示例4: testConvertFullNestedInOAI
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
@Test
public void testConvertFullNestedInOAI() throws Exception {
SAXBuilder builder = new SAXBuilder();
builder.setValidation(false);
builder.setFeature("http://xml.org/sax/features/validation", false);
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
InputStreamReader testIS = new InputStreamReader(ClassLoader.class.getResourceAsStream(testXmlNestedInOAI), "UTF-8");
Document document = builder.build(testIS);
Element sourceDocument = document.getRootElement();
String testText = NlmToDocumentTextConverter.getDocumentText(sourceDocument,
Namespace.getNamespace("http://www.openarchives.org/OAI/2.0/"));
testIS.close();
InputStream expectedIS = ClassLoader.class.getResourceAsStream(testTxtNestedInOAI);
String expectedText = IOUtils.toString(expectedIS, "UTF-8").replaceAll(System.getProperty("line.separator"), "\n");
expectedIS.close();
assertEquals(expectedText, testText);
}
示例5: JPFClasspathFixProcessor
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
public JPFClasspathFixProcessor()
{
super();
sax = new SAXBuilder();
sax.setValidation(false);
sax.setReuseParser(true);
sax.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
Format format = Format.getRawFormat();
format.setOmitEncoding(true);
format.setOmitDeclaration(true);
format.setLineSeparator("\n");
format.setEncoding("UTF-8");
xmlOut = new XMLOutputter(format);
}
示例6: getRootElemet
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
public static Element getRootElemet(String xmlPath) {
SAXBuilder builder = new SAXBuilder();
builder.setValidation(false);
Document doc = null;
try {
doc = builder.build(xmlPath);
return doc.getRootElement();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例7: extractText
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
/**
* Extracts plain text from given xml input.
*
* @param xmlInput
* @param oaiNamespace
* @return plaintext extracted from xml input
* @throws JDOMException
* @throws IOException
*/
protected static CharSequence extractText(String xmlInput, Namespace oaiNamespace)
throws JDOMException, IOException {
SAXBuilder builder = new SAXBuilder();
builder.setValidation(false);
builder.setFeature("http://xml.org/sax/features/validation", false);
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
StringReader textReader = new StringReader(xmlInput);
Document document = builder.build(textReader);
Element sourceDocument = document.getRootElement();
return NlmToDocumentTextConverter.getDocumentText(sourceDocument, oaiNamespace);
}