• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DefaultXPath类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getAttributeValue

import org.dom4j.xpath.DefaultXPath; //导入依赖的package包/类
/**
 * Extracts the value of the supplied attribute
 * 
 * @param element
 *            element with attribute in question
 * @param attributeName
 *            name of the attribute in question
 * @param failIfNotFound
 *            determines if exception should be thrown if attribute is not
 *            found
 * @return value of the attribute in question, null if not found and
 *         failIfNotFound is set to false
 * @throws GenericArtifactParsingException
 *             exception thrown is attribute is missing and failIfNotFound
 *             is set to true
 */
public static String getAttributeValue(Element element,
        String attributeName, boolean failIfNotFound)
        throws GenericArtifactParsingException {
    XPath xpath = new DefaultXPath("@" + attributeName);
    xpath.setNamespaceURIs(ccfNamespaceMap);
    Node attributeNode = xpath.selectSingleNode(element);
    if (attributeNode == null) {
        if (failIfNotFound) {
            throw new GenericArtifactParsingException("Missing attribute: "
                    + attributeName + " in element " + element.getName());
        } else {
            return null;
        }
    } else {
        return attributeNode.getText();
    }
}
 
开发者ID:jonico,项目名称:core,代码行数:34,代码来源:XPathUtils.java


示例2: parse

import org.dom4j.xpath.DefaultXPath; //导入依赖的package包/类
/**
	 * 解析测试套件配置文件
	 * @param suiteInputStream 配置文件输入流
	 * @return 测试套件对象
	 * @throws DocumentException
	 */
	public Suite parse(InputStream suiteInputStream) throws DocumentException
	{
		SAXReader reader = new SAXReader();
		reader.setEncoding("utf-8");
		
		Document document = reader.read(suiteInputStream);
		
		simpleNamespaceContext.addNamespace("ns", NS_URI);
		
		XPath xpath = new DefaultXPath("/ns:suite");
		xpath.setNamespaceContext(simpleNamespaceContext);
		Element suiteEle = (Element) xpath.selectSingleNode(document);
		if (suiteEle == null)
		{
			suiteEle = document.getRootElement();
//			throw new RuntimeException("Can not found suite config.");
		}
		
		Suite suite = new Suite();
		String xmlConfPath = suiteEle.attributeValue("pageConfig");
		String pagePackage = suiteEle.attributeValue("pagePackage", "");
		String rows = suiteEle.attributeValue("rows", "1");
		String lackLines = suiteEle.attributeValue("lackLines", "nearby");
		String errorLines = suiteEle.attributeValue("errorLines", "stop");
		String afterSleep = suiteEle.attributeValue("afterSleep", "0");
		
		suite.setXmlConfPath(xmlConfPath);
		suite.setPagePackage(pagePackage);
		suite.setRows(rows);
		suite.setLackLines(lackLines);
		suite.setErrorLines(errorLines);
		suite.setAfterSleep(Long.parseLong(afterSleep));
		
		pagesParse(document, suite);
		
		return suite;
	}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.suite.runner,代码行数:44,代码来源:XmlSuiteParser.java


示例3: getAttributeValue

import org.dom4j.xpath.DefaultXPath; //导入依赖的package包/类
/**
 * Extracts the value of the supplied attribute
 * 
 * @param element
 *            element with attribute in question
 * @param attributeName
 *            name of the attribute in question
 * @return value of the attribute in question
 * @throws GenericArtifactParsingException
 *             exception s thrown is attribute is missing
 */
private static String getAttributeValue(Element element,
        String attributeName) throws GenericArtifactParsingException {
    // TODO Cash constructed XPath objects?
    // XPath xpath = new DefaultXPath("@" + CCF_NAMESPACE_PREFIX + ":" +
    // attributeName);
    XPath xpath = new DefaultXPath("@" + attributeName);
    xpath.setNamespaceURIs(ccfNamespaceMap);
    Node attributeNode = xpath.selectSingleNode(element);
    if (attributeNode == null)
        throw new GenericArtifactParsingException("Missing attribute: "
                + attributeName + " in element " + element.getName());
    else
        return attributeNode.getText();
}
 
