RE: [xml] XPath evaluation



I have tried with the use of xmlXPathRegisterNs, but it doesn't work.
xmlXPathRegisterNs(xpathCtx, BAD_CAST "urn:ssp.ApplicationHeader$ahV10", BAD_CAST "")
xmlXPathRegisterNs(xpathCtx, BAD_CAST "urn:ssp.pm.GetAccount$camt.003.001.02", BAD_CAST "")
xmlXPathRegisterNs(xpathCtx, BAD_CAST "SwInt", BAD_CAST "")

It has the same behaviour...
/REQUEST/RequestPayload/Document doesn't work
/REQUEST/RequestPayload/*[name()='Document'] works fine

Patrick CAPRON 

-----Message d'origine-----
De : Nic [mailto:nferrier tapsellferrier co uk]
Envoyé : mercredi 26 avril 2006 14:52
À : CAPRON Patrick
Cc : xml gnome org; AUFFRAY Gilles
Objet : Re: [xml] XPath evaluation


"CAPRON Patrick" <capronpa e-i com> writes:

Hi,
 
I don't understand how libxml2 is evaluating some expressions.
 
I have an XML who looks like :
<?xml version="1.0"?>
<REQUEST>
    <HEADER/>
    <CODEAPPLI>TARGET2</CODEAPPLI>
    <BICCOR>CMCIFRPP</BICCOR>
    <NMSRVLOG>NMSRVLOG</NMSRVLOG>
    <NMRQTLOG>NMRQTLOG</NMRQTLOG>
    <REQUESTREF>REQUESTREF</REQUESTREF>
    <RQTSTATUS>RQTSTATUS</RQTSTATUS>
    <SwInt:RequestPayload>
        <AppHdr xmlns="urn:ssp.ApplicationHeader$ahV10">
            <From>
                <Type>NAME</Type>
                <Id>PM</Id>
            </From>
            <To>
                <Type>NAME</Type>
                <Id>PM</Id>
            </To>
            <MsgRef>ABCDEF</MsgRef>
            <CrDate>2006-04-19T12:00:00</CrDate>
        </AppHdr>
        <Document xmlns="urn:ssp.pm.GetLimit$camt.009.001.02">
            <camt.009.001.02>
                <MsgId>
                    <Id>REFERENCE12345</Id>
                </MsgId>
                <LmtQryDef>
                    <LmtCrit>
                        <NewCrit>
                            <SchCrit>
                                <AcctOwnr>CMCIFRPAXXX</AcctOwnr>
                            </SchCrit>
                        </NewCrit>
                    </LmtCrit>
                </LmtQryDef>
            </camt.009.001.02>
        </Document>
    </SwInt:RequestPayload>
</REQUEST>
 
I use the xmlXPathEvalExpression function.
If I use the expression : /REQUEST/RequestPayload/Document the function returns 0 node.
If I use the expression : /REQUEST/RequestPayload/*[name()='Document'] it returns the node I'm
looking for.
 
Could anybody explain me why there is a difference between this two expressions ?
I believed that they were the same...
Is it because of the xmlns ?

Yes, I think so.

But I don't know why the second one matches at all because
RequestPayload isn't in an empty namespace either; so I expected it to
match if you did:

   /REQUEST/SwInt:RequestPayload:urn:ssp.pm.GetLimit$camt.009.001.02:Document

To get xpath to match this you could register the namespaces with tags
and then eval the expressions.


Nic Ferrier
http://www.tapsellferrier.co.uk



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]