예제 #1
0
        internal XmlWriter CreateWriter(TextWriter output)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }

            XmlWriter writer;

            // create raw writer
            if (this.Indent)
            {
                writer = new XmlEncodedRawTextWriterIndent(output, this);
            }
            else
            {
                writer = new XmlEncodedRawTextWriter(output, this);
            }

            // wrap with well-formed writer
            writer = new XmlWellFormedWriter(writer, this);

            if (_useAsync)
            {
                writer = new XmlAsyncCheckWriter(writer);
            }
            return(writer);
        }
예제 #2
0
        private static XmlWriter CreateWriterImpl(TextWriter output, XmlWriterSettings settings)
        {
            Debug.Assert(output != null);
            Debug.Assert(settings != null);

            XmlWriter writer;

            switch (settings.OutputMethod)
            {
            case XmlOutputMethod.Xml:
                if (settings.Indent)
                {
                    writer = new XmlEncodedRawTextWriterIndent(output, settings);
                }
                else
                {
                    writer = new XmlEncodedRawTextWriter(output, settings);
                }
                break;

            case XmlOutputMethod.Html:
                if (settings.Indent)
                {
                    writer = new HtmlEncodedRawTextWriterIndent(output, settings);
                }
                else
                {
                    writer = new HtmlEncodedRawTextWriter(output, settings);
                }
                break;

            case XmlOutputMethod.Text:
                writer = new TextEncodedRawTextWriter(output, settings);
                break;

            case XmlOutputMethod.AutoDetect:
                writer = new XmlAutoDetectWriter(output, settings);
                break;

            default:
                Debug.Assert(false, "Invalid XmlOutputMethod setting.");
                return(null);
            }

            // Wrap with Xslt/XQuery specific writer if needed;
            // XmlOutputMethod.AutoDetect writer does this lazily when it creates the underlying Xml or Html writer.
            if (settings.OutputMethod != XmlOutputMethod.AutoDetect)
            {
                if (settings.IsQuerySpecific)
                {
                    // Create QueryOutputWriter if CData sections or DocType need to be tracked
                    writer = new QueryOutputWriter((XmlRawWriter)writer, settings);
                }
            }

            writer = new XmlWellFormedWriter(writer, settings);
            return(writer);
        }
