GNOME Bugzilla – Bug 310222
"du" and "ls" in xmllint shell should show the namespaces
Last modified: 2012-05-07 09:06:08 UTC
$ xmllint --shell content.xml / > setrootns / > ls -an 4 document-content / > cd document-content document-content is a 0 Node Set / > cd office:document-content document-content > How do I know it was the "office:" namespace without cheating (i.e. look at the XML file with an ordinary text editor)? For comfort in browsing the XML tree, the namespaces should be displayed by "ls" and "du" commands. "cat" displays the namespaces but you get the whole document when you are at its root...
Created attachment 210694 [details] [review] Improved namespace support for xmllint shell This patch (against libxml2-2.7.8) adds namespace support to ls, du and the element named in the command shell prompt. It also fixes du to actually dump the requested path, if the user gives one, rather than always dumping the whole file.
Patch is interesting but annoyingly it would print ?:foo for foo elements in the default namespace. In general I would rather show just "foo" though this would defeat the initial request as pointed by Eric (cd foo will fail because XPath won't match a node in default namespace that way ...). In the absence of a general solution to default namespace, I will keep as is for them, so I modified the patch to only handle namespaces with explicit prefixes The patch for du is good too, so picking this up ! http://git.gnome.org/browse/libxml2/commit/?id=40db1eeb3637af933fca491dfc90c25c31e6e05e thanks ! Daniel