Here you can find the source of getDigestValue(Node reference)
Parameter | Description |
---|---|
reference | the Reference node |
Parameter | Description |
---|---|
XPathExpressionException | on XPath evaluation error |
public static String getDigestValue(Node reference) throws XPathExpressionException
//package com.java2s; /**/*from w w w. j a va 2 s .co m*/ * Copyright 5AM Solutions Inc * Copyright SemanticBits LLC * Copyright AgileX Technologies, Inc * Copyright Ekagra Software Technologies Ltd * * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/cacis/LICENSE.txt for details. */ import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Node; public class Main { /** * XPath expression to retrieve the digest value of a Reference element */ public static final String GET_DIG_VAL_EXP = "*[local-name()='DigestValue']"; /** * Returns the value of DigestValue node * * @param reference the Reference node * @return the value * @throws XPathExpressionException on XPath evaluation error */ public static String getDigestValue(Node reference) throws XPathExpressionException { return getNodeValue(reference, GET_DIG_VAL_EXP); } private static String getNodeValue(Node node, String expStr) throws XPathExpressionException { final XPathFactory fac = XPathFactory.newInstance(); final XPath xpath = fac.newXPath(); final XPathExpression exp = xpath.compile(expStr); final Node selected = (Node) exp.evaluate(node, XPathConstants.NODE); return selected.getTextContent(); } }