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

Java InvalidXPathException类代码示例

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

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



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

示例1: findWithXPath

import org.dom4j.InvalidXPathException; //导入依赖的package包/类
/**
 * Searches XML element with XPath and returns list of nodes found
 *
 * @param xml        input stream with the XML in which the element is being searched
 * @param expression XPath expression used in search
 * @return {@link NodeList} of elements matching the XPath in the XML
 * @throws XPathExpressionException     if there is an error in the XPath expression
 * @throws IOException                  if the XML at the specified path is missing
 * @throws SAXException                 if the XML cannot be parsed
 * @throws ParserConfigurationException
 */
public static NodeList findWithXPath(InputStream xml, String expression)
        throws IOException, SAXException, ParserConfigurationException {
    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder dBuilder;

    dBuilder = dbFactory.newDocumentBuilder();

    Document doc = dBuilder.parse(xml);
    doc.getDocumentElement().normalize();

    XPath xPath = XPathFactory.newInstance().newXPath();

    try {
        return (NodeList) xPath.compile(expression).evaluate(doc, XPathConstants.NODESET);
    } catch (XPathExpressionException e) {
        throw new InvalidXPathException(expression, e);
    }
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:30,代码来源:XPathUtils.java


示例2: getAttribute

import org.dom4j.InvalidXPathException; //导入依赖的package包/类
public IAttributeValue getAttribute(IInstance row) {
	if (row instanceof XMLRow) {
		Node node = ((XMLRow)row).getNode();
		Node selectedNode = null;
		try {
			selectedNode = node.selectSingleNode(getXpath());
		} catch (InvalidXPathException e) {
			throw new IllegalArgumentException("Invalid XPath '" + getXpath() + "' in attribute '" + getName() + "'", e);
		}
		if (selectedNode == null) {
			return(new EmptyAttributeValue(this));
			//throw new IllegalArgumentException("Column '" + getXPath() + "' not found in row '" + node.getPath() +"'");
		}
		TextAttributeValue col = new TextAttributeValue(this, selectedNode.getText());
		return(col);
	}
	return(null);
}
 
开发者ID:luox12,项目名称:onecmdb,代码行数:19,代码来源:XPathAttributeSelector.java


示例3: validateXPath

import org.dom4j.InvalidXPathException; //导入依赖的package包/类
/**
 * Validates an XPath expression.
 *
 * @return {@link XPathActivityConfigurationBean#XPATH_VALID XPATH_VALID} -
 *         if the expression is valid;<br/>
 *         {@link XPathActivityConfigurationBean#XPATH_EMPTY XPATH_EMPTY} -
 *         if expression is empty;<br/>
 *         {@link XPathActivityConfigurationBean#XPATH_INVALID
 *         XPATH_INVALID} - if the expression is invalid / ill-formed.<br/>
 */
public static int validateXPath(String xpathExpressionToValidate) {
	// no XPath expression
	if (xpathExpressionToValidate == null
			|| xpathExpressionToValidate.trim().isEmpty()) {
		return XPATH_EMPTY;
	}

	try {
		// try to parse the XPath expression...
		createXPath(xpathExpressionToValidate.trim());
		// ...success
		return XPATH_VALID;
	} catch (InvalidXPathException e) {
		// ...failed to parse the XPath expression: notify of the error
		return XPATH_INVALID;
	}
}
 
开发者ID:apache,项目名称:incubator-taverna-common-activities,代码行数:28,代码来源:XPathActivityConfigurationBean.java


示例4: validateXPath

import org.dom4j.InvalidXPathException; //导入依赖的package包/类
/**
 * Validates an XPath expression.
 * 
 * @return {@link XPathActivityConfigurationBean#XPATH_VALID XPATH_VALID} -
 *         if the expression is valid;<br/>
 *         {@link XPathActivityConfigurationBean#XPATH_EMPTY XPATH_EMPTY} -
 *         if expression is empty;<br/>
 *         {@link XPathActivityConfigurationBean#XPATH_INVALID
 *         XPATH_INVALID} - if the expression is invalid / ill-formed.<br/>
 */
public static int validateXPath(String xpathExpressionToValidate) {
	// no XPath expression
	if (xpathExpressionToValidate == null
			|| xpathExpressionToValidate.trim().isEmpty()) {
		return XPATH_EMPTY;
	}

	try {
		// try to parse the XPath expression...
		createXPath(xpathExpressionToValidate.trim());
		// ...success
		return XPATH_VALID;
	} catch (InvalidXPathException e) {
		// ...failed to parse the XPath expression: notify of the error
		return XPATH_INVALID;
	}
}
 
开发者ID:apache,项目名称:incubator-taverna-common-activities,代码行数:28,代码来源:XPathUtils.java


示例5: generateArclibInvalidXPath

import org.dom4j.InvalidXPathException; //导入依赖的package包/类
/**
 * Tests that the {@link InvalidXPathException} exception is thrown when the SIP profile contains an invalid xpath
 */
@Test
public void generateArclibInvalidXPath() throws IOException {
    SipProfile profile = new SipProfile();
    String sipProfileXml = Resources.toString(this.getClass().getResource(
            "/arclibxmlgeneration/sipProfiles/sipProfileInvalidXPath.xml"), StandardCharsets.UTF_8);
    profile.setXml(sipProfileXml);

    store.save(profile);

    assertThrown(() -> generator.generateArclibXml(SIP_PATH, profile.getId())).isInstanceOf(InvalidXPathException.class);
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:15,代码来源:ArclibXmlGeneratorTest.java


示例6: getXPathValidationErrorMessage

import org.dom4j.InvalidXPathException; //导入依赖的package包/类
private String getXPathValidationErrorMessage() {
	try {
		// try to parse the XPath expression...
		DocumentHelper.createXPath(tfXPathExpression.getText().trim());
		// ...success
		return ("");
	} catch (InvalidXPathException e) {
		// ...failed to parse the XPath expression: notify of the error
		return (e.getMessage());
	}
}
 
开发者ID:apache,项目名称:incubator-taverna-workbench-common-activities,代码行数:12,代码来源:XPathActivityConfigurationPanel.java


示例7: selectIterator

import org.dom4j.InvalidXPathException; //导入依赖的package包/类
/**
 * Apply the given XPath expression to the given node.
 *
 * @param   prefixes  mapping of prefixes to namespace URIs for prefixes used in expr
 * @return            Iterator over org.w3c.dom.Node objects, never null
 */
public static Iterator selectIterator(org.dom4j.Node node, String expr, Map prefixes) {
    try {
        org.dom4j.XPath path = node.createXPath(expr);
        path.setNamespaceContext(new SimpleNamespaceContext(prefixes));

        return new IteratorFilter(path.selectNodes(node).iterator(), org.dom4j.Namespace.class);
    } catch (InvalidXPathException e) {
        throw new OXFException(e);
    }
}
 
开发者ID:evlist,项目名称:orbeon-forms,代码行数:17,代码来源:XPathUtils.java


示例8: selectSingleNode

import org.dom4j.InvalidXPathException; //导入依赖的package包/类
/**
 * Apply the given XPath expression to the given node.
 *
 * @param prefixes  mapping of prefixes to namespace URIs for prefixes used in expr
 */
public static org.dom4j.Node selectSingleNode(org.dom4j.Node node, String expr, Map prefixes) {
    try {
        org.dom4j.XPath path = node.createXPath(expr);
        path.setNamespaceContext(new SimpleNamespaceContext(prefixes));
        return path.selectSingleNode(node);
    } catch (InvalidXPathException e) {
        throw new OXFException(e);
    }
}
 
开发者ID:evlist,项目名称:orbeon-forms,代码行数:15,代码来源:XPathUtils.java


示例9: selectObjectValue

import org.dom4j.InvalidXPathException; //导入依赖的package包/类
public static Object selectObjectValue(org.dom4j.Node node, String expr, Map prefixes, VariableContext variableContext, FunctionContext functionContext) {
    try {
        org.dom4j.XPath path = node.createXPath(expr);
        hookupPath(path, prefixes, variableContext, functionContext);
        return path.evaluate(node);
    } catch (InvalidXPathException e) {
        throw new OXFException(e);
    }
}
 
开发者ID:evlist,项目名称:orbeon-forms,代码行数:10,代码来源:XPathUtils.java


示例10: selectStringValue

import org.dom4j.InvalidXPathException; //导入依赖的package包/类
public static String selectStringValue(org.dom4j.Node node, String expr, Map prefixes, VariableContext variableContext, FunctionContext functionContext) {
    try {
        org.dom4j.XPath path = node.createXPath(expr);
        hookupPath(path, prefixes, variableContext, functionContext);
        Object result = path.evaluate(node);
        // Test for empty node-set
        if (result == null || (result instanceof List && ((List) result).size() == 0))
            return null;
        // Otherwise return a String
        return (result instanceof String) ? (String) result : node.createXPath(".").valueOf(result);
    } catch (InvalidXPathException e) {
        throw new OXFException(e);
    }
}
 
开发者ID:evlist,项目名称:orbeon-forms,代码行数:15,代码来源:XPathUtils.java


示例11: selectBooleanValue

import org.dom4j.InvalidXPathException; //导入依赖的package包/类
public static Boolean selectBooleanValue(org.dom4j.Node node, String expr, Map prefixes, VariableContext variableContext, FunctionContext functionContext, boolean allowNull) {
    try {
        org.dom4j.XPath path = node.createXPath(expr);
        hookupPath(path, prefixes, variableContext, functionContext);
        Object result = path.evaluate(node);
        if (allowNull && (result == null || (result instanceof List && ((List) result).size() == 0)))
            return null;
        else
            return new Boolean(node.createXPath("boolean(.)").valueOf(result));
    } catch (InvalidXPathException e) {
        throw new OXFException(e);
    }
}
 
开发者ID:evlist,项目名称:orbeon-forms,代码行数:14,代码来源:XPathUtils.java


示例12: findWithXPathInvalidXPathTest

import org.dom4j.InvalidXPathException; //导入依赖的package包/类
@Test
public void findWithXPathInvalidXPathTest() throws SAXException, ParserConfigurationException, XPathExpressionException, IOException {
    assertThrown(() -> XPathUtils.findWithXPath(new FileInputStream(SIP_PATH + "/info.xml"),
            "///")).isInstanceOf(InvalidXPathException.class);
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:6,代码来源:XPathUtilsTest.java


示例13: createXPath

import org.dom4j.InvalidXPathException; //导入依赖的package包/类
public XPath createXPath(String xpath) throws InvalidXPathException {
	return element.createXPath( xpath );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:ElementWrapper.java


示例14: createXPath

import org.dom4j.InvalidXPathException; //导入依赖的package包/类
public XPath createXPath(String xpathExpression)
		throws InvalidXPathException {
	return getWrapped().createXPath(xpathExpression);
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:5,代码来源:VersionedDocument.java


示例15: createXPath

import org.dom4j.InvalidXPathException; //导入依赖的package包/类
public XPath createXPath(String xpath) throws InvalidXPathException {
	return target().createXPath( xpath );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:4,代码来源:Dom4jProxy.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java DocumentationTool类代码示例发布时间:2022-05-22
下一篇:
Java InputRepresentation类代码示例发布时间: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