예제 #3
0
        //
        // Internal properties
        //


        internal XmlWriter CreateWriter(Stream output)
        {
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            XmlWriter writer;

            // create raw writer
            Debug.Assert(Encoding.UTF8.WebName == "utf-8");
            if (this.Encoding.WebName == "utf-8")
            { // Encoding.CodePage is not supported in Silverlight
                // create raw UTF-8 writer
                if (this.Indent)
                {
                    writer = new XmlUtf8RawTextWriterIndent(output, this);
                }
                else
                {
                    writer = new XmlUtf8RawTextWriter(output, this);
                }
            }
            else
            {
                // create raw writer for other encodings
                if (this.Indent)
                {
                    writer = new XmlEncodedRawTextWriterIndent(output, this);
                }
                else
                {
                    writer = new XmlEncodedRawTextWriter(output, this);
                }
            }

            // wrap with well-formed writer
            writer = new XmlWellFormedWriter(writer, this);

            if (_useAsync)
            {
                writer = new XmlAsyncCheckWriter(writer);
            }

            return(writer);
        }
        internal XmlWriter CreateWriter(Stream output)
        {
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            XmlWriter writer;

            // create raw writer
            Debug.Assert(Encoding.UTF8.WebName == "utf-8");
            if (this.Encoding.WebName == "utf-8")
            { // Encoding.CodePage is not supported in Silverlight
                // create raw UTF-8 writer
                switch (this.OutputMethod)
                {
                case XmlOutputMethod.Xml:
                    if (this.Indent)
                    {
                        writer = new XmlUtf8RawTextWriterIndent(output, this);
                    }
                    else
                    {
                        writer = new XmlUtf8RawTextWriter(output, this);
                    }
                    break;

                case XmlOutputMethod.Html:
                    if (this.Indent)
                    {
                        writer = new HtmlUtf8RawTextWriterIndent(output, this);
                    }
                    else
                    {
                        writer = new HtmlUtf8RawTextWriter(output, this);
                    }
                    break;

                case XmlOutputMethod.Text:
                    writer = new TextUtf8RawTextWriter(output, this);
                    break;

                case XmlOutputMethod.AutoDetect:
                    writer = new XmlAutoDetectWriter(output, this);
                    break;

                default:
                    Debug.Fail("Invalid XmlOutputMethod setting.");
                    return(null);
                }
            }
            else
            {
                // Otherwise, create a general-purpose writer than can do any encoding
                switch (this.OutputMethod)
                {
                case XmlOutputMethod.Xml:
                    if (this.Indent)
                    {
                        writer = new XmlEncodedRawTextWriterIndent(output, this);
                    }
                    else
                    {
                        writer = new XmlEncodedRawTextWriter(output, this);
                    }
                    break;

                case XmlOutputMethod.Html:
                    if (this.Indent)
                    {
                        writer = new HtmlEncodedRawTextWriterIndent(output, this);
                    }
                    else
                    {
                        writer = new HtmlEncodedRawTextWriter(output, this);
                    }
                    break;

                case XmlOutputMethod.Text:
                    writer = new TextEncodedRawTextWriter(output, this);
                    break;

                case XmlOutputMethod.AutoDetect:
                    writer = new XmlAutoDetectWriter(output, this);
                    break;

                default:
                    Debug.Fail("Invalid XmlOutputMethod setting.");
                    return(null);
                }
            }

            // Wrap with Xslt/XQuery specific writer if needed;
            // XmlOutputMethod.AutoDetect writer does this lazily when it creates the underlying Xml or Html writer.
            if (this.OutputMethod != XmlOutputMethod.AutoDetect)
            {
                if (this.IsQuerySpecific)
                {
                    // Create QueryOutputWriter if CData sections or DocType need to be tracked
                    writer = new QueryOutputWriter((XmlRawWriter)writer, this);
                }
            }

            // wrap with well-formed writer
            writer = new XmlWellFormedWriter(writer, this);

            if (_useAsync)
            {
                writer = new XmlAsyncCheckWriter(writer);
            }

            return(writer);
        }
        private XmlWriter AddConformanceWrapper(XmlWriter baseWriter) {
            ConformanceLevel confLevel = ConformanceLevel.Auto;
            XmlWriterSettings baseWriterSettings = baseWriter.Settings;
            bool checkValues = false;
            bool checkNames = false;
            bool replaceNewLines = false;
            bool needWrap = false;

            if (baseWriterSettings == null) {
                // assume the V1 writer already do all conformance checking; 
                // wrap only if NewLineHandling == Replace or CheckCharacters is true
                if (this.newLineHandling == NewLineHandling.Replace) {
                    replaceNewLines = true;
                    needWrap = true;
                }
                if (this.checkCharacters) {
                    checkValues = true;
                    needWrap = true;
                }
            }
            else {
                if (this.conformanceLevel != baseWriterSettings.ConformanceLevel) {
                    confLevel = this.ConformanceLevel;
                    needWrap = true;
                }
                if (this.checkCharacters && !baseWriterSettings.CheckCharacters) {
                    checkValues = true;
                    checkNames = confLevel == ConformanceLevel.Auto;
                    needWrap = true;
                }
                if (this.newLineHandling == NewLineHandling.Replace &&
                     baseWriterSettings.NewLineHandling == NewLineHandling.None) {
                    replaceNewLines = true;
                    needWrap = true;
                }
            }

            XmlWriter writer = baseWriter;

            if (needWrap) {
                if (confLevel != ConformanceLevel.Auto) {
                    writer = new XmlWellFormedWriter(writer, this);
                }
                if (checkValues || replaceNewLines) {
                    writer = new XmlCharCheckingWriter(writer, checkValues, checkNames, replaceNewLines, this.NewLineChars);
                }
            }

#if !SILVERLIGHT
            if (this.IsQuerySpecific && (baseWriterSettings == null || !baseWriterSettings.IsQuerySpecific)) {
                // Create QueryOutputWriterV1 if CData sections or DocType need to be tracked
                writer = new QueryOutputWriterV1(writer, this);
            }
#endif

            return writer;
        }
        internal XmlWriter CreateWriter(TextWriter output) {
            if (output == null) {
                throw new ArgumentNullException("output");
            }

            XmlWriter writer;

            // create raw writer
#if SILVERLIGHT
            if (this.Indent) {
                writer = new XmlEncodedRawTextWriterIndent(output, this);
            }
            else {
                writer = new XmlEncodedRawTextWriter(output, this);
            }
#else 
            switch (this.OutputMethod) {
                case XmlOutputMethod.Xml:
                    if (this.Indent) {
                        writer = new XmlEncodedRawTextWriterIndent(output, this);
                    }
                    else {
                        writer = new XmlEncodedRawTextWriter(output, this);
                    }
                    break;
                case XmlOutputMethod.Html:
                    if (this.Indent) {
                        writer = new HtmlEncodedRawTextWriterIndent(output, this);
                    }
                    else {
                        writer = new HtmlEncodedRawTextWriter(output, this);
                    }
                    break;
                case XmlOutputMethod.Text:
                    writer = new TextEncodedRawTextWriter(output, this);
                    break;
                case XmlOutputMethod.AutoDetect:
                    writer = new XmlAutoDetectWriter(output, this);
                    break;
                default:
                    Debug.Assert(false, "Invalid XmlOutputMethod setting.");
                    return null;
            }

            // XmlOutputMethod.AutoDetect writer does this lazily when it creates the underlying Xml or Html writer.
            if (this.OutputMethod != XmlOutputMethod.AutoDetect) {
                if (this.IsQuerySpecific) {
                    // Create QueryOutputWriter if CData sections or DocType need to be tracked
                    writer = new QueryOutputWriter((XmlRawWriter)writer, this);
                }
            }
#endif //SILVERLIGHT

            // wrap with well-formed writer
            writer = new XmlWellFormedWriter(writer, this);

#if ASYNC
            if (useAsync) {
                writer = new XmlAsyncCheckWriter(writer);
            }
#endif
            return writer;
        }
        internal XmlWriter CreateWriter(Stream output) {
            if (output == null) {
                throw new ArgumentNullException("output");
            }

            XmlWriter writer;
            
            // create raw writer
#if SILVERLIGHT
            Debug.Assert(Encoding.UTF8.WebName == "utf-8");
            if (this.Encoding.WebName == "utf-8") { // Encoding.CodePage is not supported in Silverlight
                // create raw UTF-8 writer
                if (this.Indent) {
                    writer = new XmlUtf8RawTextWriterIndent(output, this);
                }
                else {
                    writer = new XmlUtf8RawTextWriter(output, this);
                }
            }
            else {
                // create raw writer for other encodings
                if (this.Indent) {
                    writer = new XmlEncodedRawTextWriterIndent(output, this);
                }
                else {
                    writer = new XmlEncodedRawTextWriter(output, this);
                }
            }
#else
            Debug.Assert(Encoding.UTF8.WebName == "utf-8");
            if (this.Encoding.WebName == "utf-8") { // Encoding.CodePage is not supported in Silverlight
                // create raw UTF-8 writer
                switch (this.OutputMethod) {
                    case XmlOutputMethod.Xml:
                        if (this.Indent) {
                            writer = new XmlUtf8RawTextWriterIndent(output, this);
                        }
                        else {
                            writer = new XmlUtf8RawTextWriter(output, this);
                        }
                        break;
                    case XmlOutputMethod.Html:
                        if (this.Indent) {
                            writer = new HtmlUtf8RawTextWriterIndent(output, this);
                        }
                        else {
                            writer = new HtmlUtf8RawTextWriter(output, this);
                        }
                        break;
                    case XmlOutputMethod.Text:
                        writer = new TextUtf8RawTextWriter(output, this);
                        break;
                    case XmlOutputMethod.AutoDetect:
                        writer = new XmlAutoDetectWriter(output, this);
                        break;
                    default:
                        Debug.Assert(false, "Invalid XmlOutputMethod setting.");
                        return null;
                }
            }
            else {
                // Otherwise, create a general-purpose writer than can do any encoding
                switch (this.OutputMethod) {
                    case XmlOutputMethod.Xml:
                        if (this.Indent) {
                            writer = new XmlEncodedRawTextWriterIndent(output, this);
                        }
                        else {
                            writer = new XmlEncodedRawTextWriter(output, this);
                        }
                        break;
                    case XmlOutputMethod.Html:
                        if (this.Indent) {
                            writer = new HtmlEncodedRawTextWriterIndent(output, this);
                        }
                        else {
                            writer = new HtmlEncodedRawTextWriter(output, this);
                        }
                        break;
                    case XmlOutputMethod.Text:
                        writer = new TextEncodedRawTextWriter(output, this);
                        break;
                    case XmlOutputMethod.AutoDetect:
                        writer = new XmlAutoDetectWriter(output, this);
                        break;
                    default:
                        Debug.Assert(false, "Invalid XmlOutputMethod setting.");
                        return null;
                }
            }

            // Wrap with Xslt/XQuery specific writer if needed; 
            // XmlOutputMethod.AutoDetect writer does this lazily when it creates the underlying Xml or Html writer.
            if (this.OutputMethod != XmlOutputMethod.AutoDetect) {
                if (this.IsQuerySpecific) {
                    // Create QueryOutputWriter if CData sections or DocType need to be tracked
                    writer = new QueryOutputWriter((XmlRawWriter)writer, this);
                }
            }
#endif // !SILVERLIGHT

            // wrap with well-formed writer
            writer = new XmlWellFormedWriter(writer, this);

#if ASYNC
            if (useAsync) {
                writer = new XmlAsyncCheckWriter(writer);
            }
#endif

            return writer;
        }
 internal void Set(string prefix, string namespaceUri, XmlWellFormedWriter.NamespaceKind kind)
 {
     this.prefix = prefix;
     this.namespaceUri = namespaceUri;
     this.kind = kind;
     this.prevNsIndex = -1;
 }