开发者ID:jonico,项目名称:core,代码行数:26,代码来源:GenericArtifactHelper.java


示例4: getAttributeValueWithoutException

import org.dom4j.xpath.DefaultXPath; //导入依赖的package包/类
/**
 * Extracts the value of the supplied attribute without throwing an
 * exception if missing
 * 
 * @param element
 *            element with attribute in question
 * @param attributeName
 *            name of the attribute in question
 * @return value of the attribute in question, null if attribute is missing
 * 
 */
private static String getAttributeValueWithoutException(Element element,
        String attributeName) {
    // TODO Cash constructed XPath objects?
    // XPath xpath = new DefaultXPath("@" + CCF_NAMESPACE_PREFIX + ":" +
    // attributeName);
    XPath xpath = new DefaultXPath("@" + attributeName);
    xpath.setNamespaceURIs(ccfNamespaceMap);
    Node attributeNode = xpath.selectSingleNode(element);
    if (attributeNode == null)
        return null;
    else
        return attributeNode.getText();
}
 
开发者ID:jonico,项目名称:core,代码行数:25,代码来源:GenericArtifactHelper.java


示例5: extractBoxConstraint

import org.dom4j.xpath.DefaultXPath; //导入依赖的package包/类
private int[] extractBoxConstraint(Element root) {
  int[] result = new int[4];
  String nodeName = currentToken.getNode().getName();
  XPath xPath = new DefaultXPath("//node[@name='" + nodeName + "']");
  Element node = (Element) xPath.selectSingleNode(root);
  result[0] = Integer.valueOf(node.attribute("x").getValue()).intValue();
  result[1] = Integer.valueOf(node.attribute("y").getValue()).intValue();
  result[2] = Integer.valueOf(node.attribute("width").getValue()).intValue();
  result[3] = Integer.valueOf(node.attribute("height").getValue()).intValue();
  return result;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:12,代码来源:JBPMProcessImageTag.java


示例6: render

import org.dom4j.xpath.DefaultXPath; //导入依赖的package包/类
public void render(final InputStream in, final OutputStream out, final Map<String , String> config)
    throws Exception {
	SAXReader reader = new SAXReader();
    Document document = reader.read(in);
    
    XPath xpath = new DefaultXPath("/l:LexML/l:Metadado/l:Identificacao");
    Map<String,String> ns = new HashMap<String,String>();
    ns.put("l","http://www.lexml.gov.br/1.0");
    xpath.setNamespaceURIs(ns);        
    Node n = xpath.selectSingleNode(document);
    //System.out.println("n:" + n);
    //System.out.println("attributes: " + ((Element) n).attributes());
    String urn = ((Element)n).attributeValue("URN");
    //System.out.println("urn:" + urn);
    String[] urnComps = urn.split(":");
    String autoridade = urnComps[3];
    String tipoNorma = urnComps[4];
                	    	    	
    RendererPDFContext ctx = new RendererPDFContext(autoridade,tipoNorma);
    ctx.addConfig(config);
    
    Element root = document.getRootElement();

    ctx.setOutputStream(out);

    new PDFBuilder(ctx, root).build();

}
 
开发者ID:lexml,项目名称:lexml-renderer-pdf,代码行数:29,代码来源:RendererPDF.java


示例7: getUrl

import org.dom4j.xpath.DefaultXPath; //导入依赖的package包/类
/**
 * @param browser
 * @param ver
 * @param os 操作系统名称
 * @param arch CUP架构(32或者64位)
 * @return 找不到返回null
 */
public String getUrl(String browser, String ver, String os, String arch)
{
	String xpathStr = String.format("//drivers/driver[@type='%s']/supports/browser[@version='%s']",
			browser, ver);
	XPath xpath = new DefaultXPath(xpathStr);

	String path = null;
	@SuppressWarnings("unchecked")
       List<Element> nodes = xpath.selectNodes(document);
	String driverVer = null;
	for(Element ele : nodes)
	{
		@SuppressWarnings("unchecked")
           List<Element> itemList = ele.getParent().getParent().element("items").elements("item");
		for(Element item : itemList)
		{
			if(os.equals(item.attributeValue("os")) && arch.equals(item.attributeValue("arch")))
			{
				path = item.attributeValue("path");
				break;
			}
		}

           driverVer = ele.getParent().getParent().attributeValue("version");
		break;
	}
	
	if(driverVer != null && !driverVer.trim().equals(""))
	{
		String base = document.getRootElement().attributeValue("base");
		String subPath = "";

           for(Browser bro : browserList())
           {
               if(browser.equals(bro.getName()))
               {
                   subPath = bro.getPath();
                   break;
               }
           }

           if("win32".equals(os))
           {
               arch = "";
           }

		path = base + subPath + "/" + driverVer + "/" + browser + "driver_" + os + arch + ".zip";
	}
	else
	{
	    path = null;
	}
	
	return path;
}
 
开发者ID:LinuxSuRen,项目名称:autotest.webdriver.downloader,代码行数:63,代码来源:DriverMapping.java


示例8: supportBrowser

import org.dom4j.xpath.DefaultXPath; //导入依赖的package包/类
/**
 * @return 支持的浏览器以及版本列表
 */
public Map<String, Set<String>> supportBrowser()
{
	Map<String, Set<String>> browserMap = new HashMap<String, Set<String>>();

	String xpathStr = String.format("//drivers/driver");
	XPath xpath = new DefaultXPath(xpathStr);

	@SuppressWarnings("unchecked")
       List<Element> nodes = xpath.selectNodes(document);
	for(Element ele : nodes)
	{
		String type = ele.attributeValue("type");
		
		Set<String> verList = new TreeSet<String>(new Comparator<String>(){

			@Override
			public int compare(String o1, String o2)
			{
				return o2.compareTo(o1);
			}
		});
		@SuppressWarnings("unchecked")
           List<Element> verEleList = ele.element("supports").elements("browser");
		for(Element verEle : verEleList)
		{
			String ver = verEle.attributeValue("version");
			
			verList.add(ver);
		}
		
		Set<String> oldVerList = browserMap.get(type);
		if(oldVerList == null)
		{
			browserMap.put(type, verList);
		}
		else
		{
			oldVerList.addAll(verList);
		}
	}
	
	return browserMap;
}
 
开发者ID:LinuxSuRen,项目名称:autotest.webdriver.downloader,代码行数:47,代码来源:DriverMapping.java


示例9: initialValue

import org.dom4j.xpath.DefaultXPath; //导入依赖的package包/类
@Override
protected XPath initialValue() {
    return new DefaultXPath(this.xpath);
}
 
开发者ID:drewwills,项目名称:cernunnos,代码行数:5,代码来源:SimpleReagent.java


示例10: initialValue

import org.dom4j.xpath.DefaultXPath; //导入依赖的package包/类
@Override
protected XPath initialValue() {
    return new DefaultXPath("descendant-or-self::text() | descendant-or-self::*/@*");
}
 
开发者ID:drewwills,项目名称:cernunnos,代码行数:5,代码来源:NodeProcessor.java


示例11: createObject

import org.dom4j.xpath.DefaultXPath; //导入依赖的package包/类
public XPath createObject(String key) {
    return new DefaultXPath(key);
}
 
开发者ID:drewwills,项目名称:cernunnos,代码行数:4,代码来源:XPathCacheFactory.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Action类代码示例发布时间:2022-05-22
下一篇:
Java Map类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap