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


Java DocumentBuilderFactoryImpl类代码示例

本文整理汇总了Java中org.apache.xerces.jaxp.DocumentBuilderFactoryImpl的典型用法代码示例。如果您正苦于以下问题:Java DocumentBuilderFactoryImpl类的具体用法?Java DocumentBuilderFactoryImpl怎么用?Java DocumentBuilderFactoryImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testDocumentBuilderFactoryInWhiteList

import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; //导入依赖的package包/类
/**
 * Test we have set features the way we expect as defaults.
 */
public void testDocumentBuilderFactoryInWhiteList() throws Throwable
{
    // Using constructor rather than the service locator and then using the helper to configure it.
    DocumentBuilderFactory dbf = new DocumentBuilderFactoryImpl();
    FactoryHelper factoryHelper = new FactoryHelper();
    List<String> whiteListClasses = Collections.singletonList(getClass().getName());
    factoryHelper.configureFactory(dbf, FactoryHelper.DEFAULT_FEATURES_TO_ENABLE,
            FactoryHelper.DEFAULT_FEATURES_TO_DISABLE,
            whiteListClasses);

    assertFalse(dbf.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING));
    assertFalse(dbf.getFeature(FactoryHelper.FEATURE_DISALLOW_DOCTYPE));

    assertTrue(dbf.getFeature(FactoryHelper.FEATURE_EXTERNAL_GENERAL_ENTITIES));
    assertTrue(dbf.getFeature(FactoryHelper.FEATURE_EXTERNAL_PARAMETER_ENTITIES));
    assertTrue(dbf.getFeature(FactoryHelper.FEATURE_USE_ENTITY_RESOLVER2));
    assertTrue(dbf.getFeature(FactoryHelper.FEATURE_LOAD_EXTERNAL_DTD));

    assertTrue(dbf.isExpandEntityReferences());
    assertFalse(dbf.isXIncludeAware()); // false is the default so is same as the non whitelist test
}
 
开发者ID:Alfresco,项目名称:alfresco-xml-factory,代码行数:25,代码来源:AppTest.java

示例2: Parser

import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; //导入依赖的package包/类
/**
 * Parser constructor.
 *
 * @param fileName The input .xml file to parse.
 * @param rootTag A root tag name to check against the XML document.
 */
public Parser(String fileName, String rootTag) throws FileNotFoundException {
	try {
		DocumentBuilderFactory dFactory = DocumentBuilderFactoryImpl.newInstance();
		DocumentBuilder dBuilder = dFactory.newDocumentBuilder();
		document = dBuilder.parse(new File(fileName));

		log.info("Parsed file: {}", fileName);

		if(!document.getDocumentElement().getTagName().equals(rootTag)) {
			throw new UnsupportedOperationException("Root tag \"" + rootTag + "\" not found.");
		}
	} catch(Exception e) {
		if(e instanceof FileNotFoundException) {
			throw new FileNotFoundException("Could not find XML document at " + fileName + ".");
		}

		log.error("Could not parse the XML document.", e);
	}
}
 
开发者ID:fauxpark,项目名称:phoebe,代码行数:26,代码来源:Parser.java

示例3: testParseLocalFile

import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; //导入依赖的package包/类
@Test
public void testParseLocalFile() throws Exception {
	// Parse and traverse XML file with ScaleDOM
	System.setProperty("javax.xml.parsers.DocumentBuilderFactory", 
			ScaleDomDocumentBuilderFactory.class.getName());
	System.out.println("INFO: Parsing with ScaleDOM, please be patient (may take several minutes)...");
	doParseFile("file://" + tmpXmlFile);

	// Parse and traverse XML file with standard XML parser (Xerces)
	System.setProperty("javax.xml.parsers.DocumentBuilderFactory", 
			DocumentBuilderFactoryImpl.class.getName());
	System.out.println("INFO: Parsing with Xerces, please be patient (may take several minutes)...");
	try {
		System.gc();
		doParseFile("file://" + tmpXmlFile);
	} catch (OutOfMemoryError t) {
		System.out.println("INFO: Xerces was unable to parse the file due to OutOfMemoryError. (This is EXPECTED!)");
	}

}
 
开发者ID:whummer,项目名称:scaleDOM,代码行数:21,代码来源:ScaleDomParsingTest.java

示例4: MCRDOMUtils

