private readonly Schema _schema; // schema to which this belongs /// <summary> /// Construct an ElementType: /// but it's better to use Schema.element() instead. /// The content model, member-of, and flags vectors are specified as ints. /// </summary> /// <param name="name"> /// The element type name /// </param> /// <param name="model"> /// ORed-together bits representing the content models /// allowed in the content of this element type /// </param> /// <param name="memberOf"> /// ORed-together bits representing the content models /// to which this element type belongs /// </param> /// <param name="flags"> /// ORed-together bits representing the flags associated /// with this element type /// </param> /// <param name="schema"> /// The schema with which this element type will be /// associated /// </param> public ElementType(string name, int model, int memberOf, int flags, Schema schema) { _name = name; Model = model; MemberOf = memberOf; Flags = flags; _atts = new Attributes(); _schema = schema; _namespace = GetNamespace(name, false); _localName = GetLocalName(name); }
// Sets up instance variables that haven't been set by setFeature private void Setup() { if (_schema == null) { _schema = new HTMLSchema(); } if (_scanner == null) { _scanner = new HTMLScanner(); } if (_autoDetector == null) { _autoDetector = new AutoDetectorDelegate(stream => new StreamReader(stream)); } _stack = new Element(_schema.GetElementType("<root>"), _defaultAttributes); _pcdata = new Element(_schema.GetElementType("<pcdata>"), _defaultAttributes); _newElement = null; _attributeName = null; _piTarget = null; _saved = null; _entity = 0; _virginStack = true; _doctypeName = _doctypePublicId = _doctypeSystemId = null; }
public void SetProperty(string name, object value) { if (name.Equals(LEXICAL_HANDLER_PROPERTY)) { if (value == null) { _lexicalHandler = this; } else { var handler = value as ILexicalHandler; if (handler != null) { _lexicalHandler = handler; } else { throw new SAXNotSupportedException("Your lexical handler is not a ILexicalHandler"); } } } else if (name.Equals(SCANNER_PROPERTY)) { var scanner = value as IScanner; if (scanner != null) { _scanner = scanner; } else { throw new SAXNotSupportedException("Your scanner is not a IScanner"); } } else if (name.Equals(SCHEMA_PROPERTY)) { var schema = value as Schema; if (schema != null) { _schema = schema; } else { throw new SAXNotSupportedException("Your schema is not a Schema"); } } else if (name.Equals(AUTO_DETECTOR_PROPERTY)) { var detector = value as IAutoDetector; if (detector != null) { _autoDetector = detector; } else { throw new SAXNotSupportedException("Your auto-detector is not an IAutoDetector"); } } else { throw new SAXNotRecognizedException("Unknown property " + name); } }