Hi everybody,
I'm trying to sign a XML document with a non-prefixed namespace, which is the default one. Well, in fact the problem neither is in the signature nor in the verification, but is a XPath problem. When I try to get a DOMNode * from a valid XPath, I always got an error telling that the node does not exist... The problem is the default namespace, I think, but I don't know how to solve it.
I'm working with a XML like this:
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<QUERY xmlns="http://inti.notariado.org/XML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<REQUEST ID="REQUEST">
<HEADER>AFASFA</HEADER>
</REQUEST>
</QUERY >
If I ask for the /QUERY/REQUEST I got an error, but if I named the namespace, the problem disappear. I mean this:
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<ns1:QUERY xmlns:ns1="http://inti.notariado.org/XML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns1:REQUEST ID="REQUEST">
<ns1:HEADER>AFASFA</ns1:HEADER>
</ns1:REQUEST>
</ns1:QUERY >
Now I can ask for /ns1:QUERY/ns1:REQUEST without problems, but this is not what I want.....
Do you know if exists an easy way where I can select a node from a valid XPath within a default namespace?
My code which returns the node from a XPath is the following:
DOMNode* XMLUtils::getDOMNodeFromXPath( const sfly::string& xpath ) {
XercesDOMSupport xds;
XalanNode *contextNode;
XercesParserLiaison theParserLiaison;
auto_ptr<XPathEvaluator> theEvaluator( new XPathEvaluator() );
XalanDocument *theDoc = theParserLiaison.createDocument( parser->getDocument());
XalanDocumentPrefixResolver thePrefixResolver( theDoc );
XalanDOMString dsPath( xpath.GetData(), xpath.GetLength() );
const XalanDOMChar *path = dsPath.c_str();
contextNode = theEvaluator->selectSingleNode( xds, theDoc, path, thePrefixResolver );
return XalanNodeToDOMNode( contextNode );
}
Thank you very much in advance!
Best Regards,
Ivan
>-<
This email has been digitally signed. You can verify its authenticity by installing Safelayer's Root Certificate:
http://ca.safelayer.com/install_root.html
>-<
IMPORTANT NOTICE: This communication contains information which is confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender. The opinions expressed within this communication are not necessarily those expressed by Safelayer Secure Communications.
smime.p7s
Description: S/MIME Cryptographic Signature