예제 #9
0
 internal NamespaceResolverProxy(XmlWellFormedWriter wfWriter)
 {
     _wfWriter = wfWriter;
 }
예제 #10
0
        private static XmlWriter CreateWriterImpl(Stream output, Encoding encoding, bool closeOutput, XmlWriterSettings settings) {
            Debug.Assert(output != null);
            Debug.Assert(encoding != null);
            Debug.Assert(settings != null);

            XmlWriter writer;

            if (encoding.CodePage == 65001) {
                // If the encoding is UTF-8, create a special-purpose writer
                switch (settings.OutputMethod) {
                    case XmlOutputMethod.Xml:
                        if (settings.Indent) {
                            writer = new XmlUtf8RawTextWriterIndent(output, encoding, settings, closeOutput);
                        }
                        else {
                            writer = new XmlUtf8RawTextWriter(output, encoding, settings, closeOutput);
                        }
                        break;
                    case XmlOutputMethod.Html:
                        if (settings.Indent) {
                            writer = new HtmlUtf8RawTextWriterIndent(output, encoding, settings, closeOutput);
                        }
                        else {
                            writer = new HtmlUtf8RawTextWriter(output, encoding, settings, closeOutput);
                        }
                        break;
                    case XmlOutputMethod.Text:
                        writer = new TextUtf8RawTextWriter(output, encoding, settings, closeOutput);
                        break;
                    case XmlOutputMethod.AutoDetect:
                        writer = new XmlAutoDetectWriter(output, encoding, settings);
                        break;
                    default:
                        Debug.Assert(false, "Invalid XmlOutputMethod setting.");
                        return null;
                }
            }
            else {
                // Otherwise, create a general-purpose writer than can do any encoding
                switch (settings.OutputMethod) {
                    case XmlOutputMethod.Xml:
                        if (settings.Indent) {
                            writer = new XmlEncodedRawTextWriterIndent(output, encoding, settings, closeOutput);
                        }
                        else {
                            writer = new XmlEncodedRawTextWriter(output, encoding, settings, closeOutput);
                        }
                        break;
                    case XmlOutputMethod.Html:
                        if (settings.Indent) {
                            writer = new HtmlEncodedRawTextWriterIndent(output, encoding, settings, closeOutput);
                        }
                        else {
                            writer = new HtmlEncodedRawTextWriter(output, encoding, settings, closeOutput);
                        }
                        break;
                    case XmlOutputMethod.Text:
                        writer = new TextEncodedRawTextWriter(output, encoding, settings, closeOutput);
                        break;
                    case XmlOutputMethod.AutoDetect:
                        writer = new XmlAutoDetectWriter(output, encoding, settings);
                        break;
                    default:
                        Debug.Assert(false, "Invalid XmlOutputMethod2 setting.");
                        return null;
                }
            }

            // Wrap with Xslt/XQuery specific writer if needed; 
            // XmlOutputMethod.AutoDetect writer does this lazily when it creates the underlying Xml or Html writer.
            if (settings.OutputMethod != XmlOutputMethod.AutoDetect) {
                if (settings.IsQuerySpecific) {
                    // Create QueryOutputWriter if CData sections or DocType need to be tracked
                    writer = new QueryOutputWriter((XmlRawWriter)writer, settings);
                }
            }

            // wrap with well-formed writer
            writer = new XmlWellFormedWriter(writer, settings);

            return writer;
        }
