Method GetFeature
GetFeature(String)
Look up the value of a feature flag.
Declaration
bool GetFeature(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The feature name, which is a fully-qualified URI. |
Returns
Type | Description |
---|---|
System.Boolean | The current value of the feature (true or false). |
Remarks
The feature name is any fully-qualified URI. It is possible for an XMLReader to recognize a feature name but temporarily be unable to return its value. Some feature values may be available only in specific contexts, such as before, during, or after a parse. Also, some feature values may not be programmatically accessible. (In the case of an adapter for SAX1 {@link Parser}, there is no implementation-independent way to expose whether the underlying parser is performing validation, expanding external entities, and so forth.)
All XMLReaders are required to recognize the http://xml.org/sax/features/namespaces and the http://xml.org/sax/features/namespace-prefixes feature names.
Typical usage is something like this:
XMLReader r = new MySAXDriver();
// try to activate validation
try {
r.SetFeature("http://xml.org/sax/features/validation", true);
} catch (SAXException e) {
Console.Error.WriteLine("Cannot activate validation.");
}
// register event handlers
r.ContentHandler = new MyContentHandler();
r.ErrorHandler = new MyErrorHandler();
// parse the first document
try {
r.Parse("http://www.foo.com/mydoc.xml");
} catch (IOException e) {
Console.Error.WriteLine("I/O exception reading XML document");
} catch (SAXException e) {
Console.Error.WriteLine("XML exception reading document.");
}
Implementors are free (and encouraged) to invent their own features, using names built on their own URIs.
Exceptions
Type | Condition |
---|---|
SAXNotRecognizedException | If the feature value can't be assigned or retrieved. |
SAXNotSupportedException | When the IXMLReader recognizes the feature name but cannot determine its value at this time. |