public QueryOutputWriterV1(XmlWriter writer, XmlWriterSettings settings)
        {
            _wrapped = writer;

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

            if (settings.OutputMethod == XmlOutputMethod.Xml)
            {
                bool documentConformance = false;

                // 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)
                {
                    documentConformance = true;
                    _outputDocType = true;
                }

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

                if (documentConformance)
                {
                    if (settings.Standalone == XmlStandalone.Yes)
                    {
                        _wrapped.WriteStartDocument(true);
                    }
                    else
                    {
                        _wrapped.WriteStartDocument();
                    }
                }

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

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

                    _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;
            }
        }
        private async Task WriteStartDocumentImplAsync(XmlStandalone standalone)
        {
            try {
                await AdvanceStateAsync(Token.StartDocument).ConfigureAwait(false);

                if (conformanceLevel == ConformanceLevel.Auto)
                {
                    conformanceLevel = ConformanceLevel.Document;
                    stateTable       = StateTableDocument;
                }
                else if (conformanceLevel == ConformanceLevel.Fragment)
                {
                    throw new InvalidOperationException(Res.GetString(Res.Xml_CannotStartDocumentOnFragment));
                }

                if (rawWriter != null)
                {
                    if (!xmlDeclFollows)
                    {
                        await rawWriter.WriteXmlDeclarationAsync(standalone).ConfigureAwait(false);
                    }
                }
                else
                {
                    // We do not pass the standalone value here - Dev10 Bug #479769
                    await writer.WriteStartDocumentAsync().ConfigureAwait(false);
                }
            }
            catch {
                currentState = State.Error;
                throw;
            }
        }
        //
        // Private methods
        //
        private void Initialize()
        {
            _encoding                = Encoding.UTF8;
            _omitXmlDecl             = false;
            _newLineHandling         = NewLineHandling.Replace;
            _newLineChars            = Environment.NewLine; // "\r\n" on Windows, "\n" on Unix
            _indent                  = TriState.Unknown;
            _indentChars             = "  ";
            _newLineOnAttributes     = false;
            _closeOutput             = false;
            _namespaceHandling       = NamespaceHandling.Default;
            _conformanceLevel        = ConformanceLevel.Document;
            _checkCharacters         = true;
            _writeEndDocumentOnClose = true;

            _outputMethod = XmlOutputMethod.Xml;
            _cdataSections.Clear();
            _mergeCDataSections       = false;
            _mediaType                = null;
            _docTypeSystem            = null;
            _docTypePublic            = null;
            _standalone               = XmlStandalone.Omit;
            _doNotEscapeUriAttributes = false;

            _useAsync   = false;
            _isReadOnly = false;
        }
Beispiel #4
0
//
// Private methods
//
        void Initialize()
        {
            encoding                = Encoding.UTF8;
            omitXmlDecl             = false;
            newLineHandling         = NewLineHandling.Replace;
            newLineChars            = Environment.NewLine; // "\r\n" on Windows, "\n" on Unix
            indent                  = TriState.Unknown;
            indentChars             = "  ";
            newLineOnAttributes     = false;
            closeOutput             = false;
            namespaceHandling       = NamespaceHandling.Default;
            conformanceLevel        = ConformanceLevel.Document;
            checkCharacters         = true;
            writeEndDocumentOnClose = true;

#if !SILVERLIGHT
            outputMethod = XmlOutputMethod.Xml;
            cdataSections.Clear();
            mergeCDataSections       = false;
            mediaType                = null;
            docTypeSystem            = null;
            docTypePublic            = null;
            standalone               = XmlStandalone.Omit;
            doNotEscapeUriAttributes = false;
#endif

#if ASYNC || FEATURE_NETCORE
            useAsync = false;
#endif
            isReadOnly = false;
        }
        // Write the xml declaration.  This must be the first call.  
        internal override async Task WriteXmlDeclarationAsync( XmlStandalone standalone ) {
            CheckAsyncCall();
            // Output xml declaration only if user allows it and it was not already output
            if ( !omitXmlDeclaration && !autoXmlDeclaration ) {

                if ( trackTextContent && inTextContent != false ) { ChangeTextContentMark( false ); }

                await RawTextAsync( "<?xml version=\"" ).ConfigureAwait(false);

                // Version
                await RawTextAsync( "1.0" ).ConfigureAwait(false);

                // Encoding
                if ( encoding != null ) {
                    await RawTextAsync( "\" encoding=\"" ).ConfigureAwait(false);
                    await RawTextAsync( encoding.WebName ).ConfigureAwait(false);
                }

                // Standalone
                if ( standalone != XmlStandalone.Omit ) {
                    await RawTextAsync( "\" standalone=\"" ).ConfigureAwait(false);
                    await RawTextAsync( standalone == XmlStandalone.Yes ? "yes" : "no" ).ConfigureAwait(false);
                }

                await RawTextAsync( "\"?>" ).ConfigureAwait(false);
            }
        }
