this patches break the testbed!!

i think the dynamic validation feature must be set ...
i'm off for today .. i will look at it tomorrow

martin


Sam Ruby wrote:

> Ping?
> 
> Turbine remains the only Apache code base which is not prepared to compile
> with Xerces 2.  (Xalan is planning on dropping the Xalan1 compatibility
> layer once Xerces 2 is announced).  A patch was provided below.  I'm
> prepared to iterate through the turbine codebases and provide similar
> patches.
> 
> - Sam Ruby
> ---------------------- Forwarded by Sam Ruby/Raleigh/IBM on 01/07/2002
> 02:47 PM ---------------------------
> 
> Sam Ruby
> 11/25/2001 07:50 PM
> 
> To:    [EMAIL PROTECTED]
> cc:
> From:  Sam Ruby/Raleigh/IBM@IBMUS
> Subject:    Getting prepared for Xerces 2...
> 
> 
> Now that Xerces 2 is in it's third beta, perhaps it is time for Turbine to
> consider pluggable parsers?  I took a stab at converting torque over to
> JAXP... diffs below.  Should work with both Xerces 1 and 2, and perhaps
> even Crimson.
> 
> It looks like virtual clones of these source files are also present in
> turbine-2, so similar techniques should work there too.
> 
> Note: gump's nightly nags are still based on Xerces 1 at the moment.  If
> you want a sneak peek at what builds under Xerces 2 will look like, check
> out http://nagoya.apache.org/~rubys/gump/xerces2/index.html
> 
> - Sam Ruby
> 
> Index: XmlToAppData.java
> ===================================================================
> RCS file: 
>/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/XmlToAppData.java,v
> retrieving revision 1.8
> diff -u -r1.8 XmlToAppData.java
> --- XmlToAppData.java   2001/09/29 01:46:30     1.8
> +++ XmlToAppData.java   2001/11/26 00:25:24
> @@ -73,8 +73,9 @@
>  import org.apache.torque.engine.database.model.Table;
>  import org.apache.torque.engine.database.model.Unique;
> 
> -import org.apache.xerces.framework.XMLParser;
> -import org.apache.xerces.parsers.SAXParser;
> +import javax.xml.parsers.ParserConfigurationException;
> +import javax.xml.parsers.SAXParser;
> +import javax.xml.parsers.SAXParserFactory;
> 
>  import org.xml.sax.Attributes;
>  import org.xml.sax.ContentHandler;
> @@ -114,6 +115,13 @@
>      private Table foreignTable;
>      private String errorMessage;
> 
> +    private static SAXParserFactory saxFactory;
> +
> +    static {
> +        saxFactory = SAXParserFactory.newInstance();
> +        saxFactory.setValidating(true);
> +    }
> +
>      /**
>       * Creates a new instance.
>       */
> @@ -163,7 +171,7 @@
>              try
>              {
>                  InputSource is = new InputSource (br);
> -                parser.parse(is);
> +                parser.parse(is, this);
>              }
>              finally
>              {
> @@ -189,23 +197,17 @@
>       * @return A validating XML parser.
>       */
>      protected SAXParser createParser()
> -        throws SAXNotRecognizedException, SAXNotSupportedException
> +        throws SAXException, ParserConfigurationException
>      {
> -        SAXParser parser = new SAXParser();
> +        SAXParser parser = saxFactory.newSAXParser();
> 
>          // We don't use an external handlers, instead implementing
>          // handler interfaces ourself.
> -        parser.setContentHandler(this);
> -        parser.setErrorHandler(this);
> +        parser.getParser().setErrorHandler(this);
> 
>          // Set the Resolver for the Torque's DTD.
>          DTDResolver dtdResolver = new DTDResolver();
> -        parser.setEntityResolver(dtdResolver);
> -
> -        // Validate the input file
> -        parser.setFeature
> -            ("http://apache.org/xml/features/validation/dynamic";, true);
> -        parser.setFeature("http://xml.org/sax/features/validation";, true);
> +        parser.getParser().setEntityResolver(dtdResolver);
> 
>          return parser;
>      }
> Index: XmlToData.java
> ===================================================================
> RCS file: 
>/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/XmlToData.java,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 XmlToData.java
> --- XmlToData.java      2001/08/02 05:08:33     1.1.1.1
> +++ XmlToData.java      2001/11/26 00:25:24
> @@ -65,11 +65,14 @@
>  import java.net.URL;
>  import java.util.List;
>  import java.util.Vector;
> +
> +import javax.xml.parsers.ParserConfigurationException;
> +import javax.xml.parsers.SAXParser;
> +import javax.xml.parsers.SAXParserFactory;
> +
>  import org.apache.torque.engine.database.model.Column;
>  import org.apache.torque.engine.database.model.Database;
>  import org.apache.torque.engine.database.model.Table;
> -import org.apache.xerces.framework.XMLParser;
> -import org.apache.xerces.parsers.SAXParser;
>  import org.xml.sax.Attributes;
>  import org.xml.sax.ContentHandler;
>  import org.xml.sax.EntityResolver;
> @@ -99,6 +102,13 @@
>      private File dtdFile;
>      private InputSource dataDTD;
> 
> +    private static SAXParserFactory saxFactory;
> +
> +    static {
> +        saxFactory = SAXParserFactory.newInstance();
> +        saxFactory.setValidating(true);
> +    }
> +
>      /**
>       * Default custructor
>       */
> @@ -122,27 +132,20 @@
>          {
>              data = new Vector();
> 
> -            SAXParser parser = new SAXParser();
> +            SAXParser parser = saxFactory.newSAXParser();
> 
>              // set the Resolver for the DTD
> -            parser.setEntityResolver(this);
> +            parser.getParser().setEntityResolver(this);
> 
>              // We don't use an external content handler - we use this object
> -            parser.setContentHandler(this);
> -
> -            // Validate the input file
> -            parser.setFeature
> -                ("http://apache.org/xml/features/validation/dynamic";, true);
> -            parser.setFeature("http://xml.org/sax/features/validation";, true);
> -
> -            parser.setErrorHandler(this);
> +            parser.getParser().setErrorHandler(this);
> 
>              FileReader fr = new FileReader (xmlFile);
>              BufferedReader br = new BufferedReader (fr);
>              try
>              {
>                  InputSource is = new InputSource (br);
> -                parser.parse(is);
> +                parser.parse(is, this);
>              }
>              finally
>              {
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 
> 




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

Reply via email to