gmazza      2003/08/01 18:15:20

  Modified:    src/java/org/apache/fop/apps Driver.java FOInputHandler.java
                        InputHandler.java XSLTInputHandler.java
  Log:
  1.  Moved the XMLReader createParser() functionality from abstract class 
InputHandler to FOInputHandler.
  2.  Added the setting of the "namespace-prefix" SAX option directly into 
createParser(), and removed function setParserFeatures (where it was previously being 
set).
  3.  Removed the duplicate XMLReader creation code in Driver.run(), it now uses 
FOTreeBuilder.createParser().
  
  Revision  Changes    Path
  1.14      +2 -11     xml-fop/src/java/org/apache/fop/apps/Driver.java
  
  Index: Driver.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/Driver.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Driver.java       29 Jul 2003 19:08:22 -0000      1.13
  +++ Driver.java       2 Aug 2003 01:15:20 -0000       1.14
  @@ -579,7 +579,6 @@
       public synchronized void render(InputHandler inputHandler)
                   throws FOPException {
           XMLReader parser = inputHandler.getParser();
  -        inputHandler.setParserFeatures(parser);
           render(parser, inputHandler.getInputSource());
       }
   
  @@ -660,15 +659,8 @@
   
           if (reader == null) {
               if (!(source instanceof DocumentInputSource)) {
  -                try {
  -                    SAXParserFactory spf = 
javax.xml.parsers.SAXParserFactory.newInstance();
  -                    spf.setNamespaceAware(true);
  -                    reader = spf.newSAXParser().getXMLReader();
  -                } catch (SAXException e) {
  -                    throw new FOPException(e);
  -                } catch (ParserConfigurationException e) {
  -                    throw new FOPException(e);
  -                }
  +                //TODO: (gm) rename to FOFileHandler or similar
  +                reader = org.apache.fop.apps.FOInputHandler.createParser();
               }
           }
   
  @@ -678,6 +670,5 @@
               render(reader, source);
           }
       }
  -
   }
   
  
  
  
  1.5       +29 -1     xml-fop/src/java/org/apache/fop/apps/FOInputHandler.java
  
  Index: FOInputHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/FOInputHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FOInputHandler.java       17 Jun 2003 16:35:57 -0000      1.4
  +++ FOInputHandler.java       2 Aug 2003 01:15:20 -0000       1.5
  @@ -53,11 +53,16 @@
   // Imported SAX classes
   import org.xml.sax.InputSource;
   import org.xml.sax.XMLReader;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.SAXNotSupportedException;
   
   // java
  +import javax.xml.parsers.SAXParserFactory;
  +import javax.xml.parsers.ParserConfigurationException;
   import java.io.File;
   import java.net.URL;
   
  +
   /**
    * Manages input if it is an XSL-FO file.
    */
  @@ -97,7 +102,7 @@
        * @see org.apache.fop.apps.InputHandler#getParser()
        */
       public XMLReader getParser() throws FOPException {
  -        return super.createParser();
  +        return createParser();
       }
   
       /**
  @@ -107,6 +112,29 @@
           throw new FOPException("not implemented: FOInputHandler.run(Driver)");
       }
   
  +    /**
  +     * Creates <code>XMLReader</code> object using default
  +     * <code>SAXParserFactory</code>
  +     * @return the created <code>XMLReader</code>
  +     * @throws FOPException if the parser couldn't be created or configured for 
proper operation.
  +     */
  +    protected static XMLReader createParser() throws FOPException {
  +        try {
  +            SAXParserFactory factory = SAXParserFactory.newInstance();
  +            factory.setNamespaceAware(true);
  +            factory.setFeature(
  +                "http://xml.org/sax/features/namespace-prefixes";, true);
  +            return factory.newSAXParser().getXMLReader();
  +        } catch (SAXNotSupportedException se) {
  +            throw new FOPException("Error: You need a parser which allows the"
  +                   + " http://xml.org/sax/features/namespace-prefixes";
  +                   + " feature to be set to true to support namespaces", se);
  +        } catch (SAXException se) {
  +            throw new FOPException("Couldn't create XMLReader", se);
  +        } catch (ParserConfigurationException pce) {
  +            throw new FOPException("Couldn't create XMLReader", pce);
  +        }
  +    }
   
   }
   
  
  
  
  1.6       +0 -35     xml-fop/src/java/org/apache/fop/apps/InputHandler.java
  
  Index: InputHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/InputHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- InputHandler.java 27 Jul 2003 16:37:13 -0000      1.5
  +++ InputHandler.java 2 Aug 2003 01:15:20 -0000       1.6
  @@ -111,24 +111,6 @@
               throw new Error("unexpected MalformedURLException");
           }
       }
  -
  -    /**
  -     * Creates <code>XMLReader</code> object using default
  -     * <code>SAXParserFactory</code>
  -     * @return the created <code>XMLReader</code>
  -     * @throws FOPException if the parser couldn't be created or configured for 
proper operation.
  -     */
  -    protected static XMLReader createParser() throws FOPException {
  -        try {
  -            SAXParserFactory factory = SAXParserFactory.newInstance();
  -            factory.setNamespaceAware(true);
  -            return factory.newSAXParser().getXMLReader();
  -        } catch (SAXException se) {
  -            throw new FOPException("Coudn't create XMLReader", se);
  -        } catch (ParserConfigurationException pce) {
  -            throw new FOPException("Coudn't create XMLReader", pce);
  -        }
  -    }
       
       /**
        * Runs this InputHandler through the Driver.
  @@ -136,22 +118,5 @@
        * @throws FOPException if processing this InputHandler fails
        */
       public abstract void run(Driver driver) throws FOPException;
  -
  -    /**
  -     * Sets the parser features on an XMLReader
  -     * @param parser XMLReader to set features on
  -     * @throws FOPException if the XMLReader doesn't support the feature that
  -     * need to be set
  -     */
  -    public static void setParserFeatures(XMLReader parser) throws FOPException {
  -        try {
  -            parser.setFeature("http://xml.org/sax/features/namespace-prefixes";,
  -                              true);
  -        } catch (SAXException e) {
  -            throw new FOPException("Error: You need a parser which allows the"
  -                   + " http://xml.org/sax/features/namespace-prefixes";
  -                   + " feature to be set to true to support namespaces", e);
  -        }
  -    }
   }
   
  
  
  
  1.7       +1 -1      xml-fop/src/java/org/apache/fop/apps/XSLTInputHandler.java
  
  Index: XSLTInputHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/XSLTInputHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XSLTInputHandler.java     31 Jul 2003 05:14:29 -0000      1.6
  +++ XSLTInputHandler.java     2 Aug 2003 01:15:20 -0000       1.7
  @@ -170,7 +170,7 @@
                       saxTFactory.newXMLFilter(xsltSource);
   
                   // Create an XMLReader.
  -                XMLReader parser = createParser();
  +                XMLReader parser = FOInputHandler.createParser();
                   if (parser == null) {
                       throw new FOPException("Unable to create SAX parser");
                   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to