The problem is that I have created a library around the apache-XML security and I don't know the namespaces of the XML document to verify. The user of my library gives me the Xpath expression of the signature location. The work arround I found for the moment is to add all namespaces of my signed document (only thoses found at document level) into the nscontext object, but I don't like this solution. Any others idea ?
Regards. Yvan -----Original Message----- From: Vishal Mahajan [mailto:[EMAIL PROTECTED] Sent: lundi, 4. octobre 2004 11:40 To: [EMAIL PROTECTED] Subject: Re: Problem of retrieving signature element using XPath expression ha ving different namespaces 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:id e >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 > >