Beispiel #6
0
        private async Task WriteStartDocumentImplAsync(XmlStandalone standalone)
        {
            try
            {
                await AdvanceStateAsync(Token.StartDocument).ConfigureAwait(false);

                if (_conformanceLevel == ConformanceLevel.Auto)
                {
                    _conformanceLevel = ConformanceLevel.Document;
                    _stateTable       = s_stateTableDocument;
                }
                else if (_conformanceLevel == ConformanceLevel.Fragment)
                {
                    throw new InvalidOperationException(SR.Xml_CannotStartDocumentOnFragment);
                }

                if (_rawWriter != null)
                {
                    if (!_xmlDeclFollows)
                    {
                        await _rawWriter.WriteXmlDeclarationAsync(standalone).ConfigureAwait(false);
                    }
                }
                else
                {
                    // We do not pass the standalone value here
                    await _writer.WriteStartDocumentAsync().ConfigureAwait(false);
                }
            }
            catch
            {
                _currentState = State.Error;
                throw;
            }
        }
Beispiel #7
0
 internal override void WriteXmlDeclaration(XmlStandalone standalone)
 {
     VerifyState(Method.WriteXmlDeclaration);
     if (standalone != XmlStandalone.Omit)
     {
         XmlNode node = _document.CreateXmlDeclaration("1.0", string.Empty, standalone == XmlStandalone.Yes ? "yes" : "no");
         AddChild(node, _write);
     }
 }
