当前位置: 首页>>代码示例>>Java>>正文


Java SAXBuilder.setValidation方法代码示例

本文整理汇总了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());
    }
}
 
开发者ID:dbunibas,项目名称:spicy,代码行数:20,代码来源:DAOXmlUtility.java

示例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());
        }
    }
}
 
开发者ID:intuit,项目名称:Tank,代码行数:28,代码来源:GenericXMLHandler.java

示例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);
   }
 
开发者ID:openaire,项目名称:iis,代码行数:20,代码来源:NlmToDocumentTextConverterTest.java

示例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);
}
 
开发者ID:openaire,项目名称:iis,代码行数:22,代码来源:NlmToDocumentTextConverterTest.java

示例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);
}
 
开发者ID:equella,项目名称:Equella,代码行数:16,代码来源:JPFClasspathFixProcessor.java

示例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;
    }
}
 
开发者ID:jwpttcg66,项目名称:redis-game-transaction,代码行数:13,代码来源:JdomUtils.java

示例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);
}
 
开发者ID:openaire,项目名称:iis,代码行数:22,代码来源:MetadataImporter.java


注:本文中的org.jdom.input.SAXBuilder.setValidation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。