예제 #11
0
        private static XmlWriter AddConformanceWrapper(XmlWriter baseWriter, XmlWriterSettings baseWriterSettings, XmlWriterSettings settings)
        {
            ConformanceLevel confLevel       = ConformanceLevel.Auto;
            bool             checkValues     = false;
            bool             checkNames      = false;
            bool             replaceNewLines = false;
            bool             needWrap        = false;

            if (baseWriterSettings == null)
            {
                // assume the V1 writer already do all conformance checking;
                // wrap only if NewLineHandling == Replace or CheckCharacters is true
                if (settings.NewLineHandling == NewLineHandling.Replace)
                {
                    replaceNewLines = true;
                    needWrap        = true;
                }
                if (settings.CheckCharacters)
                {
                    checkValues = true;
                    needWrap    = true;
                }
            }
            else
            {
                if (settings.ConformanceLevel != baseWriterSettings.ConformanceLevel)
                {
                    confLevel = settings.ConformanceLevel;
                    needWrap  = true;
                }
                if (settings.CheckCharacters && !baseWriterSettings.CheckCharacters)
                {
                    checkValues = true;
                    checkNames  = confLevel == ConformanceLevel.Auto;
                    needWrap    = true;
                }
                if (settings.NewLineHandling == NewLineHandling.Replace &&
                    baseWriterSettings.NewLineHandling == NewLineHandling.None)
                {
                    replaceNewLines = true;
                    needWrap        = true;
                }
            }

            if (needWrap)
            {
                XmlWriter writer = baseWriter;
                if (confLevel != ConformanceLevel.Auto)
                {
                    writer = new XmlWellFormedWriter(writer, settings);
                }
                if (checkValues || replaceNewLines)
                {
                    writer = new XmlCharCheckingWriter(writer, checkValues, checkNames, replaceNewLines, settings.NewLineChars);
                }
                return(writer);
            }
            else
            {
                return(baseWriter);
            }
        }
