예제 #1
0
        public QueryOutputWriter(XmlRawWriter writer, XmlWriterSettings settings)
        {
            _wrapped = writer;

            _systemId = settings.DocTypeSystem;
            _publicId = settings.DocTypePublic;

            if (settings.OutputMethod == XmlOutputMethod.Xml)
            {
                // Xml output method shouldn't output doc-type-decl if system ID is not defined (even if public ID is)
                // Only check for well-formed document if output method is xml
                if (_systemId != null)
                {
                    _outputDocType      = true;
                    _checkWellFormedDoc = true;
                }

                // Check for well-formed document if standalone="yes" in an auto-generated xml declaration
                if (settings.AutoXmlDeclaration && settings.Standalone == XmlStandalone.Yes)
                {
                    _checkWellFormedDoc = true;
                }

                if (settings.CDataSectionElements.Count > 0)
                {
                    _bitsCData        = new BitStack();
                    _lookupCDataElems = new Dictionary <XmlQualifiedName, int>();
                    _qnameCData       = new XmlQualifiedName();

                    // Add each element name to the lookup table
                    foreach (XmlQualifiedName name in settings.CDataSectionElements)
                    {
                        _lookupCDataElems[name] = 0;
                    }

                    _bitsCData.PushBit(false);
                }
            }
            else if (settings.OutputMethod == XmlOutputMethod.Html)
            {
                // Html output method should output doc-type-decl if system ID or public ID is defined
                if (_systemId != null || _publicId != null)
                {
                    _outputDocType = true;
                }
            }
        }