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


Java XPath类代码示例

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


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

示例1: isExcludedCommit

import org.jdom2.xpath.XPath; //导入依赖的package包/类
private boolean isExcludedCommit(Element logEntry) throws JDOMException {
    boolean isExclude = false;
    String file = "none";
    List nodes = XPath.selectNodes(logEntry, "paths/path");
    for (Iterator j = nodes.iterator(); j.hasNext();) {
        Element element = (Element) j.next();
        file = element.getValue();

        for (String exclusion : getExclusions()) {
            if (file.matches(exclusion)) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:anwfr,项目名称:SvnStat,代码行数:17,代码来源:SvnStat.java

示例2: selectNodes

import org.jdom2.xpath.XPath; //导入依赖的package包/类
private static List<Object> selectNodes(Document target, Element patch) throws JDOMException {

        boolean isMultiSelect = false;

        String selector = patch.getAttributeValue("sel");
        if (selector == null) {
            selector = patch.getAttributeValue("msel");
            isMultiSelect = true;
        }

        XPath xpath = XPath.newInstance(selector);
        bindNamespacePrefixes(xpath, patch);
        List content = xpath.selectNodes(target);

        if (content.isEmpty()) {
            throw new PatchException(ErrorCondition.UNLOCATED_NODE,
                    "no matches for selector \"" + selector + "\"");
        }
        if (!isMultiSelect && content.size() > 1) {
            throw new PatchException(ErrorCondition.UNLOCATED_NODE,
                    "more that one match for selector \"" + selector + "\" -- if you want to select multiple nodes, use the 'msel' attribute instead of 'sel'.");
        }
        return content;
    }
 
开发者ID:dnault,项目名称:xml-patch,代码行数:25,代码来源:Patcher.java

示例3: getXMLObjects

import org.jdom2.xpath.XPath; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static List getXMLObjects(Document doc, String xpath)
{
	List objects = new ArrayList();
	try
	{
		XPath xp = XPath.newInstance(xpath);
		objects = xp.selectNodes(doc);
	}
	catch (Exception e)
	{
		logger.error("cannot process xpath: " + xpath + " on document: "
				+ Utils.element2String(doc == null ? null : doc.getRootElement(), true));
	}
	return objects;
}
 
开发者ID:yawlfoundation,项目名称:yawl,代码行数:17,代码来源:XMLUtils.java

示例4: readXML

import org.jdom2.xpath.XPath; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
public List<String> readXML(String cityName) {
	List<String> results  = new ArrayList<String>();
	Document doc;
	try {
		SAXBuilder builder = new SAXBuilder();
		doc = (Document) builder.build(xmlFile);

		List<Element> nodes;
		nodes = (List<Element>) XPath.selectNodes(doc, "/costcalculator/city");
			
		for (Element element : nodes) {
			if (cityName.equals(element.getAttributeValue("name"))) {
				results.add(element.getAttributeValue("name"));
				results.add(element.getChildText(ELEMENT_DISTANCE));
				results.add(element.getChildText(ELEMENT_DURATION));
				results.add(element.getChildText(ELEMENT_TICKET));
				results.add(element.getChildText(ELEMENT_DTICKET));
				results.add(element.getChildText(ELEMENT_HOTEL));
				results.add(element.getChildText(ELEMENT_PUBLICTRANSPORT));
			} 
		}
	} catch (JDOMException | IOException e) {
		e.printStackTrace();
	}
	return results;				
}
 
开发者ID:Linuxmaker,项目名称:FeeCalculator,代码行数:28,代码来源:XMLCreator.java

示例5: loadFile

import org.jdom2.xpath.XPath; //导入依赖的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


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