예제 #12
0
        private static XmlWriter CreateWriterImpl(Stream output, Encoding encoding, bool closeOutput, XmlWriterSettings settings)
        {
            Debug.Assert(output != null);
            Debug.Assert(encoding != null);
            Debug.Assert(settings != null);

            XmlWriter writer;

            if (encoding.CodePage == 65001)
            {
                // If the encoding is UTF-8, create a special-purpose writer
                switch (settings.OutputMethod)
                {
                case XmlOutputMethod.Xml:
                    if (settings.Indent)
                    {
                        writer = new XmlUtf8RawTextWriterIndent(output, encoding, settings, closeOutput);
                    }
                    else
                    {
                        writer = new XmlUtf8RawTextWriter(output, encoding, settings, closeOutput);
                    }
                    break;

                case XmlOutputMethod.Html:
                    if (settings.Indent)
                    {
                        writer = new HtmlUtf8RawTextWriterIndent(output, encoding, settings, closeOutput);
                    }
                    else
                    {
                        writer = new HtmlUtf8RawTextWriter(output, encoding, settings, closeOutput);
                    }
                    break;

                case XmlOutputMethod.Text:
                    writer = new TextUtf8RawTextWriter(output, encoding, settings, closeOutput);
                    break;

                case XmlOutputMethod.AutoDetect:
                    writer = new XmlAutoDetectWriter(output, encoding, settings);
                    break;

                default:
                    Debug.Assert(false, "Invalid XmlOutputMethod setting.");
                    return(null);
                }
            }
            else
            {
                // Otherwise, create a general-purpose writer than can do any encoding
                switch (settings.OutputMethod)
                {
                case XmlOutputMethod.Xml:
                    if (settings.Indent)
                    {
                        writer = new XmlEncodedRawTextWriterIndent(output, encoding, settings, closeOutput);
                    }
                    else
                    {
                        writer = new XmlEncodedRawTextWriter(output, encoding, settings, closeOutput);
                    }
                    break;

                case XmlOutputMethod.Html:
                    if (settings.Indent)
                    {
                        writer = new HtmlEncodedRawTextWriterIndent(output, encoding, settings, closeOutput);
                    }
                    else
                    {
                        writer = new HtmlEncodedRawTextWriter(output, encoding, settings, closeOutput);
                    }
                    break;

                case XmlOutputMethod.Text:
                    writer = new TextEncodedRawTextWriter(output, encoding, settings, closeOutput);
                    break;

                case XmlOutputMethod.AutoDetect:
                    writer = new XmlAutoDetectWriter(output, encoding, settings);
                    break;

                default:
                    Debug.Assert(false, "Invalid XmlOutputMethod2 setting.");
                    return(null);
                }
            }

            // Wrap with Xslt/XQuery specific writer if needed;
            // XmlOutputMethod.AutoDetect writer does this lazily when it creates the underlying Xml or Html writer.
            if (settings.OutputMethod != XmlOutputMethod.AutoDetect)
            {
                if (settings.IsQuerySpecific)
                {
                    // Create QueryOutputWriter if CData sections or DocType need to be tracked
                    writer = new QueryOutputWriter((XmlRawWriter)writer, settings);
                }
            }

            // wrap with well-formed writer
            writer = new XmlWellFormedWriter(writer, settings);

            return(writer);
        }
