Yvan,
Please see inline ...
Hess Yvan wrote:
Hi,
I have a problem to retrieve the Signature element of my signed XML document using XPath expression. My document looks like that:
<?xml version="1.0" encoding="UTF-8"?> <edoc:e-document xmlns:dcmi="http://www.imtf.com/e-document/dcmi" xmlns:edoc="http://www.imtf.com/e-document" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"> <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> .... </ds:Signature> <edoc:metadata> <dcmi:DCMI>
<dcmi:identifier>urn:hypersuite:EFECD0FF-C0A8021C08DEE071-D030940E</dcmi:ide ntifier> <dcmi:date>1966-07-20</dcmi:date> </dcmi:DCMI> <edoc:custom> <edoc:customer>333777</edoc:customer> <edoc:account>333777.0</edoc:account> <edoc:account-manager>Giraffe aile</edoc:account-manager> <edoc:amount>123456789.10</edoc:amount> <edoc:type>Savane</edoc:type> </edoc:custom> </edoc:metadata> </edoc:e-document>
I would like to retrieve my signature element using the XPath expression
"/edoc:e-document/ds:Signature", but it fails because the namespace "edoc"
is not known if I use
Element nscontext = XMLUtils.createDSctx(xmlDocument, "ds", Constants.SignatureSpecNS);
Also add "edoc" prefix-mapping to nscontext,
nscontext.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:edoc", "http://www.imtf.com/e-document");
Vishal
sigElement = (Element) XPathAPI.selectSingleNode(xmlDocument, signatureLocation, nscontext);
and it fails also if I use
sigElement = (Element) XPathAPI.selectSingleNode(xmlDocument, signatureLocation);
How can I solve the problem (I don't want to use "//ds:Signature") . It seem to be a problem of Xalan XPath API....
Thanks for your answer
Yvan