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


Java XMLReaderJDOMFactory类代码示例

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


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

示例1: createBuilder

import org.jdom2.input.sax.XMLReaderJDOMFactory; //导入依赖的package包/类
private SAXBuilder createBuilder()
{
	return new SAXBuilder(new XMLReaderJDOMFactory()
	{
		@Override
		public XMLReader createXMLReader() throws JDOMException
		{
			SAXParserFactory fac = SAXParserFactory.newInstance();
			// All JDOM parsers are namespace aware.
			fac.setNamespaceAware(true);
			fac.setValidating(false);
			try
			{
				fac.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
				return fac.newSAXParser().getXMLReader();
			}
			catch (ParserConfigurationException | SAXException e)
			{
				throw new RuntimeException(e);
			}
		}

		@Override
		public boolean isValidating()
		{
			return false;
		}
	}, null, null);
}
 
开发者ID:equella,项目名称:Equella,代码行数:30,代码来源:RssPortletRenderer.java

示例2: MCRXMLParserImpl

import org.jdom2.input.sax.XMLReaderJDOMFactory; //导入依赖的package包/类
public MCRXMLParserImpl(XMLReaderJDOMFactory factory, boolean silent) {
    this.validate = factory.isValidating();
    builder = new SAXBuilder(factory);
    builder.setFeature(FEATURE_NAMESPACES, true);
    builder.setFeature(FEATURE_SCHEMA_SUPPORT, validate);
    builder.setFeature(FEATURE_FULL_SCHEMA_SUPPORT, false);
    builder.setErrorHandler(new MCRXMLParserErrorHandler(silent));
    builder.setEntityResolver(new XercesBugFixResolver(MCREntityResolver.instance()));
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:10,代码来源:MCRXMLParserImpl.java

示例3: loadFile

import org.jdom2.input.sax.XMLReaderJDOMFactory; //导入依赖的package包/类
public void loadFile(String pathname, String filename) {

        try {
            // Build & creat the document with SAX, use XML schema validation
            URL path = ClassLoader.getSystemResource("ANNeML.xsd");
            if(path.getFile()==null) {
                jLabel2.setForeground(Color.RED);
                jLabel2.setText("error loading XML schema");  
            }
            else{
                //File argylexsd = new File(path.toURI());
                //XMLReaderJDOMFactory schemafac = new XMLReaderXSDFactory(argylexsd);
                XMLReaderJDOMFactory schemafac = new XMLReaderXSDFactory("ANNeML.xsd"); //***for .jar deployment
                SAXBuilder builder = new SAXBuilder(schemafac);
                AL_gui.NNetMap = builder.build(pathname);
                java.util.List subnets = XPath.newInstance("//SUBNET").selectNodes(AL_gui.NNetMap);
                java.util.List layers = XPath.newInstance("//LAYER").selectNodes(AL_gui.NNetMap);
                java.util.List inputNeurodes = XPath.newInstance("//NEURODE[SYNAPSE/@ORG_NEURODE='INPUT']").selectNodes(AL_gui.NNetMap);
                java.util.List hiddenNeurodes = XPath.newInstance("//LAYER[@LAYER_NAME='HIDDEN']/NEURODE").selectNodes(AL_gui.NNetMap);
                java.util.List outputNeurodes = XPath.newInstance("//LAYER[@LAYER_NAME='OUTPUT']/NEURODE").selectNodes(AL_gui.NNetMap);                
                jLabel2.setForeground(Color.GREEN);
                jLabel2.setText("Valid ANNeML file.");
            } 
            } catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(AL_gui.this, "There was an error parsing the file.\n" + e.toString(), "Warning", JOptionPane.WARNING_MESSAGE);
        }
         
                    
    }
 
开发者ID:adam-nnl,项目名称:ANNeML-Lab,代码行数:31,代码来源:AL_gui.java

示例4: readPhyloXML

import org.jdom2.input.sax.XMLReaderJDOMFactory; //导入依赖的package包/类
/**
  * Parses the PhyloXML file and fill the structure of MetaML.
  * 
  * @param f PhyloXML file.
  * @return Returns an PhyloXML object.
  */
 private PhyloXML readPhyloXML(File f) throws JDOMException {
 	try {
         // TODO A round of non-validating parsing to get the file name of the referenced XSD
         
         // Set the implementation of SAXParserFactory to the one bundled wit the JRE
         System.setProperty("javax.xml.parsers.SAXParserFactory", "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
         
         // Read bundled XML schema            	
     	URL xsdUrl = getClass().getResource("/schemas/phyloxml-1.10.xsd");
     	XMLReaderJDOMFactory factory = new XMLReaderXSDFactory(xsdUrl);
          
         // This builder validates against the provided XSD
         SAXBuilder sb = new SAXBuilder(factory);
         Document doc = sb.build(f);
 		
Element rootElement = doc.getRootElement();
Namespace phyloXMLNamespace = rootElement.getNamespace();

/*
          * Parse <phyloxml>
          */
Namespace defaultNamespace = Namespace.getNamespace("phyloxml", phyloXMLNamespace.getURI());
XPathExpression<Element> phylogenyExpression = xpfac.compile("phyloxml:"+Constants.PHYLOXML_PHYLOGENY, Filters.element(), null, defaultNamespace);

for (Element phylogenyElement : phylogenyExpression.evaluate(rootElement)) {									
             Phylogeny phylogeny = new Phylogeny(this);
             
             readSubClades(defaultNamespace, phylogeny, phylogenyElement, null);
		
	/*
	 * This is a pretty dirty hack. We just hijack the
	 * phylogenyObject2 field, knowing that readSubClades will
	 * add the Clades to this Phylogeny. After one phylogeny has
	 * been processed we add phylogenyObject2 to the list of
	 * phylogenies and start over again.
	 * 
	 * THIS HACK WILL NOT BE THREADSAFE!!
	 */
	phylogenies.add(phylogeny);
}

/*
 * Parse project name
 */
Namespace metaXMLNamespace = Namespace.getNamespace("metaxml", "http://metaXML.fz-juelich.de");
XPathExpression<Element> projectNameExpression = xpfac.compile("metaxml:"+Constants.PHYLOXML_PROJECTNAME, Filters.element(), null, metaXMLNamespace);			
for (Element projectNameElement : projectNameExpression.evaluate(rootElement)) {
	this.projectName = projectNameElement.getValue();
}
     } catch (IOException ex) {
     	/* TODO Handle exceptions properly */
     	logger.error("Loading from file failed", ex);
     }
     
     return new PhyloXML(phylogenies);
 }
 
开发者ID:modsim,项目名称:vizardous,代码行数:63,代码来源:Forest.java

示例5: SAXBuilder

import org.jdom2.input.sax.XMLReaderJDOMFactory; //导入依赖的package包/类
public SAXBuilder(final XMLReaderJDOMFactory factory) {
    super(factory);
}
 
开发者ID:rometools,项目名称:rome,代码行数:4,代码来源:SAXBuilder.java


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