public virtual bool GetFeature(string name) { if (_parent != null) { return(_parent.GetFeature(name)); } throw new SAXNotRecognizedException("Feature: " + name); }
/// <summary> /// Check and display the value of a feature. /// </summary> /// <param name="reader"></param> /// <param name="name"></param> private static void checkFeature(IXmlReader reader, String name) { try { Console.WriteLine(" " + name + " = " + reader.GetFeature(name)); } catch (SAXNotRecognizedException e) { Console.WriteLine("XMLReader does not recognize feature " + name); } catch (SAXNotSupportedException e) { Console.WriteLine("XMLReader recognizes feature " + name + " but does not support checking its value"); } }
/* IXmlReader */ /// <summary>See <see href="http://www.saxproject.org/apidoc/org/xml/sax/helpers/XMLFilterImpl.html#getFeature(java.lang.String)"> /// getFeature(java.lang.String)</see> on www.saxproject.org.</summary> /// <remarks>Difference to Java: Will throw <see cref="SaxException"/> /// if parent is <c>null</c>.</remarks> public bool GetFeature(string name) { CheckParent(); return(parent.GetFeature(name)); }
/// <summary> /// Handles the output of the results of trying to set the feature. Returns true if the /// feature can be set without exception. /// </summary> public bool TryFeature(string feature, IXmlReader parser) { int slashPos = feature.LastIndexOf('/'); string featureName = feature.Substring(slashPos + 1); try { if (!parser.GetFeature(feature)) parser.SetFeature(feature, true); writer.WriteLine(" <" + featureName + ">true</" + featureName + ">"); return true; } catch { writer.WriteLine(" <" + featureName + ">false</" + featureName + ">"); return false; } }
/// <summary> /// Handles setting the feature. /// </summary> public void SetFeature(string feature, IXmlReader parser, bool flag) { if (parser.GetFeature(feature) != flag) parser.SetFeature(feature, flag); }