Public.Parser.XML2

[ Start > PikeModules > Module > Public.Parser.XML2 ] [ Edit this Page | Show Page Versions | Show Formatted ]


__Namespaces in XML2__

Public.Parser.XML2 handles namespaces a bit differently than Parser.XML. This brief overview of the process should help explain things a little better.

get_attributes() will return all attributes without their namespace attached. In cases where there are two attributes with the same "local" name, the first defined attribute will be returned.

For example, in this contrived xml snippet:

{code}


{code}

We get the following result:

{code}
> n->get_attributes();
(1) Result: ([ /* 3 elements */
              "collision": "1",
              "encodingStyle": "http://www.w3.org/2001/12/soap-encoding",
              "nonsatt": "foo"
            ])
{code}

get_ns_attributes(string ns_uri) should return all attributes with a given namespace URI.

For example, in the previous document, 

{code}
n->get_ns_attributes("http://www.w3.org/2001/12/soap-envelope");

(2) Result: ([ /* 2 elements */
              "collision": "1",
              "encodingStyle": "http://www.w3.org/2001/12/soap-encoding"
            ])
{code}

 n->get_nss() should return a list of all namespace (prefix:uri) pairs defined for the node. The default namespace will have an index of "".

n->get_ns() should return the default namespace for the node.


Powered by PikeWiki2

 
gotpike.org | Copyright © 2004 - 2009 | Pike is a trademark of Department of Computer and Information Science, Linköping University