예제 #13
0
        internal XmlWriter CreateWriter(TextWriter output)
        {
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            XmlWriter writer;

            // create raw writer
            if (this.Indent)
            {
                writer = new XmlEncodedRawTextWriterIndent(output, this);
            }
            else
            {
                writer = new XmlEncodedRawTextWriter(output, this);
            }

            // wrap with well-formed writer
            writer = new XmlWellFormedWriter(writer, this);

            if (_useAsync)
            {
                writer = new XmlAsyncCheckWriter(writer);
            }
            return writer;
        }
예제 #14
0
        //
        // Internal properties
        //


        internal XmlWriter CreateWriter(Stream output)
        {
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            XmlWriter writer;

            // create raw writer
            Debug.Assert(Encoding.UTF8.WebName == "utf-8");
            if (this.Encoding.WebName == "utf-8")
            { // Encoding.CodePage is not supported in Silverlight
                // create raw UTF-8 writer
                if (this.Indent)
                {
                    writer = new XmlUtf8RawTextWriterIndent(output, this);
                }
                else
                {
                    writer = new XmlUtf8RawTextWriter(output, this);
                }
            }
            else
            {
                // create raw writer for other encodings
                if (this.Indent)
                {
                    writer = new XmlEncodedRawTextWriterIndent(output, this);
                }
                else
                {
                    writer = new XmlEncodedRawTextWriter(output, this);
                }
            }

            // wrap with well-formed writer
            writer = new XmlWellFormedWriter(writer, this);

            if (_useAsync)
            {
                writer = new XmlAsyncCheckWriter(writer);
            }

            return writer;
        }
        internal XmlWriter CreateWriter(TextWriter output)
        {
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            XmlWriter writer;

            // create raw writer
            switch (this.OutputMethod)
            {
            case XmlOutputMethod.Xml:
                if (this.Indent)
                {
                    writer = new XmlEncodedRawTextWriterIndent(output, this);
                }
                else
                {
                    writer = new XmlEncodedRawTextWriter(output, this);
                }
                break;

            case XmlOutputMethod.Html:
                if (this.Indent)
                {
                    writer = new HtmlEncodedRawTextWriterIndent(output, this);
                }
                else
                {
                    writer = new HtmlEncodedRawTextWriter(output, this);
                }
                break;

            case XmlOutputMethod.Text:
                writer = new TextEncodedRawTextWriter(output, this);
                break;

            case XmlOutputMethod.AutoDetect:
                writer = new XmlAutoDetectWriter(output, this);
                break;

            default:
                Debug.Fail("Invalid XmlOutputMethod setting.");
                return(null);
            }

            // XmlOutputMethod.AutoDetect writer does this lazily when it creates the underlying Xml or Html writer.
            if (this.OutputMethod != XmlOutputMethod.AutoDetect)
            {
                if (this.IsQuerySpecific)
                {
                    // Create QueryOutputWriter if CData sections or DocType need to be tracked
                    writer = new QueryOutputWriter((XmlRawWriter)writer, this);
                }
            }

            // wrap with well-formed writer
            writer = new XmlWellFormedWriter(writer, this);

            if (_useAsync)
            {
                writer = new XmlAsyncCheckWriter(writer);
            }
            return(writer);
        }
