commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nicola...@apache.org
Subject cvs commit: jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/morphers/xml XSLTMorpher.java
Date Thu, 29 Aug 2002 07:07:59 GMT
nicolaken    2002/08/29 00:07:59

  Modified:    morphos/src/java/org/apache/commons/morphos/factories
                        BasicMorpherFactory.java
               morphos/src/java/org/apache/commons/morphos Morphos.java
               morphos/src/java/org/apache/commons/morphos/morphers/poi
                        POIFSMorpher.java
               morphos/src/java/org/apache/commons/morphos/morphers/xml
                        XSLTMorpher.java
  Log:
  After some net problems, Sven is connected to the net again, and
  here is another patch!
  Thanks, man, keep them rolling... till I get up and call a vote for you that is ;-)
  
  <action dev="nicolaken" type="add" due-to="Sven Kuenzler" due-to-email="svenk@tzi.de"
context="code">
    Added the Locator interface, to separate the getting of a resource
     from the actual processing.
  </action>
  
  Revision  Changes    Path
  1.2       +4 -3      jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/factories/BasicMorpherFactory.java
  
  Index: BasicMorpherFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/factories/BasicMorpherFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BasicMorpherFactory.java	5 Aug 2002 13:35:13 -0000	1.1
  +++ BasicMorpherFactory.java	29 Aug 2002 07:07:59 -0000	1.2
  @@ -84,6 +84,7 @@
   	 knownMorphers.put("xslt","org.apache.commons.morphos.morphers.xml.XSLTMorpher");
   	 knownMorphers.put("poi2xls","org.apache.commons.morphos.morphers.poi.POIFSMorpher");
   	 knownMorphers.put("is2sax","org.apache.commons.morphos.morphers.dataform.InputSource2SAXMorpher");
  +	 knownMorphers.put("stream2sax","org.apache.commons.morphos.morphers.dataform.Stream2SAXMorpher");
        }
   		   
       public Morpher getMorpher(ObjectFlavor inputFlavor, ObjectFlavor outputFlavor){
  
  
  
  1.4       +21 -23    jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/Morphos.java
  
  Index: Morphos.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/Morphos.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Morphos.java	5 Aug 2002 13:35:13 -0000	1.3
  +++ Morphos.java	29 Aug 2002 07:07:59 -0000	1.4
  @@ -75,6 +75,7 @@
   import org.xml.sax.XMLReader;
   
   import org.apache.commons.morphos.morphers.xml.*;
  +import org.apache.commons.beanutils.PropertyUtils;
   
   /**
    * @author Nicola Ken Barozzi
  @@ -89,38 +90,35 @@
   			System.err.println("Usage: org.apache.commons.morphos.Morphos infile outfile [xsl-transform]");
   			System.exit(2);
   		}
  -                
  -                //------------------------------------------------------------        
       
  -                //WARNING: pipelining done by hand; uses only fixed morphers
  -                //------------------------------------------------------------
  -                //Can use more stages for modularity, like string->File
  -                // then File->InputStream, then the following.
  -                //Need to integrate with Transformers for simple stuff.
  -                //------------------------------------------------------------
  -                // also here we give a morpher to a morpher, sometimes we give
  -                // the output... needs to be thought better maybe...
   
  -                InputSource input = new InputSource(new FileInputStream(args[0]));	
  -		OutputStream output = new FileOutputStream(args[1]);
  -                
  +		Locator input = new org.apache.commons.morphos.locators.InputStreamLocator();
  +		Locator output = new org.apache.commons.morphos.locators.OutputStreamLocator();
  +
  +		input.setLocation(args[0]);
  +		output.setLocation(args[1]);
  +		                
                   MorpherFactory mf = new BasicMorpherFactory();
   		MorpherPipeline mp = new SAXMorpherPipeline();
   
  -		mp.addStage(mf.getMorpher("is2sax"));
  +		mp.addStage(mf.getMorpher("stream2sax"));
   		Morpher xslt = mf.getMorpher("xslt");
   		if(args.length==3){
  -		    ((StylesheetAware)xslt).setStylesheet(new javax.xml.transform.sax.SAXSource(new InputSource(new
FileInputStream(args[2]))));
  +		    PropertyUtils.setSimpleProperty(xslt, "stylesheet", 
  +						    new javax.xml.transform.sax.SAXSource(new InputSource(new FileInputStream(args[2]))));
   		}
   		mp.addStage(xslt);
   		mp.addStage(mf.getMorpher("gnumeric2xls"));
   
  -		mp.setInput(input);                
  -		mp.setOutput(output);
  +
  +		mp.setInput(input.locate());                
  +		mp.setOutput(output.locate());
   		
                   mp.morph();
                   
  -                output.flush();
  -                output.close();
  +		// FIXME: Where does this really belong?
  +		OutputStream result = (OutputStream)output.locate();
  +                result.flush();
  +                result.close();
   	}
   	
   }
  
  
  
  1.3       +2 -0      jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/morphers/poi/POIFSMorpher.java
  
  Index: POIFSMorpher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/morphers/poi/POIFSMorpher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- POIFSMorpher.java	5 Aug 2002 13:35:14 -0000	1.2
  +++ POIFSMorpher.java	29 Aug 2002 07:07:59 -0000	1.3
  @@ -104,6 +104,8 @@
        */
        public void setOutput(Object output) throws ObjectFlavorException
         {
  +	  if(output==null) throw new ObjectFlavorException("null output object");
  +
   	if(output instanceof POIFSFileSystem){
   	  _outputStream=null;
             _filesystem=(POIFSFileSystem)output;
  
  
  
  1.2       +5 -3      jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/morphers/xml/XSLTMorpher.java
  
  Index: XSLTMorpher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/morphers/xml/XSLTMorpher.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XSLTMorpher.java	5 Aug 2002 13:35:14 -0000	1.1
  +++ XSLTMorpher.java	29 Aug 2002 07:07:59 -0000	1.2
  @@ -68,6 +68,8 @@
   import javax.xml.transform.sax.*;
   import org.xml.sax.*;
   
  +import org.xml.sax.Locator;
  +
   /**
    *  
    *
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message