You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by iv...@safelayer.com on 2004/09/07 16:11:24 UTC

Problems with default namespace and XPath

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.

RE: Problems with default namespace and XPath

Posted by iv...@safelayer.com.
Oh! I forgot to tell that I'm working in a C++ environment, using 
Xerces_2_5_0 and Xalan_1_8.

Thank you very much anyway,  Maarten.


>-<
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.




maarten.gerbrands@nc3a.nato.int
07/09/2004 17:09
Please respond to security-dev
 
        To:     security-dev@xml.apache.org
        cc: 
        Subject:        RE: Problems with default namespace and XPath


I had the same problem using Java 2 SDK, SE v1.4.2_04.
Using the Apache Xerces-j2-2.6.2.jar instead of the default Apache
classes of this SDK I didn't have this error anymore.
I hope this helps solving your problem.

Maarten Gerbrands
Communication Networks Branch,
Communication and Information Systems Division
NATO C3 Agency
 
 

-----Original Message-----
From: ivan.fontanals@safelayer.com [mailto:ivan.fontanals@safelayer.com]

Sent: dinsdag 7 september 2004 16:11
To: security-dev@xml.apache.org
Subject: Problems with default namespace and XPath


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.


RE: Problems with default namespace and XPath

Posted by ma...@nc3a.nato.int.
I had the same problem using Java 2 SDK, SE v1.4.2_04.
Using the Apache Xerces-j2-2.6.2.jar instead of the default Apache
classes of this SDK I didn't have this error anymore.
I hope this helps solving your problem.

Maarten Gerbrands
Communication Networks Branch,
Communication and Information Systems Division
NATO C3 Agency
 
 

-----Original Message-----
From: ivan.fontanals@safelayer.com [mailto:ivan.fontanals@safelayer.com]

Sent: dinsdag 7 september 2004 16:11
To: security-dev@xml.apache.org
Subject: Problems with default namespace and XPath


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.