Init() private method

private Init ( string name, string ns ) : void
name string
ns string
return void
Ejemplo n.º 1
0
        /// <summary>
        /// Output doc-type-decl on the first element, and determine whether this element is a
        /// CData section element.
        /// </summary>
        public override void WriteStartElement(string prefix, string localName, string ns)
        {
            EndCDataSection();

            // Output doc-type declaration immediately before first element is output
            if (_outputDocType)
            {
                WriteState ws = _wrapped.WriteState;
                if (ws == WriteState.Start || ws == WriteState.Prolog)
                {
                    _wrapped.WriteDocType(
                        prefix.Length != 0 ? prefix + ":" + localName : localName,
                        _publicId,
                        _systemId,
                        null);
                }
                _outputDocType = false;
            }

            _wrapped.WriteStartElement(prefix, localName, ns);

            if (_lookupCDataElems != null)
            {
                // Determine whether this element is a CData section element
                _qnameCData.Init(localName, ns);
                _bitsCData.PushBit(_lookupCDataElems.ContainsKey(_qnameCData));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Check well-formedness, possibly output doc-type-decl, and determine whether this element is a
        /// CData section element.
        /// </summary>
        public override void WriteStartElement(string prefix, string localName, string ns)
        {
            EndCDataSection();

            if (_checkWellFormedDoc)
            {
                // Don't allow multiple document elements
                if (_depth == 0 && _hasDocElem)
                {
                    throw new XmlException(SR.Xml_NoMultipleRoots, string.Empty);
                }

                _depth++;
                _hasDocElem = true;
            }

            // Output doc-type declaration immediately before first element is output
            if (_outputDocType)
            {
                _wrapped.WriteDocType(
                    prefix.Length != 0 ? prefix + ":" + localName : localName,
                    _publicId,
                    _systemId,
                    null);

                _outputDocType = false;
            }

            _wrapped.WriteStartElement(prefix, localName, ns);

            if (_lookupCDataElems != null)
            {
                // Determine whether this element is a CData section element
                _qnameCData.Init(localName, ns);
                _bitsCData.PushBit(_lookupCDataElems.ContainsKey(_qnameCData));
            }
        }