xml-xalan-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "siegfried" <siegfr...@heintze.com>
Subject FW: FW: command line tool for reading and writing to/from stdin and stdout?
Date Fri, 05 Sep 2008 02:40:05 GMT
Woops -- where did that bogus address come from? Let me try again:

  _____  

From: siegfried [mailto:siegfried@heintze.com] 
Sent: Thursday, September 04, 2008 6:56 PM
To: 'keshlam@us.ibm.com'; 'David Bertoni'
Cc: 'xalan-j-users@lotus.com'
Subject: RE: FW: command line tool for reading and writing to/from stdin and
stdout?


Sure!
This program from
c:/dev/xalan/xalan-j_2_7_1/samples/UseStylesheetPI/UseStylesheetPI.java (see
attachment) does not work because I made a minor modification to read from
standard input on line 58. Can you help me make it work?
 
Here is the fragment redundantly for your reding pleasure. Note that if I
hard code a file name on line 58, line 62 works.
Thanks!
Siegfried
 
     TransformerFactory tFactory = TransformerFactory.newInstance();
      Source stylesheet = tFactory.getAssociatedStylesheet
        (new StreamSource(System.in),media, title, charset);
      
      Transformer transformer = tFactory.newTransformer(stylesheet);
/*  60*/ 
        
     transformer.transform(new StreamSource(System.in), 
                             new StreamResult(new
java.io.FileOutputStream(java.io.FileDescriptor.out)));
       


 
 
 

  _____  

From: keshlam@us.ibm.com [mailto:keshlam@us.ibm.com] 
Sent: Thursday, September 04, 2008 5:03 PM
To: David Bertoni
Cc: siegfried; xalan-j-users@lotus.com
Subject: Re: FW: command line tool for reading and writing to/from stdin and
stdout?



> I'm not sure what you mean by "having standard input open twice."  Are 
> you saying you want to read both the input document and the stylesheet 
> from system.in?  That isn't possible, since there would be no way to 
> demarcate each entity in the stream. 

Well, it's possible -- but you'd need to develop your own data stream
protocol which allowed you to express logical end-of-file, and do some
entity-resolver work to read twice from this delimited stream using
different URIs. 

Or, simpler but less efficient, have a preprocessing stage which reads that
delimited stream, writes the documents into scratch files, and then process
from those. 

But I agree that we're guessing at the intended meaning. Siegfried, maybe
you ought to take a long step back and explain exactly what it is you're
trying to do. If you want to read both the stylesheet and document from
stdin, you need a delimiting and resolver solution as discussed above. If
you just want to read the document from stdin, and the stylesheet from a
file, while writing to stdout... well, that should be a trivial change to
one of the Xalan sample programs. 

If you're trying to do something else, you'll need to explain what in enough
detail that we can advise you. The mind-reading support service costs real
money. <smile/> 

Mime
View raw message