Subject: Re: [xml2rfc] #305 (Version 2 cli): xml2rfc refuses to accept stdin

From: "xml2rfc issue tracker" <[email-masked]>
Date: Tue, 27 Oct 2015 03:41:45 -0000

#305: xml2rfc refuses to accept stdin

Comment (by [email-masked]):

 Doing this is going to be a large problem with the current design.  We are
 doing two parse passes over the input.  This is very difficult if one is
 using xml2rfc as a filter.

 The main reason for doing two passes appears to be able to resolve the
 entity &rfc.number;  If an alternate method can be found to this it might
 be possible to change to a single pass over the input.

 I would currently recommend won't fix on this and potentially make it
 something that should be considered for v3.

-- 
----------------------------+----------------------------------
  Reporter:  [email-masked]   |      Owner:  [email-masked]
      Type:  defect         |     Status:  new
  Priority:  medium         |  Milestone:
 Component:  Version 2 cli  |    Version:  2.4.x
Resolution:                 |   Keywords:  filter
----------------------------+----------------------------------

Ticket URL: <http://trac.tools.ietf.org/tools/xml2rfc/trac/ticket/305#comment:1>
xml2rfc <http://tools.ietf.org/tools/xml2rfc/>

---

From: "xml2rfc issue tracker" <[email-masked]>
Date: Tue, 27 Oct 2015 04:01:02 -0000

Comment (by [email-masked]):

 The solution is easy enough (pseudo-code):

 {{{
 if not (check if we can seek on file descriptor):
     copy input to temp file
     set name to be deleted on exit
     reset command line filename to temp filename
 }}}

Ticket URL: <http://trac.tools.ietf.org/tools/xml2rfc/trac/ticket/305#comment:2>
xml2rfc <http://tools.ietf.org/tools/xml2rfc/>

---

From: "xml2rfc issue tracker" <[email-masked]>
Date: Tue, 27 Oct 2015 17:37:09 -0000

It is not quite that easy. We always use a file because we don't pass
 handles between python and C code so it would be

 1.  Change the command line to allow for stdin (no file name) as an option
 2.  If stdin, copy input to a temp file
 3.  Run with the temp file

 Presumably we need to do the opposite so that we can stream out to stdout
 as well.

Ticket URL: <http://trac.tools.ietf.org/tools/xml2rfc/trac/ticket/305#comment:3>
xml2rfc <http://tools.ietf.org/tools/xml2rfc/>

---

From: "xml2rfc issue tracker" <[email-masked]>
Date: Wed, 28 Oct 2015 10:25:44 -0000

Comment (by [email-masked]):

 Reading the stdin input into a {{{StringIO}}} instance and reading it (in
 both passes) from that should let us handle stdin.  Writing is done in a
 singel pass, so even now it should be possible to specify
 {{{/dev/stdout}}} as output file, and have piped output work.  Should be
 tested to verify, of course.

Ticket URL: <https://tools.ietf.org/tools/xml2rfc/trac/ticket/305#comment:4>
xml2rfc <http://tools.ietf.org/tools/xml2rfc/>