OpenCSW Bug Tracker


Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004355 [xmlstarlet] regular use minor always 2010-03-18 14:56 2010-04-25 22:02
Reporter skayser View Status public  
Assigned To dam
Priority normal Resolution fixed  
Status closed  
Summary 0004355: 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?
Additional Information $ pkgparam CSWxmlstarlet VERSION
1.0.1,REV=2009.04.09
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0007851)
dam (administrator)
2010-04-11 20:58

Takeover of upstream project, known patches have been applied:
  http://xmlstar.git.sourceforge.net/git/gitweb.cgi?p=xmlstar/xmlstar;a=shortlog [^]
Wait for libxml2 to re-add bin/64/xml-config
(0007854)
skayser (administrator)
2010-04-12 23:20

Although it hasn't been released yet: Impressive effort. Thanks very much!
(0007869)
dam (administrator)
2010-04-17 21:21

First release with all known patched applied is in experimental:
  http://mirror.opencsw.org/experimental.html#dam [^]
  xmlstarlet-1.0.2,REV=2010.04.17-SunOS5.9-sparc-CSW.pkg.gz
  xmlstarlet-1.0.2,REV=2010.04.17-SunOS5.9-i386-CSW.pkg.gz
Please verify.
(0007893)
skayser (administrator)
2010-04-21 11:06

Problem fixed, thank you.
(0007902)
dam (administrator)
2010-04-25 22:02

Fixed in 1.0.2,REV=2010.04.17 and released to current/.


Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker