Hi Brett,

     I tried your code fragment, but couldn't reproduce your error.  I
couldn't see anything obviously wrong, but my threshold for what is obvious
is probably higher than that of some of the others on this mailing list.

     Could I ask you to try inserting the following lines in your "catch"
clauses, and to let us know the results?  That should help pinpoint where
things are going wrong.

        System.out.println("msg:  "+e.getMessage());
        e.printStackTrace();

Thanks,

Henry
------------------------------------------------------------------------
Henry Zongaro      XML Parsers development
IBM SWS Toronto Lab   Tie Line 778-6044;  Phone (416) 448-6044
mailto:[EMAIL PROTECTED]


"Brett McLaughlin" <[EMAIL PROTECTED]> on 2001/04/16 10:04:18 PM

Please respond to [EMAIL PROTECTED]

To:   <[EMAIL PROTECTED]>
cc:
Subject:  Features in xerces


I'm having some weird behavior trying to set features on an instance of an
XMLReader, created with the org.apache.xerces.parsers.SAXParser class, and
would love some clarification.

Here's the relevant code fragment:

        String featureURI = "";

        try {
            // Create instances needed for parsing
            XMLReader reader =
                XMLReaderFactory.createXMLReader(vendorParserClass);
            ContentHandler jTreeContentHandler =
                new JTreeContentHandler(treeModel, base, reader);
            ErrorHandler jTreeErrorHandler = new JTreeErrorHandler();

            // Register content handler
            reader.setContentHandler(jTreeContentHandler);

            // Register error handler
            reader.setErrorHandler(jTreeErrorHandler);

            /** Deal with features **/
            featureURI = "http://xml.org/sax/features/validation";;

            // Request validation
            reader.setFeature(featureURI, true);

            // Namespace processing - on
            featureURI = "http://xml.org/sax/features/namespaces";;
            setNamespaceProcessing(reader, true);

            // Turn off schema processing
            featureURI =
                "http://apache.org/xml/features/validation/schema";;
            reader.setFeature(featureURI, false);

            // Parse
            InputSource inputSource =
                new InputSource(xmlURI);
            reader.parse(inputSource);
        } catch (SAXNotRecognizedException e) {
            System.out.println("The parser class " + vendorParserClass +
                " does not recognize the feature URI " + featureURI);
            System.exit(0);
        } catch (SAXNotSupportedException e) {
            System.out.println("The parser class " + vendorParserClass +
                " does not support the feature URI " + featureURI);
            System.exit(0);
        }

In this code, vendorParserClass is set to the value
org.apache.xerces.parsers.SAXParser, and it works great without any
features. However, each of these features triggers an error (commenting out
one generates an error on the next):

The parser class org.apache.xerces.parsers.SAXParser does not support the
featur
e URI http://apache.org/xml/features/validation/schema

Any ideas on what's going on? I'm using Xerces 1.3.0.

Thanks,
Brett


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

Reply via email to