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


Java SAXBuilder.setFeature方法代码示例

本文整理汇总了Java中org.jdom.input.SAXBuilder.setFeature方法的典型用法代码示例。如果您正苦于以下问题:Java SAXBuilder.setFeature方法的具体用法?Java SAXBuilder.setFeature怎么用?Java SAXBuilder.setFeature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jdom.input.SAXBuilder的用法示例。


在下文中一共展示了SAXBuilder.setFeature方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: constructDocumentFromXml

import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
/**
 * Construct document from xml string.
 *
 * @param xmlString the xml string
 * @return the document
 */
public static Document constructDocumentFromXml(final String xmlString) {
    try {
        final SAXBuilder builder = new SAXBuilder();
        builder.setFeature("http://xml.org/sax/features/external-general-entities", false);
        builder.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
        return builder
                .build(new ByteArrayInputStream(xmlString.getBytes(Charset.defaultCharset())));
    } catch (final Exception e) {
        return null;
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:18,代码来源:AbstractSamlObjectBuilder.java

示例2: 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

示例3: 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

示例4: constructDocumentFromXmlString

import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
public static Document constructDocumentFromXmlString(final String xmlString) {
    try {
        final SAXBuilder builder = new SAXBuilder();
        builder.setFeature("http://xml.org/sax/features/external-general-entities", false);
        builder.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
        return builder
                .build(new ByteArrayInputStream(xmlString.getBytes()));
    } catch (final Exception e) {
        return null;
    }
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:12,代码来源:SamlUtils.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: 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

示例7: createBuilder

import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
/**
 * Create and initialize the SAX builder.
 * 
 * @return the SAX builder instance.
 * @since 1.4.9
 */
protected SAXBuilder createBuilder() {
    final SAXBuilder builder = new SAXBuilder();
    builder.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
    return builder;
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:12,代码来源:JDomDriver.java


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