namespacing fun(?)
[email protected] ("Daniel Pupius") Fri, 30 Jan 2004 16:48:25 -0000
| Newsgroups | php.xml.dev |
|---|---|
| Organization | act e-learning |
| Message-ID | <[email protected]> |
Hey there,
I'm using the DOM XML and XPATH queries. My application has to accept XML
formats based on an IMS standard, both generated in our company and
externally by others.
Now the problem, most people use the same naming convensions for namespaces,
but a couple of people do not. This causes the XPATH queries to fail.
For example, consider the following XML documents:
<demo xmlns="http://somenamespace">
<node>
<child />
<child />
</node>
</demo>
<ns:demo xmlns:ns="http://somenamespace">
<ns:node>
<ns:child />
<ns:child />
</ns:node>
</ns:demo>
<fun:demo xmlns:fun="http://somenamespace">
<fun:node>
<fun:child />
<fun:child />
</fun:node>
</fun:demo>
They all represent the same structure, bound to the same namespace. And are
thus all esentially equal to:
<http://somenamespace:demo>
.... etc ....
</http://somenamespace:demo>
When creating the XPATH queries, you'd register the namespace:
xpath_register_ns($xpath,"ns", "http://somenamespace");
And format your queries like so:
/ns:demo/ns:node/ns:child
I'd expect this to match all the above xml files, since the "ns" in the
xpath query refers to the namespace rather than the textual abrieviation of
the namespace. Am I correct in this assumption? Of course, it doens't seem
to work with PHPs parser.
I was therefore wondering if anyone had any ideas on how to get round this
problem...
Cheers
Dan