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

Mantis Bug Tracker noreply at opencsw.org
Thu Mar 18 14:56:12 CET 2010


The following issue has been SUBMITTED. 
====================================================================== 
http://www.opencsw.org/mantis/view.php?id=4355 
====================================================================== 
Reported By:                skayser
Assigned To:                
====================================================================== 
Project:                    xmlstarlet
Issue ID:                   4355
Category:                   regular use
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2010-03-18 14:56 CET
Last Modified:              2010-03-18 14:56 CET
====================================================================== 
Summary:                    Multiple namespace definitions via (-N) don' work
when reading from stdin
Description: 
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#"
   xmlns:em="http://www.mozilla.org/2004/em-rdf#">
  <Description about="urn:mozilla:install-manifest">
    <em:id>{e4a8a97b-f2ed-450b-b12d-ee082ba24781}</em:id>
  </Description>
</RDF>

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
{e4a8a97b-f2ed-450b-b12d-ee082ba24781}

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
"//rdf:Description[@about='urn:mozilla:install-manifest']/em:id"
XMLStarlet Toolkit: Select from XML document(s)
Usage: xml sel <global-options> {<template>} [ <xml-file> ... ]
where
  <global-options> - global options for selecting
  <xml-file> - input XML document file name/uri (stdin is used if
missing)
...

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"
{e4a8a97b-f2ed-450b-b12d-ee082ba24781}

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
http://sourceforge.net/tracker/?func=detail&aid=1722425&group_id=66612&atid=515106

Could you please rebuild with the patch?
======================================================================



More information about the bug-notifications mailing list