Discussion:
[XOM-interest] Removing namespace declarations
Peter Murray-Rust
2011-05-09 20:56:33 UTC
Permalink
I have been processing XOM using XInclude and have somehow ended up with
XInclude namespace declarations on nodes, as in:

<module xmlns="http://www.xml-cml.org/schema" xmlns:xi="
http://www.w3.org/2001/XInclude">
...
</module>

I'd like to get rid of them, ideally with XPath, but my reading of XOM
suggests that I cannot obtain namespace declarations with XPath. If I can't
do it this way is there a programmatic way of getting rid of them?

P.
--
Peter Murray-Rust
Reader in Molecular Informatics
Unilever Centre, Dep. Of Chemistry
University of Cambridge
CB2 1EW, UK
+44-1223-763069
Elliotte Rusty Harold
2011-05-12 18:29:04 UTC
Permalink
Post by Peter Murray-Rust
I have been processing XOM using XInclude and have somehow ended up with
<module xmlns="http://www.xml-cml.org/schema" xmlns:xi="
http://www.w3.org/2001/XInclude">
?...
</module>
Looks like your XInclude picked up some namespaces in scope.
Post by Peter Murray-Rust
I'd like to get rid of them, ideally with XPath, but my reading of XOM
suggests that I cannot obtain namespace declarations with XPath. If I can't
do it this way is there a programmatic way of getting rid of them?
Should be. Assuming the namespace isn't actually used, then just call
element.removeNamespaceDeclaration("xi")
--
Elliotte Rusty Harold
elharo at ibiblio.org
Continue reading on narkive:
Loading...