[bug-notifications] [xmlstarlet 0004355]: Multiple namespace definitions via (-N) don' work when reading from stdin

Mantis Bug Tracker noreply at opencsw.org
Wed Apr 21 11:06:17 CEST 2010

A NOTE has been added to this issue. 
Reported By:                skayser
Assigned To:                dam
Project:                    xmlstarlet
Issue ID:                   4355
Category:                   regular use
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     feedback
Date Submitted:             2010-03-18 14:56 CET
Last Modified:              2010-04-21 11:06 CEST
Summary:                    Multiple namespace definitions via (-N) don' work
when reading from stdin
xmlstarlet behaves differently when reading from stdin as opposed to
reading from a file. Specifically, working with multiple namespace
definitions (-N) does NOT work when reading from stdin.

For demonstration purposes test2.xml contains an abbreviated install.rdf
(from a Firefox add-on).

$ cat test2.xml 
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  <Description about="urn:mozilla:install-manifest">

Retrieving the value of em:id when reading from the file works.

$ xmlstarlet sel -N rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns# -N
em=http://www.mozilla.org/2004/em-rdf# -t -v
"//rdf:Description[@about='urn:mozilla:install-manifest']/em:id" test2.xml

Using the very same command just reading from stdin does NOT work. Instead
the usage instructions are displayed. Unfortunately, there is no indication
what exactly xmlstarlet doesn't like about its invocation.

$ cat test2.xml | xmlstarlet sel -N
rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns# -N
em=http://www.mozilla.org/2004/em-rdf# -t -v
XMLStarlet Toolkit: Select from XML document(s)
Usage: xml sel <global-options> {<template>} [ <xml-file> ... ]
  <global-options> - global options for selecting
  <xml-file> - input XML document file name/uri (stdin is used if

Note the documented behavior for xml-file and stdin above. Judging from
this it shouldn't make a difference whether an input file is read from a
file or from stdin.

Now, reading from stdin, but falling back to a single namespace definition
works (to do so I obviously needed to simplify the XPath expression as I
can't work with the dropped namespace any more).

$ cat test2.xml | xmlstarlet sel -N em=http://www.mozilla.org/2004/em-rdf#
-t -v "//em:id"

Seems to me as if there is something weird going on when reading from
stdin. Same behavior can be observed on Debian Etch. Searching through the
upstream bug tracker turned up a relevant bug (which has a patch):

many -N options on command line bug - ID: 1722425

Could you please rebuild with the patch?

 (0007893) skayser (administrator) - 2010-04-21 11:06
Problem fixed, thank you.

More information about the bug-notifications mailing list