예제 #16
0
        private static XmlWriter CreateWriterImpl(TextWriter output, XmlWriterSettings settings) {
            Debug.Assert(output != null);
            Debug.Assert(settings != null);

            XmlWriter writer;

            switch (settings.OutputMethod) {
                case XmlOutputMethod.Xml:
                    if (settings.Indent) {
                        writer = new XmlEncodedRawTextWriterIndent(output, settings);
                    }
                    else {
                        writer = new XmlEncodedRawTextWriter(output, settings);
                    }
                    break;
                case XmlOutputMethod.Html:
                    if (settings.Indent) {
                        writer = new HtmlEncodedRawTextWriterIndent(output, settings);
                    }
                    else {
                        writer = new HtmlEncodedRawTextWriter(output, settings);
                    }
                    break;
                case XmlOutputMethod.Text:
                    writer = new TextEncodedRawTextWriter(output, settings);
                    break;
                case XmlOutputMethod.AutoDetect:
                    writer = new XmlAutoDetectWriter(output, settings);
                    break;
                default:
                    Debug.Assert(false, "Invalid XmlOutputMethod setting.");
                    return null;
            }

            // Wrap with Xslt/XQuery specific writer if needed; 
            // XmlOutputMethod.AutoDetect writer does this lazily when it creates the underlying Xml or Html writer.
            if (settings.OutputMethod != XmlOutputMethod.AutoDetect) {
                if (settings.IsQuerySpecific) {

                    // Create QueryOutputWriter if CData sections or DocType need to be tracked
                    writer = new QueryOutputWriter((XmlRawWriter)writer, settings);
                }
            }

            writer = new XmlWellFormedWriter(writer, settings);
            return writer;
        }
        private XmlWriter AddConformanceWrapper(XmlWriter baseWriter)
        {
            ConformanceLevel  confLevel          = ConformanceLevel.Auto;
            XmlWriterSettings baseWriterSettings = baseWriter.Settings;
            bool checkValues     = false;
            bool checkNames      = false;
            bool replaceNewLines = false;
            bool needWrap        = false;

            if (baseWriterSettings == null)
            {
                // assume the V1 writer already do all conformance checking;
                // wrap only if NewLineHandling == Replace or CheckCharacters is true
                if (_newLineHandling == NewLineHandling.Replace)
                {
                    replaceNewLines = true;
                    needWrap        = true;
                }
                if (_checkCharacters)
                {
                    checkValues = true;
                    needWrap    = true;
                }
            }
            else
            {
                if (_conformanceLevel != baseWriterSettings.ConformanceLevel)
                {
                    confLevel = this.ConformanceLevel;
                    needWrap  = true;
                }
                if (_checkCharacters && !baseWriterSettings.CheckCharacters)
                {
                    checkValues = true;
                    checkNames  = confLevel == ConformanceLevel.Auto;
                    needWrap    = true;
                }
                if (_newLineHandling == NewLineHandling.Replace &&
                    baseWriterSettings.NewLineHandling == NewLineHandling.None)
                {
                    replaceNewLines = true;
                    needWrap        = true;
                }
            }

            XmlWriter writer = baseWriter;

            if (needWrap)
            {
                if (confLevel != ConformanceLevel.Auto)
                {
                    writer = new XmlWellFormedWriter(writer, this);
                }
                if (checkValues || replaceNewLines)
                {
                    writer = new XmlCharCheckingWriter(writer, checkValues, checkNames, replaceNewLines, this.NewLineChars);
                }
            }

            if (this.IsQuerySpecific && (baseWriterSettings == null || !baseWriterSettings.IsQuerySpecific))
            {
                // Create QueryOutputWriterV1 if CData sections or DocType need to be tracked
                writer = new QueryOutputWriterV1(writer, this);
            }

            return(writer);
        }