Beispiel #8
0
 public QueryOutputWriterV1(XmlWriter writer, XmlWriterSettings settings)
 {
     this.wrapped  = writer;
     this.systemId = settings.DocTypeSystem;
     this.publicId = settings.DocTypePublic;
     if (settings.OutputMethod == XmlOutputMethod.Xml)
     {
         bool flag = false;
         if (this.systemId != null)
         {
             flag = true;
             this.outputDocType = true;
         }
         if (settings.Standalone == XmlStandalone.Yes)
         {
             flag            = true;
             this.standalone = settings.Standalone;
         }
         if (flag)
         {
             if (settings.Standalone == XmlStandalone.Yes)
             {
                 this.wrapped.WriteStartDocument(true);
             }
             else
             {
                 this.wrapped.WriteStartDocument();
             }
         }
         if ((settings.CDataSectionElements != null) && (settings.CDataSectionElements.Count > 0))
         {
             this.bitsCData        = new BitStack();
             this.lookupCDataElems = new Dictionary <XmlQualifiedName, XmlQualifiedName>();
             this.qnameCData       = new XmlQualifiedName();
             foreach (XmlQualifiedName name in settings.CDataSectionElements)
             {
                 this.lookupCDataElems[name] = null;
             }
             this.bitsCData.PushBit(false);
         }
     }
     else if ((settings.OutputMethod == XmlOutputMethod.Html) && ((this.systemId != null) || (this.publicId != null)))
     {
         this.outputDocType = true;
     }
 }
 public QueryOutputWriterV1(XmlWriter writer, XmlWriterSettings settings)
 {
     this.wrapped = writer;
     this.systemId = settings.DocTypeSystem;
     this.publicId = settings.DocTypePublic;
     if (settings.OutputMethod == XmlOutputMethod.Xml)
     {
         bool flag = false;
         if (this.systemId != null)
         {
             flag = true;
             this.outputDocType = true;
         }
         if (settings.Standalone == XmlStandalone.Yes)
         {
             flag = true;
             this.standalone = settings.Standalone;
         }
         if (flag)
         {
             if (settings.Standalone == XmlStandalone.Yes)
             {
                 this.wrapped.WriteStartDocument(true);
             }
             else
             {
                 this.wrapped.WriteStartDocument();
             }
         }
         if ((settings.CDataSectionElements != null) && (settings.CDataSectionElements.Count > 0))
         {
             this.bitsCData = new BitStack();
             this.lookupCDataElems = new Dictionary<XmlQualifiedName, XmlQualifiedName>();
             this.qnameCData = new XmlQualifiedName();
             foreach (XmlQualifiedName name in settings.CDataSectionElements)
             {
                 this.lookupCDataElems[name] = null;
             }
             this.bitsCData.PushBit(false);
         }
     }
     else if ((settings.OutputMethod == XmlOutputMethod.Html) && ((this.systemId != null) || (this.publicId != null)))
     {
         this.outputDocType = true;
     }
 }
Beispiel #10
0
 internal override void WriteXmlDeclaration(XmlStandalone standalone)
 {
     if (!this.omitXmlDeclaration && !this.autoXmlDeclaration)
     {
         this.RawText("<?xml version=\"");
         this.RawText("1.0");
         if (this.encoding != null)
         {
             this.RawText("\" encoding=\"");
             this.RawText(this.encoding.WebName);
         }
         if (standalone != XmlStandalone.Omit)
         {
             this.RawText("\" standalone=\"");
             this.RawText((standalone == XmlStandalone.Yes) ? "yes" : "no");
         }
         this.RawText("\"?>");
     }
 }
Beispiel #11
0
 protected XmlUtf8RawTextWriter(XmlWriterSettings settings)
 {
     this.xmlCharType        = XmlCharType.Instance;
     this.bufPos             = 1;
     this.textPos            = 1;
     this.bufLen             = 0x1800;
     this.newLineHandling    = settings.NewLineHandling;
     this.omitXmlDeclaration = settings.OmitXmlDeclaration;
     this.newLineChars       = settings.NewLineChars;
     this.checkCharacters    = settings.CheckCharacters;
     this.closeOutput        = settings.CloseOutput;
     this.standalone         = settings.Standalone;
     this.outputMethod       = settings.OutputMethod;
     this.mergeCDataSections = settings.MergeCDataSections;
     if (this.checkCharacters && (this.newLineHandling == NewLineHandling.Replace))
     {
         this.ValidateContentChars(this.newLineChars, "NewLineChars", false);
     }
 }
 protected XmlEncodedRawTextWriter(XmlWriterSettings settings)
 {
     this.xmlCharType = XmlCharType.Instance;
     this.bufPos = 1;
     this.textPos = 1;
     this.bufLen = 0x1800;
     this.newLineHandling = settings.NewLineHandling;
     this.omitXmlDeclaration = settings.OmitXmlDeclaration;
     this.newLineChars = settings.NewLineChars;
     this.checkCharacters = settings.CheckCharacters;
     this.closeOutput = settings.CloseOutput;
     this.standalone = settings.Standalone;
     this.outputMethod = settings.OutputMethod;
     this.mergeCDataSections = settings.MergeCDataSections;
     if (this.checkCharacters && (this.newLineHandling == NewLineHandling.Replace))
     {
         this.ValidateContentChars(this.newLineChars, "NewLineChars", false);
     }
 }
 private void Initialize()
 {
     this.encoding            = System.Text.Encoding.UTF8;
     this.omitXmlDecl         = false;
     this.newLineHandling     = System.Xml.NewLineHandling.Replace;
     this.newLineChars        = Environment.NewLine;
     this.indent              = TriState.Unknown;
     this.indentChars         = "  ";
     this.newLineOnAttributes = false;
     this.closeOutput         = false;
     this.namespaceHandling   = System.Xml.NamespaceHandling.Default;
     this.conformanceLevel    = System.Xml.ConformanceLevel.Document;
     this.checkCharacters     = true;
     this.outputMethod        = XmlOutputMethod.Xml;
     this.cdataSections.Clear();
     this.mergeCDataSections = false;
     this.mediaType          = null;
     this.docTypeSystem      = null;
     this.docTypePublic      = null;
     this.standalone         = XmlStandalone.Omit;
     this.isReadOnly         = false;
 }
