You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Brett McLaughlin <br...@newInstance.com> on 2001/04/17 04:04:18 UTC

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: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org