/** * Execute xPath expression and return value as object. * * @param element OMElement which requires to evaluate * @param xPathExp String xPath expression * @param nameSpaceMap name value pair containing namespace and prefixes * @return the Object which evaluated from OMElement * @throws JaxenException when having an issue with xPath expression */ protected Object xPathEvaluate(OMElement element, String xPathExp, Map<String, String> nameSpaceMap) throws JaxenException { AXIOMXPath xpath = new AXIOMXPath(element, xPathExp); xpath.addNamespaces(element); if (nameSpaceMap != null) { for (String prefix : nameSpaceMap.keySet()) { xpath.addNamespace(prefix, nameSpaceMap.get(prefix)); } } return xpath.evaluate(element); }
/** * Execute xPath expression and return value as object. * * @param element OMElement which requires to evaluate * @param xPathExp String xPath expression * @param nameSpaceMap name value pair containing namespace and prefixes * @return the Object which evaluated from OMElement * @throws JaxenException when having an issue with xPath expression */ protected Object xPathEvaluate(OMElement element, String xPathExp, Map<String, String> nameSpaceMap) throws JaxenException { AXIOMXPath xpath = new AXIOMXPath(element, xPathExp); xpath.addNamespaces(element); if (nameSpaceMap != null) { for (String prefix : nameSpaceMap.keySet()) { xpath.addNamespace(prefix, nameSpaceMap.get(prefix)); } } return xpath.evaluate(element); }
public Object evaluateXPath( XPath xpath, Object context ) throws XMLProcessingException { Object result; try { result = getAXIOMXPath( xpath ).evaluate( context ); } catch ( JaxenException e ) { throw new XMLProcessingException( e.getMessage() ); } return result; }
compiledXPath = new AXIOMXPath(source); result = compiledXPath.evaluate(envelope); } catch (JaxenException e) { throw new EvaluatorException("Error while parsing the XPath expression: " + source, e);
compiledXPath = new AXIOMXPath(source); result = compiledXPath.evaluate(envelope); } catch (JaxenException e) { throw new EvaluatorException("Error while parsing the XPath expression: " + source, e);
private static OMElement updateSchemaImports(OMElement omElement, boolean isMasterArtifact, String xpath) throws JaxenException { AXIOMXPath xPath = new AXIOMXPath(xpath); // "http://schemas.xmlsoap.org/wsdl/" xPath.addNamespace("xs", "http://www.w3.org/2001/XMLSchema"); Object result = xPath.evaluate(omElement); if(!(result instanceof ArrayList)){ return omElement; } List list = (ArrayList)result; for (Object obj : list) { OMElement _import = (OMElement) obj; OMAttribute attribute = _import.getAttribute(new QName("schemaLocation")); String newValue = isMasterArtifact ? "dependencies" + attribute.getAttributeValue().substring(attribute.getAttributeValue().lastIndexOf("/")) :attribute.getAttributeValue().substring(attribute.getAttributeValue().lastIndexOf("/")+1); attribute.setAttributeValue(newValue); } return omElement; }
private static OMElement updateWSDLImports(OMElement omElement,boolean isMasterArtifact) throws JaxenException { AXIOMXPath xPath = new AXIOMXPath("//wsd:import[@location]"); xPath.addNamespace("wsd", "http://schemas.xmlsoap.org/wsdl/"); Object result = xPath.evaluate(omElement); if(!(result instanceof ArrayList)){ return omElement; } List list = (ArrayList) result; for (Object obj : list) { OMElement _import = (OMElement) obj; OMAttribute attribute = _import.getAttribute(new QName("location")); String newValue = isMasterArtifact ? "dependencies" + attribute.getAttributeValue().substring(attribute.getAttributeValue().lastIndexOf("/")) :attribute.getAttributeValue().substring(attribute.getAttributeValue().lastIndexOf("/")+1); attribute.setAttributeValue(newValue); } return omElement; }