Beispiel #14
0
//
// Public methods
//
        public void Reset()
        {
            encoding            = Encoding.UTF8;
            omitXmlDecl         = false;
            newLineHandling     = NewLineHandling.Replace;
            newLineChars        = "\r\n";
            indent              = TriState.Unknown;
            indentChars         = "  ";
            newLineOnAttributes = false;
            closeOutput         = false;

            conformanceLevel = ConformanceLevel.Document;
            checkCharacters  = true;

            outputMethod       = XmlOutputMethod.Xml;
            cdataSections      = null;
            mergeCDataSections = false;
            mediaType          = null;
            docTypeSystem      = null;
            docTypePublic      = null;
            standalone         = XmlStandalone.Omit;

            isReadOnly = false;
        }
Beispiel #15
0
 internal override void WriteXmlDeclaration(XmlStandalone standalone)
 {
     this.AddEvent(XmlEventType.XmlDecl1, standalone);
 }
//
// Public methods
//
        public void Reset() {
            encoding = Encoding.UTF8;
            omitXmlDecl = false;
            newLineHandling = NewLineHandling.Replace;
            newLineChars = "\r\n";
            indent = TriState.Unknown;
            indentChars = "  ";
            newLineOnAttributes = false;
            closeOutput = false;

            conformanceLevel = ConformanceLevel.Document;
            checkCharacters = true;

            outputMethod = XmlOutputMethod.Xml;
            cdataSections = null;
            mergeCDataSections = false;
            mediaType = null;
            docTypeSystem = null;
            docTypePublic = null;
            standalone = XmlStandalone.Omit;

            isReadOnly = false;
        }
 internal override void WriteXmlDeclaration(XmlStandalone standalone)
 {
     this.EnsureWrappedWriter(XmlOutputMethod.Xml);
     this.wrapped.WriteXmlDeclaration(standalone);
 }
        // Write the xml declaration.  This must be the first call.  
        internal override void WriteXmlDeclaration( XmlStandalone standalone ) {
            // Output xml declaration only if user allows it and it was not already output
            if ( !omitXmlDeclaration && !autoXmlDeclaration ) {

                if ( trackTextContent && inTextContent != false ) { ChangeTextContentMark( false ); }

                RawText( "<?xml version=\"" );

                // Version
                RawText( "1.0" );

                // Encoding
                if ( encoding != null ) {
                    RawText( "\" encoding=\"" );
                    RawText( encoding.WebName );
                }

                // Standalone
                if ( standalone != XmlStandalone.Omit ) {
                    RawText( "\" standalone=\"" );
                    RawText( standalone == XmlStandalone.Yes ? "yes" : "no" );
                }

                RawText( "\"?>" );
            }
        }