예제 #18
0
        private static XmlWriter AddConformanceWrapper(XmlWriter baseWriter, XmlWriterSettings baseWriterSettings, XmlWriterSettings settings) {
            ConformanceLevel confLevel = ConformanceLevel.Auto;
            bool checkValues = false;
            bool checkNames = false;
            bool replaceNewLines = false;
            bool needWrap = false;

            if (baseWriterSettings == null) {
                // assume the V1 writer already do all conformance checking; 
                // wrap only if NewLineHandling == Replace or CheckCharacters is true
                if (settings.NewLineHandling == NewLineHandling.Replace) {
                    replaceNewLines = true;
                    needWrap = true;
                }
                if (settings.CheckCharacters) {
                    checkValues = true;
                    needWrap = true;
                }
            }
            else {
                if (settings.ConformanceLevel != baseWriterSettings.ConformanceLevel) {
                    confLevel = settings.ConformanceLevel;
                    needWrap = true;
                }
                if (settings.CheckCharacters && !baseWriterSettings.CheckCharacters) {
                    checkValues = true;
                    checkNames = confLevel == ConformanceLevel.Auto;
                    needWrap = true;
                }
                if (settings.NewLineHandling == NewLineHandling.Replace &&
                     baseWriterSettings.NewLineHandling == NewLineHandling.None) {
                    replaceNewLines = true;
                    needWrap = true;
                }
            }

            if (needWrap) {
                XmlWriter writer = baseWriter;
                if (confLevel != ConformanceLevel.Auto) {
                    writer = new XmlWellFormedWriter(writer, settings);
                }
                if (checkValues || replaceNewLines) {
                    writer = new XmlCharCheckingWriter(writer, checkValues, checkNames, replaceNewLines, settings.NewLineChars);
                }
                return writer;
            }
            else {
                return baseWriter;
            }
        }
예제 #19
0
 internal NamespaceResolverProxy(XmlWellFormedWriter wfWriter)
 {
     _wfWriter = wfWriter;
 }
 internal void Set(XmlWellFormedWriter.AttributeValueCache.ItemType type, object data)
 {
     this.type = type;
     this.data = data;
 }