List of usage examples for javax.xml.xpath XPathConstants BOOLEAN
QName BOOLEAN
To view the source code for javax.xml.xpath XPathConstants BOOLEAN.
Click Source Link
The XPath 1.0 boolean data type.
Maps to Java Boolean .
From source file:org.kuali.rice.kew.xml.DocumentTypeXmlParser.java
private RouteNode makeRouteNodePrototype(String nodeTypeName, String nodeName, String nodeExpression, Node routeNodesNode, DocumentType documentType, RoutePathContext context) throws XPathExpressionException, GroupNotFoundException, XmlException { NodeList nodeList;// ww w.ja va 2s.c om try { nodeList = (NodeList) getXPath().evaluate(nodeExpression, routeNodesNode, XPathConstants.NODESET); } catch (XPathExpressionException xpee) { LOG.error("Error evaluating node expression: '" + nodeExpression + "'"); throw xpee; } if (nodeList.getLength() > 1) { throw new XmlException("More than one node under routeNodes has the same name of '" + nodeName + "'"); } if (nodeList.getLength() == 0) { throw new XmlException("No node definition was found with the name '" + nodeName + "'"); } Node node = nodeList.item(0); RouteNode routeNode = new RouteNode(); // set fields that all route nodes of all types should have defined routeNode.setDocumentType(documentType); routeNode.setRouteNodeName((String) getXPath().evaluate("./@name", node, XPathConstants.STRING)); routeNode.setContentFragment(XmlJotter.jotNode(node)); if (XmlHelper.pathExists(xpath, "./activationType", node)) { routeNode.setActivationType(ActivationTypeEnum .parse((String) getXPath().evaluate("./activationType", node, XPathConstants.STRING)) .getCode()); } else { routeNode.setActivationType(DEFAULT_ACTIVATION_TYPE); } Group exceptionWorkgroup = defaultExceptionWorkgroup; String exceptionWg = null; String exceptionWorkgroupName = null; String exceptionWorkgroupNamespace = null; if (XmlHelper.pathExists(xpath, "./" + EXCEPTION_GROUP_NAME, node)) { exceptionWorkgroupName = Utilities .substituteConfigParameters( (String) getXPath().evaluate("./" + EXCEPTION_GROUP_NAME, node, XPathConstants.STRING)) .trim(); exceptionWorkgroupNamespace = Utilities .substituteConfigParameters((String) getXPath() .evaluate("./" + EXCEPTION_GROUP_NAME + "/@" + NAMESPACE, node, XPathConstants.STRING)) .trim(); } if (org.apache.commons.lang.StringUtils.isEmpty(exceptionWorkgroupName) && XmlHelper.pathExists(xpath, "./" + EXCEPTION_WORKGROUP_NAME, node)) { LOG.warn((new StringBuilder(160)).append("Document Type XML is using deprecated element '") .append(EXCEPTION_WORKGROUP_NAME).append("', please use '").append(EXCEPTION_GROUP_NAME) .append("' instead.").toString()); // for backward compatibility we also need to be able to support exceptionWorkgroupName exceptionWg = Utilities.substituteConfigParameters( (String) getXPath().evaluate("./" + EXCEPTION_WORKGROUP_NAME, node, XPathConstants.STRING)); exceptionWorkgroupName = Utilities.parseGroupName(exceptionWg); exceptionWorkgroupNamespace = Utilities.parseGroupNamespaceCode(exceptionWg); } if (org.apache.commons.lang.StringUtils.isEmpty(exceptionWorkgroupName) && XmlHelper.pathExists(xpath, "./" + EXCEPTION_WORKGROUP, node)) { LOG.warn((new StringBuilder(160)).append("Document Type XML is using deprecated element '") .append(EXCEPTION_WORKGROUP).append("', please use '").append(EXCEPTION_GROUP_NAME) .append("' instead.").toString()); // for backward compatibility we also need to be able to support exceptionWorkgroup exceptionWg = Utilities.substituteConfigParameters( (String) getXPath().evaluate("./" + EXCEPTION_WORKGROUP, node, XPathConstants.STRING)); exceptionWorkgroupName = Utilities.parseGroupName(exceptionWg); exceptionWorkgroupNamespace = Utilities.parseGroupNamespaceCode(exceptionWg); } if (org.apache.commons.lang.StringUtils.isEmpty(exceptionWorkgroupName)) { if (routeNode.getDocumentType().getDefaultExceptionWorkgroup() != null) { exceptionWorkgroupName = routeNode.getDocumentType().getDefaultExceptionWorkgroup().getName(); exceptionWorkgroupNamespace = routeNode.getDocumentType().getDefaultExceptionWorkgroup() .getNamespaceCode(); } } if (org.apache.commons.lang.StringUtils.isNotEmpty(exceptionWorkgroupName) && org.apache.commons.lang.StringUtils.isNotEmpty(exceptionWorkgroupNamespace)) { exceptionWorkgroup = getGroupService().getGroupByNamespaceCodeAndName(exceptionWorkgroupNamespace, exceptionWorkgroupName); if (exceptionWorkgroup == null) { throw new GroupNotFoundException("Could not locate exception workgroup with namespace '" + exceptionWorkgroupNamespace + "' and name '" + exceptionWorkgroupName + "'"); } } else { if (StringUtils.isEmpty(exceptionWorkgroupName) ^ StringUtils.isEmpty(exceptionWorkgroupNamespace)) { throw new GroupNotFoundException("Could not locate exception workgroup with namespace '" + exceptionWorkgroupNamespace + "' and name '" + exceptionWorkgroupName + "'"); } } if (exceptionWorkgroup != null) { routeNode.setExceptionWorkgroupName(exceptionWorkgroup.getName()); routeNode.setExceptionWorkgroupId(exceptionWorkgroup.getId()); } if (((Boolean) getXPath().evaluate("./mandatoryRoute", node, XPathConstants.BOOLEAN)).booleanValue()) { routeNode.setMandatoryRouteInd( Boolean.valueOf((String) getXPath().evaluate("./mandatoryRoute", node, XPathConstants.STRING))); } else { routeNode.setMandatoryRouteInd(Boolean.FALSE); } if (((Boolean) getXPath().evaluate("./finalApproval", node, XPathConstants.BOOLEAN)).booleanValue()) { routeNode.setFinalApprovalInd( Boolean.valueOf((String) getXPath().evaluate("./finalApproval", node, XPathConstants.STRING))); } else { routeNode.setFinalApprovalInd(Boolean.FALSE); } // for every simple child element of the node, store a config parameter of the element name and text content NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node n = children.item(i); if (n instanceof Element) { Element e = (Element) n; String name = e.getNodeName(); String content = getTextContent(e); routeNode.getConfigParams().add(new RouteNodeConfigParam(routeNode, name, content)); } } // make sure a default rule selector is set Map<String, String> cfgMap = Utilities.getKeyValueCollectionAsMap(routeNode.getConfigParams()); if (!cfgMap.containsKey(RouteNode.RULE_SELECTOR_CFG_KEY)) { routeNode.getConfigParams().add(new RouteNodeConfigParam(routeNode, RouteNode.RULE_SELECTOR_CFG_KEY, FlexRM.DEFAULT_RULE_SELECTOR)); } if (((Boolean) getXPath().evaluate("./ruleTemplate", node, XPathConstants.BOOLEAN)).booleanValue()) { String ruleTemplateName = (String) getXPath().evaluate("./ruleTemplate", node, XPathConstants.STRING); RuleTemplateBo ruleTemplate = KEWServiceLocator.getRuleTemplateService() .findByRuleTemplateName(ruleTemplateName); if (ruleTemplate == null) { throw new XmlException("Rule template for node '" + routeNode.getRouteNodeName() + "' not found: " + ruleTemplateName); } routeNode.setRouteMethodName(ruleTemplateName); routeNode.setRouteMethodCode(KewApiConstants.ROUTE_LEVEL_FLEX_RM); } else if (((Boolean) getXPath().evaluate("./routeModule", node, XPathConstants.BOOLEAN)).booleanValue()) { routeNode .setRouteMethodName((String) getXPath().evaluate("./routeModule", node, XPathConstants.STRING)); routeNode.setRouteMethodCode(KewApiConstants.ROUTE_LEVEL_ROUTE_MODULE); } else if (((Boolean) getXPath().evaluate("./peopleFlows", node, XPathConstants.BOOLEAN)).booleanValue()) { routeNode.setRouteMethodCode(KewApiConstants.ROUTE_LEVEL_PEOPLE_FLOW); } else if (((Boolean) getXPath().evaluate("./rulesEngine", node, XPathConstants.BOOLEAN)).booleanValue()) { // validate that the element has at least one of the two required attributes, XML schema does not provide a way for us to // check this so we must do so programatically Element rulesEngineElement = (Element) getXPath().evaluate("./rulesEngine", node, XPathConstants.NODE); String executorName = rulesEngineElement.getAttribute("executorName"); String executorClass = rulesEngineElement.getAttribute("executorClass"); if (StringUtils.isBlank(executorName) && StringUtils.isBlank(executorClass)) { throw new XmlException( "The rulesEngine declaration must have at least one of 'executorName' or 'executorClass' attributes."); } else if (StringUtils.isNotBlank(executorName) && StringUtils.isNotBlank(executorClass)) { throw new XmlException( "Only one of 'executorName' or 'executorClass' may be declared on rulesEngine configuration, but both were declared."); } routeNode.setRouteMethodCode(KewApiConstants.ROUTE_LEVEL_RULES_ENGINE); } String nodeType = null; if (((Boolean) getXPath().evaluate("./type", node, XPathConstants.BOOLEAN)).booleanValue()) { nodeType = (String) getXPath().evaluate("./type", node, XPathConstants.STRING); } else { String localName = (String) getXPath().evaluate("local-name(.)", node, XPathConstants.STRING); if ("start".equalsIgnoreCase(localName)) { nodeType = "org.kuali.rice.kew.engine.node.InitialNode"; } else if ("split".equalsIgnoreCase(localName)) { nodeType = "org.kuali.rice.kew.engine.node.SimpleSplitNode"; } else if ("join".equalsIgnoreCase(localName)) { nodeType = "org.kuali.rice.kew.engine.node.SimpleJoinNode"; } else if ("requests".equalsIgnoreCase(localName)) { nodeType = "org.kuali.rice.kew.engine.node.RequestsNode"; } else if ("process".equalsIgnoreCase(localName)) { nodeType = "org.kuali.rice.kew.engine.node.SimpleSubProcessNode"; } else if (NodeType.ROLE.getName().equalsIgnoreCase(localName)) { nodeType = RoleNode.class.getName(); } } if (org.apache.commons.lang.StringUtils.isEmpty(nodeType)) { throw new XmlException( "Could not determine node type for the node named '" + routeNode.getRouteNodeName() + "'"); } routeNode.setNodeType(nodeType); String localName = (String) getXPath().evaluate("local-name(.)", node, XPathConstants.STRING); if ("split".equalsIgnoreCase(localName)) { context.splitNodeStack.addFirst(routeNode); } else if ("join".equalsIgnoreCase(localName) && context.splitNodeStack.size() != 0) { // join node should have same branch prototype as split node RouteNode splitNode = (RouteNode) context.splitNodeStack.removeFirst(); context.branch = splitNode.getBranch(); } else if (NodeType.ROLE.getName().equalsIgnoreCase(localName)) { routeNode.setRouteMethodName(RoleRouteModule.class.getName()); routeNode.setRouteMethodCode(KewApiConstants.ROUTE_LEVEL_ROUTE_MODULE); } routeNode.setBranch(context.branch); return routeNode; }
From source file:org.kuali.rice.kew.xml.DocumentTypeXmlParser.java
private List getDocumentTypePolicies(NodeList documentTypePolicies, DocumentType documentType) throws XPathExpressionException, XmlException, ParserConfigurationException { List policies = new ArrayList(); Set policyNames = new HashSet(); for (int i = 0; i < documentTypePolicies.getLength(); i++) { DocumentTypePolicy policy = new DocumentTypePolicy(); try {/*from w w w . j a v a 2 s .c om*/ String policyName = (String) getXPath().evaluate("./name", documentTypePolicies.item(i), XPathConstants.STRING); policy.setPolicyName(org.kuali.rice.kew.api.doctype.DocumentTypePolicy.fromCode(policyName) .getCode().toUpperCase()); } catch (XPathExpressionException xpee) { LOG.error("Error obtaining document type policy name", xpee); throw xpee; } try { if (((Boolean) getXPath().evaluate("./value", documentTypePolicies.item(i), XPathConstants.BOOLEAN)) .booleanValue()) { policy.setPolicyValue(Boolean.valueOf((String) getXPath().evaluate("./value", documentTypePolicies.item(i), XPathConstants.STRING))); } else { policy.setPolicyValue(Boolean.FALSE); } } catch (XPathExpressionException xpee) { LOG.error("Error obtaining document type policy value", xpee); throw xpee; } try { String policyStringValue = (String) getXPath().evaluate("./stringValue", documentTypePolicies.item(i), XPathConstants.STRING); if (!StringUtils.isEmpty(policyStringValue)) { policy.setPolicyStringValue(policyStringValue.toUpperCase()); policy.setPolicyValue(Boolean.TRUE); // if DocumentStatusPolicy, check against allowable values if (KewApiConstants.DOCUMENT_STATUS_POLICY .equalsIgnoreCase(org.kuali.rice.kew.api.doctype.DocumentTypePolicy .fromCode(policy.getPolicyName()).getCode())) { boolean found = false; for (int index = 0; index < KewApiConstants.DOCUMENT_STATUS_POLICY_VALUES.length; index++) { if (KewApiConstants.DOCUMENT_STATUS_POLICY_VALUES[index] .equalsIgnoreCase(policyStringValue)) { found = true; break; } } if (!found) { throw new XmlException("Application Document Status string value: " + policyStringValue + " is invalid."); } } } else { //DocumentStatusPolicy requires a <stringValue> tag if (KewApiConstants.DOCUMENT_STATUS_POLICY .equalsIgnoreCase(org.kuali.rice.kew.api.doctype.DocumentTypePolicy .fromCode(policy.getPolicyName()).getCode())) { throw new XmlException("Application Document Status Policy requires a <stringValue>"); } String customConfig = parseDocumentPolicyCustomXMLConfig(documentTypePolicies.item(i)); if (customConfig != null) { policy.setPolicyStringValue(customConfig); } } } catch (XPathExpressionException xpee) { LOG.error("Error obtaining document type policy string value", xpee); throw xpee; } if (!policyNames.add(policy.getPolicyName())) { throw new XmlException( "Policy '" + policy.getPolicyName() + "' has already been defined on this document"); } else { policies.add(policy); } policy.setDocumentType(documentType); } return policies; }
From source file:org.lockss.plugin.clockss.XPathXmlMetadataParser.java
private ArticleMetadata extractDataFromNode(Object startNode, XPathInfo[] xPathList) throws XPathExpressionException { ArticleMetadata returnAM = makeNewArticleMetadata(); NumberFormat format = NumberFormat.getInstance(); for (int i = 0; i < xPathList.length; i++) { log.debug3("evaluate xpath: " + xPathList[i].xKey.toString()); QName definedType = xPathList[i].xVal.getType(); Object itemResult = xPathList[i].xExpr.evaluate(startNode, XPathConstants.NODESET); NodeList resultNodeList = (NodeList) itemResult; log.debug3(resultNodeList.getLength() + " results for this xKey"); for (int p = 0; p < resultNodeList.getLength(); p++) { Node resultNode = resultNodeList.item(p); if (resultNode == null) { continue; }//from w ww . j ava 2s . c om String value = null; if (definedType == XPathConstants.NODE) { // filter node value = xPathList[i].xVal.getValue(resultNode); } else if (definedType == XPathConstants.STRING) { // filter node text content String text = resultNode.getTextContent(); if (!StringUtil.isNullString(text)) { value = xPathList[i].xVal.getValue(text); } } else if (definedType == XPathConstants.BOOLEAN) { // filter boolean value of node text content String text = resultNode.getTextContent(); if (!StringUtil.isNullString(text)) { value = xPathList[i].xVal.getValue(Boolean.parseBoolean(text)); } } else if (definedType == XPathConstants.NUMBER) { // filter number value of node text content try { String text = resultNode.getTextContent(); if (!StringUtil.isNullString(text)) { value = xPathList[i].xVal.getValue(format.parse(text)); } } catch (ParseException ex) { // ignore invalid number log.debug3("ignore invalid number", ex); } } else { log.debug("Unknown nodeValue type: " + definedType.toString()); } if (!StringUtil.isNullString(value)) { log.debug3(" returning (" + xPathList[i].xKey + ", " + value); returnAM.putRaw(xPathList[i].xKey, value); } } } return returnAM; }
From source file:org.mule.module.dxpath.DxTransformer.java
/** * Result type from this transformer./* w w w . ja v a2s . c om*/ * * @param resultType * Result type from this transformer. */ public void setResultType(ResultType resultTypeType) { QName resultType; switch (resultTypeType) { case BOOLEAN: resultType = XPathConstants.BOOLEAN; break; case NODE: resultType = XPathConstants.NODE; break; case NODESET: resultType = XPathConstants.NODESET; break; case NUMBER: resultType = XPathConstants.NUMBER; break; default: resultType = XPathConstants.STRING; break; } this.resultType = resultType; }
From source file:org.opencastproject.comments.CommentParser.java
private static Comment commentFromManifest(Node commentNode, UserDirectoryService userDirectoryService) throws UnsupportedElementException { try {/* ww w. j a va 2s . c o m*/ // id Long id = null; Double idAsDouble = ((Number) xpath.evaluate("@id", commentNode, XPathConstants.NUMBER)).doubleValue(); if (!idAsDouble.isNaN()) id = idAsDouble.longValue(); // text String text = (String) xpath.evaluate("text/text()", commentNode, XPathConstants.STRING); // Author Node authorNode = (Node) xpath.evaluate("author", commentNode, XPathConstants.NODE); User author = userFromManifest(authorNode, userDirectoryService); // ResolvedStatus Boolean resolved = BooleanUtils .toBoolean((Boolean) xpath.evaluate("@resolved", commentNode, XPathConstants.BOOLEAN)); // Reason String reason = (String) xpath.evaluate("reason/text()", commentNode, XPathConstants.STRING); if (StringUtils.isNotBlank(reason)) reason = reason.trim(); // CreationDate String creationDateString = (String) xpath.evaluate("creationDate/text()", commentNode, XPathConstants.STRING); Date creationDate = new Date(DateTimeSupport.fromUTC(creationDateString)); // ModificationDate String modificationDateString = (String) xpath.evaluate("modificationDate/text()", commentNode, XPathConstants.STRING); Date modificationDate = new Date(DateTimeSupport.fromUTC(modificationDateString)); // Create comment Comment comment = Comment.create(Option.option(id), text.trim(), author, reason, resolved, creationDate, modificationDate); // Replies NodeList replyNodes = (NodeList) xpath.evaluate("replies/reply", commentNode, XPathConstants.NODESET); for (int i = 0; i < replyNodes.getLength(); i++) { comment.addReply(replyFromManifest(replyNodes.item(i), userDirectoryService)); } return comment; } catch (XPathExpressionException e) { throw new UnsupportedElementException("Error while reading comment information from manifest", e); } catch (Exception e) { if (e instanceof UnsupportedElementException) throw (UnsupportedElementException) e; throw new UnsupportedElementException( "Error while reading comment creation or modification date information from manifest", e); } }
From source file:org.opens.tanaguru.processor.DOMHandlerImpl.java
@Override @Deprecated// www. j a v a 2 s . co m public TestSolution checkEachWithXpath(String expr) { Collection<TestSolution> resultSet = new ArrayList<TestSolution>(); for (Node node : selectedElementList) { TestSolution tempResult = TestSolution.PASSED; try { XPathExpression xPathExpression = xpath.compile(expr); Boolean check = (Boolean) xPathExpression.evaluate(node, XPathConstants.BOOLEAN); if (!check.booleanValue()) { tempResult = TestSolution.FAILED; // addSourceCodeRemark(result, node, // "wrong value, does not respect xpath expression : " + // expr, node.getNodeValue()); } } catch (XPathExpressionException ex) { LOGGER.error(ex.getMessage() + " occured requesting " + expr + " on " + ssp.getURI()); throw new RuntimeException(ex); } resultSet.add(tempResult); } return RuleHelper.synthesizeTestSolutionCollection(resultSet); }
From source file:org.rhq.modules.plugins.wildfly10.helper.HostConfiguration.java
/** * /* w w w . ja v a2 s . c o m*/ * @return true if $local authentication is the only authentication configured for realm associated to native management interface */ public boolean isNativeLocalOnly() { String nativeRealm = getManagementSecurityRealm(); if (nativeRealm != null) { XPath xpath = this.xpathFactory.newXPath(); try { XPathExpression expr = xpath.compile("count(//management/security-realms/security-realm[@name='" + nativeRealm + "']/authentication[count(local) = count(*)]) = 1"); return (Boolean) expr.evaluate(this.document, XPathConstants.BOOLEAN); } catch (XPathExpressionException e) { log.error("Evaluation of XPath expression failed: " + e.getMessage()); return false; } } return false; }
From source file:org.sakaiproject.james.JamesServlet.java
protected void customizeConfig(String host, String dns1, String dns2, String smtpPort, String logDir, String postmasterAddress) throws JamesConfigurationException { String configPath = m_phoenixHome + "/apps/james/SAR-INF/config.xml"; String environmentPath = m_phoenixHome + "/apps/james/SAR-INF/environment.xml"; XPath xpath = XPathFactory.newInstance().newXPath(); Document doc;//from ww w . j a v a2 s .co m try { // process config.xml first doc = Xml.readDocument(configPath); if (doc == null) { M_log.error("init(): James config file " + configPath + "could not be found."); throw new JamesConfigurationException(); } if (postmasterAddress == null) { postmasterAddress = "postmaster@" + host; } // build a hashmap of node paths and values to set HashMap<String, String> nodeValues = new HashMap<String, String>(); // WARNING!! in XPath, node-set indexes begin with 1, and NOT 0 nodeValues.put("/config/James/servernames/servername[1]", host); nodeValues.put("/config/dnsserver/servers/server[2]", dns1); nodeValues.put("/config/dnsserver/servers/server[3]", dns2); nodeValues.put("/config/James/postmaster", postmasterAddress); nodeValues.put("/config/smtpserver/port", smtpPort); // loop through the hashmap, setting each value, or failing if one can't be found for (String nodePath : nodeValues.keySet()) { if (!(Boolean) xpath.evaluate(nodePath, doc, XPathConstants.BOOLEAN)) { if (nodePath.startsWith("/config/dnsserver/servers/server")) { // add node (only if we're dealing with DNS server entries) Element element = doc.createElement("server"); element.appendChild(doc.createTextNode(nodeValues.get(nodePath))); Node parentNode = (Node) xpath.evaluate("/config/dnsserver/servers", doc, XPathConstants.NODE); parentNode.appendChild(element); } else { // else, throw an exception throw new JamesConfigurationException(); } } else { // change existing node (if value != null else remove it) Node node = (Node) xpath.evaluate(nodePath, doc, XPathConstants.NODE); if (nodeValues.get(nodePath) != null) { node.setTextContent(nodeValues.get(nodePath)); } else { node.getParentNode().removeChild(node); } } } M_log.debug("init(): writing James configuration to " + configPath); Xml.writeDocument(doc, configPath); // now handle environment.xml doc = Xml.readDocument(environmentPath); if (doc == null) { M_log.error("init(): James config file " + environmentPath + "could not be found."); throw new JamesConfigurationException(); } String nodePath = "/server/logs/targets/file/filename"; String nodeValue = logDir + "james"; if (!(Boolean) xpath.evaluate(nodePath, doc, XPathConstants.BOOLEAN)) { M_log.error("init(): Could not find XPath '" + nodePath + "' in " + environmentPath + "."); throw new JamesConfigurationException(); } ((Node) xpath.evaluate(nodePath, doc, XPathConstants.NODE)).setTextContent(nodeValue); M_log.debug("init(): writing James configuration to " + environmentPath); Xml.writeDocument(doc, environmentPath); } catch (JamesConfigurationException e) { throw e; } catch (Exception e) { M_log.warn("init(): An unhandled exception was encountered while configuring James: " + e.getMessage()); } }
From source file:org.wso2.carbon.bpmn.core.types.datatypes.xml.api.XMLDocument.java
/** * Function to evaluate xPath query, and return specified return type * * @param xpathStr xpath expression to evaluate * @param returnType The desired return type of xpath evaluation. Supported retrun types : "NODESET", "NODE", "STRING", "NUMBER", "BOOLEAN" * @return result of xpath evaluation in specified return type * @throws BPMNXmlException/*from w ww . j a v a 2 s .co m*/ * @throws XPathExpressionException */ public Object xPath(String xpathStr, String returnType) throws BPMNXmlException, XPathExpressionException { if (returnType.equals(XPathConstants.NODESET.getLocalPart())) { Utils.evaluateXPath(doc, xpathStr, XPathConstants.NODESET); } else if (returnType.equals(XPathConstants.NODE.getLocalPart())) { Utils.evaluateXPath(doc, xpathStr, XPathConstants.NODE); } else if (returnType.equals(XPathConstants.STRING.getLocalPart())) { Utils.evaluateXPath(doc, xpathStr, XPathConstants.STRING); } else if (returnType.equals(XPathConstants.NUMBER.getLocalPart())) { Utils.evaluateXPath(doc, xpathStr, XPathConstants.NUMBER); } else if (returnType.equals(XPathConstants.BOOLEAN.getLocalPart())) { Utils.evaluateXPath(doc, xpathStr, XPathConstants.BOOLEAN); } else { //Unknown return type throw new BPMNXmlException("Unknown return type : " + returnType); } return null; }
From source file:org.wso2.carbon.humantask.core.engine.runtime.xpath.XPathExpressionRuntime.java
/** * Evaluate given XPath string and returns the result as boolean * * @param exp XPath expression//from w w w . jav a 2 s .c om * @param evalCtx Evaluation context containing all the required context information * @return boolean */ @Override public boolean evaluateAsBoolean(String exp, EvaluationContext evalCtx) { return (Boolean) evaluate(exp, evalCtx, XPathConstants.BOOLEAN); }