Beispiel #19
0
        //
        // XmlRawWriter methods and properties
        //

        // Write the xml declaration.  This must be the first call.
        internal virtual Task WriteXmlDeclarationAsync(XmlStandalone standalone)
        {
            return(AsyncHelper.DoneTask);
        }
 /// <summary>
 /// Write the xml declaration.  This must be the first call.
 /// </summary>
 internal override void WriteXmlDeclaration(XmlStandalone standalone) {
     this.wrapped.WriteXmlDeclaration(standalone);
 }
 internal virtual Task WriteXmlDeclarationAsync(XmlStandalone standalone) {
     throw new NotImplementedException(); 
 }
Beispiel #22
0
 internal override void WriteXmlDeclaration(XmlStandalone standalone)
 {
     // Forces xml writer to be created
     EnsureWrappedWriter(XmlOutputMethod.Xml);
     _wrapped.WriteXmlDeclaration(standalone);
 }
        private void WriteStartDocumentImpl(XmlStandalone standalone) {
            try {
                AdvanceState(Token.StartDocument);

                if (conformanceLevel == ConformanceLevel.Auto) {
                    conformanceLevel = ConformanceLevel.Document;
                    stateTable = StateTableDocument;
                }
                else if (conformanceLevel == ConformanceLevel.Fragment) {
                    throw new InvalidOperationException(Res.GetString(Res.Xml_CannotStartDocumentOnFragment));
                }

                if (rawWriter != null) {
                    if (!xmlDeclFollows) {
                        rawWriter.WriteXmlDeclaration(standalone);
                    }
                }
                else {
                    // We do not pass the standalone value here - Dev10 Bug #479769
                    writer.WriteStartDocument();
                }
            }
            catch {
                currentState = State.Error;
                throw;
            }
        }
Beispiel #24
0
        //-----------------------------------------------
        // XmlRawWriter interface
        //-----------------------------------------------

        /// <summary>
        /// Write the xml declaration.  This must be the first call after Open.
        /// </summary>
        internal override void WriteXmlDeclaration(XmlStandalone standalone)
        {
            // Ignore the xml declaration when building the cache
        }
Beispiel #25
0
 internal abstract void WriteXmlDeclaration(XmlStandalone standalone);
        // Write the xml declaration.  This must be the first call.  
        internal override void WriteXmlDeclaration( XmlStandalone standalone ) {
            // Output xml declaration only if user allows it and it was not already output
            if ( !omitXmlDeclaration && !autoXmlDeclaration ) {

                

                RawText( "<?xml version=\"" );

                // Version
                RawText( "1.0" );

                // Encoding
                if ( encoding != null ) {
                    RawText( "\" encoding=\"" );
                    RawText( ( encoding.CodePage == 1201 ) ? "UTF-16BE" : encoding.WebName );
                }

                // Standalone
                if ( standalone != XmlStandalone.Omit ) {
                    RawText( "\" standalone=\"" );
                    RawText( standalone == XmlStandalone.Yes ? "yes" : "no" );
                }

                RawText( "\"?>" );
            }
        }
//
// Constructors
//
        // Construct and initialize an instance of this class.
        protected XmlUtf8RawTextWriter( XmlWriterSettings settings, bool closeOutput ) {
            // copy settings
            newLineHandling = settings.NewLineHandling;
            omitXmlDeclaration = settings.OmitXmlDeclaration;
            newLineChars = settings.NewLineChars;
            standalone = settings.Standalone;
            outputMethod = settings.OutputMethod;
            checkCharacters = settings.CheckCharacters;
            mergeCDataSections = settings.MergeCDataSections;
            this.closeOutput = closeOutput;

            if ( checkCharacters && newLineHandling == NewLineHandling.Replace ) {
                ValidateContentChars( newLineChars, "NewLineChars", false );
            }
        }
        //-----------------------------------------------
        // XmlRawWriter interface
        //-----------------------------------------------

        /// <summary>
        /// Write the xml declaration.  This must be the first call after Open.
        /// </summary>
        internal override void WriteXmlDeclaration(XmlStandalone standalone)
        {
            // Ignore the xml declaration when building the cache
        }