import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; //导入依赖的package包/类
private MCRDOMUtils() {
    builderQueue = new ConcurrentLinkedQueue<>();
    docBuilderFactory = DocumentBuilderFactory.newInstance(DocumentBuilderFactoryImpl.class.getName(), getClass()
        .getClassLoader());
    docBuilderFactory.setNamespaceAware(true);
    MCRShutdownHandler.getInstance().addCloseable(this);
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:8,代码来源:MCRDOMUtils.java

示例5: newDocumentBuilderFactory

import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; //导入依赖的package包/类
private DocumentBuilderFactory newDocumentBuilderFactory() {
	try{
   		return new DocumentBuilderFactoryImpl();
   	}
   	catch(Throwable t) {
   		return DocumentBuilderFactory.newInstance();
   	}
}
 
开发者ID:lucee,项目名称:Lucee,代码行数:9,代码来源:XMLUtilImpl.java

示例6: getDocumentBuilderFactory

import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; //导入依赖的package包/类
/**
 * @return a factory for parsers that use this schema.
 */
DocumentBuilderFactory getDocumentBuilderFactory()
{
  if (mSchema == null)
  {
    throw new RuntimeException("Not yet parsed");
  }

  // Thanks http://xerces.apache.org/xerces2-j/faq-dom.html#faq-8
  DocumentBuilderFactoryImpl lFactory =
      (DocumentBuilderFactoryImpl)DocumentBuilderFactory.newInstance(
                           DocumentBuilderFactoryImpl.class.getName(), null);
  lFactory.setNamespaceAware(true);
  lFactory.setValidating(true);
  lFactory.setAttribute("http://apache.org/xml/features/validation/schema",
                        Boolean.TRUE);
  lFactory.setAttribute("http://apache.org/xml/features/validation/schema-full-checking",
                        Boolean.TRUE);
  lFactory.setAttribute("http://apache.org/xml/properties/dom/document-class-name",
                        "org.apache.xerces.dom.PSVIDocumentImpl");

  lFactory.setSchema(mSchema);
  // Undocumented but necessary to force the
  // org.apache.xerces.impl.xs.XmlSchemaValidator to actually use our schema
  // - otherwise the above schema doesn't make it all the way down the
  // stack. Sigh.
  lFactory.setAttribute("http://apache.org/xml/properties/internal/grammar-pool",
                        ((XSGrammarPoolContainer)mSchema).getGrammarPool());

  return lFactory;
}
 
开发者ID:kw217,项目名称:sax2j,代码行数:34,代码来源:XmlSchema.java

示例7: Generador

import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; //导入依赖的package包/类
public Generador() throws ParserConfigurationException{
	// Inicializamos factoría (xerces) de creación de documentos XML (DOM)
	dbFactory = DocumentBuilderFactoryImpl.newInstance();
    docBuilder = dbFactory.newDocumentBuilder();
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:6,代码来源:Generador.java

示例8: newDocumentBuilderFactory

import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; //导入依赖的package包/类
private static DocumentBuilderFactory newDocumentBuilderFactory() {
	return new DocumentBuilderFactoryImpl();
   	// we do not use DocumentBuilderFactory.newInstance(); because it is unpredictable
}
 
开发者ID:lucee,项目名称:Lucee,代码行数:5,代码来源:XMLUtil.java

示例9: ConfigParserContentHandler

import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; //导入依赖的package包/类
public ConfigParserContentHandler() throws Exception {
    DocumentBuilderFactory dbf = DocumentBuilderFactoryImpl.newInstance(); // Xerces
    db = dbf.newDocumentBuilder();
}
 
开发者ID:avast,项目名称:syringe,代码行数:5,代码来源:XmlConfigParser.java

示例10: createReportDocument

import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; //导入依赖的package包/类
/**
 * Create an XML document based on mapping verification result
 * @return
 */
private Document createReportDocument()
{
	Document dom=null;
	DocumentBuilderFactory dbf = DocumentBuilderFactoryImpl.newInstance();
	try
	{
		//get an instance of builder
		DocumentBuilder db = dbf.newDocumentBuilder();

		//create an instance of DOM
		dom = db.newDocument();
		Element  rootElm=dom.createElement("unmapped");
		rootElm.setAttribute("type", reportType);
		dom.appendChild(rootElm);

		Element components=dom.createElement("components");
		Element srcNode=dom.createElement("component");
		srcNode.setAttribute("kind", "scs");
		String srcFilePath = getSourceFileName();
           if (srcFilePath.startsWith(FileUtil.getWorkingDirPath()))
           	srcFilePath = srcFilePath.replace(FileUtil.getWorkingDirPath(), Config.CAADAPTER_HOME_DIR_TAG);

		srcNode.setAttribute("location", srcFilePath);
		srcNode.setAttribute("type", "source");
		components.appendChild(srcNode);

		Element trgtNode=dom.createElement("component");
		trgtNode.setAttribute("kind", "xmi");
		String tgrtFilePath =getTargetFileName();
           if (tgrtFilePath.startsWith(FileUtil.getWorkingDirPath()))
           	tgrtFilePath = tgrtFilePath.replace(FileUtil.getWorkingDirPath(), Config.CAADAPTER_HOME_DIR_TAG);

		trgtNode.setAttribute("location", tgrtFilePath);
		trgtNode.setAttribute("type", "target");
		components.appendChild(trgtNode);

		rootElm.appendChild(components);

		Element unmappedFields=dom.createElement("fields");
		for(String oneItem:reportElments)
		{
			Element rptItem=dom.createElement("field");
			rptItem.setAttribute("kind", "scs");
			rptItem.setAttribute("xmlPath", oneItem);
			unmappedFields.appendChild(rptItem);
		}
		rootElm.appendChild(unmappedFields);
	}
	catch(ParserConfigurationException  e)
	{
		e.printStackTrace();
	}
	return dom;
}
 
开发者ID:NCIP,项目名称:caadapter,代码行数:59,代码来源:XsdToXmiMappingReporter.java

示例11: SimpleXMLParser

import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; //导入依赖的package包/类
/**
 * Create an instance of the SimpleXMLParser.
 * @throws ParserConfigurationException if the object cannot create an
 * instance of the Xerces parser it uses internally.
 */
public SimpleXMLParser() throws ParserConfigurationException {
  // throws ParserConfigurationException if creation fails
  builder = DocumentBuilderFactoryImpl.newInstance().newDocumentBuilder();
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:10,代码来源:SimpleXMLParser.java


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