List of utility methods to do XPath Get
String | get(String path, Node e) get return (String) evaluateXPath(path, e, XPathConstants.STRING);
|
String | getAttribute(String fileName, String xPathExpression, String attributeName) get Attribute try { Document document = parseXML(new File(fileName)); XPath xpath = XPathFactory.newInstance().newXPath(); XPathExpression xpathExpression = xpath.compile(xPathExpression); Node node = (Node) xpathExpression.evaluate(document, NODE); return getAttributeValueByName(node, attributeName); } catch (Exception e) { throw new RuntimeException("Failed to extract element from:" + fileName, e); ... |
String | getBaseLocation(byte[] metadata) get Base Location DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder; try { builder = builderFactory.newDocumentBuilder(); Document document = builder.parse(new ByteArrayInputStream(metadata)); return (String) xPath.compile(BASE_LOCATION).evaluate(document, XPathConstants.STRING); } catch (XPathExpressionException | ParserConfigurationException | SAXException | IOException e) { return null; ... |
boolean | getBool(Node node, boolean def, XPathExpression expr) Get a boolean from an XPath expression. String s = getStringOrNull(node, expr); if (s == null) { return def; return s.equalsIgnoreCase("true"); |
Map | getCache() get Cache Map<String, XPathExpression> mRetVal = sCache.get(); if (mRetVal == null) { mRetVal = new HashMap<String, XPathExpression>(); sCache.set(mRetVal); return mRetVal; |
X509Certificate | getCertificateFromKeyInfo(Node keyInfoNode) get Certificate From Key Info X509Certificate cert = null; try { String s = x509Path.evaluate(keyInfoNode); if (s == null || s.length() == 0) return null; byte[] decoded = Base64.decodeBase64(s); cert = (X509Certificate) certFactory.generateCertificate(new ByteArrayInputStream(decoded)); } catch (XPathExpressionException e) { ... |
XPath | getCruxPagesXPath() get Crux Pages X Path XPathFactory factory = XPathFactory.newInstance(); XPath findPath = factory.newXPath(); findPath.setNamespaceContext(new NamespaceContext() { public String getNamespaceURI(String prefix) { if (prefix.equals("c")) { return "http://www.cruxframework.org/crux"; } else if (prefix.equals("v")) { return "http://www.cruxframework.org/view"; ... |
XPath | getDefaultXPath() get Default X Path return defaultXPath;
|
XPathFactory | getDefaultXPathFactory() get Default X Path Factory return s_aXPathFactory;
|
String | getDigestValue(Node reference) Returns the value of DigestValue node return getNodeValue(reference, GET_DIG_VAL_EXP);
|