Beispiel #29
0
 internal override void WriteXmlDeclaration(XmlStandalone standalone)
 {
     VerifyState(Method.WriteXmlDeclaration);
     if (standalone != XmlStandalone.Omit)
     {
         XmlNode node = _document.CreateXmlDeclaration("1.0", string.Empty, standalone == XmlStandalone.Yes ? "yes" : "no");
         AddChild(node, _write);
     }
 }
        private void WriteStartDocumentImpl(XmlStandalone standalone)
        {
            try
            {
                AdvanceState(Token.StartDocument);

                if (_conformanceLevel == ConformanceLevel.Auto)
                {
                    _conformanceLevel = ConformanceLevel.Document;
                    _stateTable = s_stateTableDocument;
                }
                else if (_conformanceLevel == ConformanceLevel.Fragment)
                {
                    throw new InvalidOperationException(SR.Xml_CannotStartDocumentOnFragment);
                }

                if (_rawWriter != null)
                {
                    if (!_xmlDeclFollows)
                    {
                        _rawWriter.WriteXmlDeclaration(standalone);
                    }
                }
                else
                {
                    // We do not pass the standalone value here
                    _writer.WriteStartDocument();
                }
            }
            catch
            {
                _currentState = State.Error;
                throw;
            }
        }
 private void WriteStartDocumentImpl(XmlStandalone standalone)
 {
     try
     {
         this.AdvanceState(Token.StartDocument);
         if (this.conformanceLevel == ConformanceLevel.Auto)
         {
             this.conformanceLevel = ConformanceLevel.Document;
             this.stateTable = StateTableDocument;
         }
         else if (this.conformanceLevel == ConformanceLevel.Fragment)
         {
             throw new InvalidOperationException(Res.GetString("Xml_CannotStartDocumentOnFragment"));
         }
         if (this.rawWriter != null)
         {
             if (!this.xmlDeclFollows)
             {
                 this.rawWriter.WriteXmlDeclaration(standalone);
             }
         }
         else
         {
             this.writer.WriteStartDocument();
         }
     }
     catch
     {
         this.currentState = State.Error;
         throw;
     }
 }
Beispiel #32
0
        //-----------------------------------------------
        // XmlRawWriter interface
        //-----------------------------------------------

        internal override void WriteXmlDeclaration(XmlStandalone standalone) {
            AddEvent(XmlEventType.XmlDecl1, (object) standalone);
        }
//
// XmlRawWriter methods and properties
//

        // Write the xml declaration.  This must be the first call.
#if !SILVERLIGHT || ASYNC // This code is not being hit in Silverlight, but is used on desktop and in CoreSys builds.
        internal virtual Task WriteXmlDeclarationAsync( XmlStandalone standalone ) {

            return AsyncHelper.DoneTask;

        }
Beispiel #34
0
        //
        // Private methods
        //
        private void Initialize()
        {
            _encoding = Encoding.UTF8;
            _omitXmlDecl = false;
            _newLineHandling = NewLineHandling.Replace;
            _newLineChars = Environment.NewLine; // "\r\n" on Windows, "\n" on Unix
            _indent = TriState.Unknown;
            _indentChars = "  ";
            _newLineOnAttributes = false;
            _closeOutput = false;
            _namespaceHandling = NamespaceHandling.Default;
            _conformanceLevel = ConformanceLevel.Document;
            _checkCharacters = true;
            _writeEndDocumentOnClose = true;

            _outputMethod = XmlOutputMethod.Xml;
            _cdataSections.Clear();
            _mergeCDataSections = false;
            _mediaType = null;
            _docTypeSystem = null;
            _docTypePublic = null;
            _standalone = XmlStandalone.Omit;
            _doNotEscapeUriAttributes = false;

            _useAsync = false;
            _isReadOnly = false;
        }
