Re: [xml] XPath with default namespace

How can I ensure that I have the correct namespaces set up in the context
 before using xPath to query for an element that defines it's namespace
 within that element?
 <xsd:schema targetNamespace="";

Taking this as a cut down file...

<?xml version="1.0"?>

<definitions name="someservice"
     <xsd:schema targetNamespace="";
     <xsd:element name="GetEndorsingBoarder"/>

If I try :

XPath returns:
 Error xpath.c:7976: Undefined namespace prefix
 Error xpath.c:7970: Invalid type
 Which is obviously because the namespace is not defined yet.

I can hack it by predefining an alternative prefix e.g ofxsd2000 to the URI
 in question but that implies that I have to evaluate a path for each
 possible value of xsd: i.e.

         xmlXPathRegisterNs(ctx, (xmlChar *)"ofxsd2001", (xmlChar
         xmlXPathRegisterNs(ctx, (xmlChar *)"ofxsd2000", (xmlChar
         xmlXPathRegisterNs(ctx, (xmlChar *)"ofxsd1999", (xmlChar

and then search with all three possible mappings of xsd to the above URIs.
 Or do I have to walk the tree to the schema element and then load the

Also, I am unable to figure out how to list out the current namespaces in a
 given context. Any help would be greatly appreciated.


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