//
// Constructors
//
        // Construct and initialize an instance of this class.
        protected XmlEncodedRawTextWriter( XmlWriterSettings settings ) {

#if ASYNC
            useAsync = settings.Async;
#endif

            // copy settings
            newLineHandling = settings.NewLineHandling;
            omitXmlDeclaration = settings.OmitXmlDeclaration;
            newLineChars = settings.NewLineChars;
            checkCharacters = settings.CheckCharacters;
            closeOutput = settings.CloseOutput;

            standalone = settings.Standalone;
            outputMethod = settings.OutputMethod;
            mergeCDataSections = settings.MergeCDataSections;

            if ( checkCharacters && newLineHandling == NewLineHandling.Replace ) {
                ValidateContentChars( newLineChars, "NewLineChars", false );
            }
        }
Beispiel #36
0
 internal virtual void WriteXmlDeclaration(XmlStandalone standalone)
 {
 }
 public int WriteStartDocument(XmlStandalone standalone)
 {
     return(((delegate * unmanaged <IXmlWriter *, XmlStandalone, int>)(lpVtbl[26]))((IXmlWriter *)Unsafe.AsPointer(ref this), standalone));
 }
 internal override void WriteXmlDeclaration(XmlStandalone standalone)
 {
     if (!this.omitXmlDeclaration && !this.autoXmlDeclaration)
     {
         if (this.trackTextContent && this.inTextContent)
         {
             this.ChangeTextContentMark(false);
         }
         this.RawText("<?xml version=\"");
         this.RawText("1.0");
         if (this.encoding != null)
         {
             this.RawText("\" encoding=\"");
             this.RawText(this.encoding.WebName);
         }
         if (standalone != XmlStandalone.Omit)
         {
             this.RawText("\" standalone=\"");
             this.RawText((standalone == XmlStandalone.Yes) ? "yes" : "no");
         }
         this.RawText("\"?>");
     }
 }
Beispiel #39
0
        // Write the xml declaration.  This must be the first call.
#if !SILVERLIGHT // This code is not being hit in Silverlight
        internal virtual void WriteXmlDeclaration( XmlStandalone standalone ) {

        }
        private async Task WriteStartDocumentImplAsync(XmlStandalone standalone) {
            try {
                await AdvanceStateAsync(Token.StartDocument).ConfigureAwait(false);

                if (conformanceLevel == ConformanceLevel.Auto) {
                    conformanceLevel = ConformanceLevel.Document;
                    stateTable = StateTableDocument;
                }
                else if (conformanceLevel == ConformanceLevel.Fragment) {
                    throw new InvalidOperationException(Res.GetString(Res.Xml_CannotStartDocumentOnFragment));
                }

                if (rawWriter != null) {
                    if (!xmlDeclFollows) {
                        await rawWriter.WriteXmlDeclarationAsync(standalone).ConfigureAwait(false);
                    }
                }
                else {
                    // We do not pass the standalone value here - Dev10 
                    await writer.WriteStartDocumentAsync().ConfigureAwait(false);
                }
            }
            catch {
                currentState = State.Error;
                throw;
            }
        }
Beispiel #41
0
        public QueryOutputWriterV1(XmlWriter writer, XmlWriterSettings settings)
        {
            this.wrapped = writer;

            this.systemId = settings.DocTypeSystem;
            this.publicId = settings.DocTypePublic;

            if (settings.OutputMethod == XmlOutputMethod.Xml)
            {
                bool documentConformance = false;

                // 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 (this.systemId != null)
                {
                    documentConformance = true;
                    this.outputDocType  = true;
                }

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

                if (documentConformance)
                {
                    if (settings.Standalone == XmlStandalone.Yes)
                    {
                        this.wrapped.WriteStartDocument(true);
                    }
                    else
                    {
                        this.wrapped.WriteStartDocument();
                    }
                }

                if (settings.CDataSectionElements != null && settings.CDataSectionElements.Count > 0)
                {
                    this.bitsCData        = new BitStack();
                    this.lookupCDataElems = new Dictionary <XmlQualifiedName, XmlQualifiedName>();
                    this.qnameCData       = new XmlQualifiedName();

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

                    this.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 (this.systemId != null || this.publicId != null)
                {
                    this.outputDocType = true;
                }
            }
        }
Beispiel #42
0
        //-----------------------------------------------
        // XmlRawWriter interface
        //-----------------------------------------------

        internal override void WriteXmlDeclaration(XmlStandalone standalone)
        {
            AddEvent(XmlEventType.XmlDecl1, (object)standalone);
        }
 /// <summary>
 /// Write the xml declaration.  This must be the first call.
 /// </summary>
 internal override void WriteXmlDeclaration(XmlStandalone standalone)
 {
     this.wrapped.WriteXmlDeclaration(standalone);
 }
//
// Private methods
//
        void Initialize() {
            encoding = Encoding.UTF8;
            omitXmlDecl = false;
            newLineHandling = NewLineHandling.Replace;
            newLineChars = Environment.NewLine; // "\r\n" on Windows, "\n" on Unix
            indent = TriState.Unknown;
            indentChars = "  ";
            newLineOnAttributes = false;
            closeOutput = false;
            namespaceHandling = NamespaceHandling.Default;
            conformanceLevel = ConformanceLevel.Document;
            checkCharacters = true;
            writeEndDocumentOnClose = true;

#if !SILVERLIGHT
            outputMethod = XmlOutputMethod.Xml;
            cdataSections.Clear();
            mergeCDataSections = false;
            mediaType = null;
            docTypeSystem = null;
            docTypePublic = null;
            standalone = XmlStandalone.Omit;
            doNotEscapeUriAttributes = false;
#endif

#if ASYNC || FEATURE_NETCORE
            useAsync = false;
#endif
            isReadOnly = false;
        }
 internal override void WriteXmlDeclaration(XmlStandalone standalone) {
     // Forces xml writer to be created
     EnsureWrappedWriter(XmlOutputMethod.Xml);
     this.wrapped.WriteXmlDeclaration(standalone);
 }
Beispiel #46
0
        //
        // XmlRawWriter methods and properties
        //

        // Write the xml declaration.  This must be the first call.
        internal virtual Task WriteXmlDeclarationAsync(XmlStandalone standalone)
        {
            return Task.CompletedTask;
        }
Beispiel #47
0
 internal virtual Task WriteXmlDeclarationAsync(XmlStandalone standalone)
 {
     return(Task.CompletedTask);
 }
 internal override void WriteXmlDeclaration(XmlStandalone standalone)
 {
     // Ignore xml declaration
 }
Beispiel #49
0
 //
 // XmlRawWriter
 //
 // Ignore Xml declaration
 internal override void WriteXmlDeclaration(XmlStandalone standalone)
 {
 }
 internal override void WriteXmlDeclaration(XmlStandalone standalone)
 {
     this.EnsureWrappedWriter(XmlOutputMethod.Xml);
     this.wrapped.WriteXmlDeclaration(standalone);
 }
Beispiel #51
0
 internal override void WriteXmlDeclaration(XmlStandalone standalone)
 {
     // Ignore xml declaration
 }
Beispiel #52
0
 internal abstract void WriteXmlDeclaration(XmlStandalone standalone);
Beispiel #53
0
        //-----------------------------------------------
        // XmlRawWriter interface
        //-----------------------------------------------

        /// <summary>
        /// No-op.
        /// </summary>
        internal override void WriteXmlDeclaration(XmlStandalone standalone)
        {
        }
Beispiel #54
0
 internal virtual Task WriteXmlDeclarationAsync(XmlStandalone standalone)
 {
     throw new NotImplementedException();
 }