System.Xml.Xsl.IlGen.XmlILOptimizerVisitor.Visit C# (CSharp) Method

Visit() protected method

Override the Visit method in order to scan for redundant namespaces and compute side-effect bit.
protected Visit ( QilNode nd ) : QilNode
nd QilNode
return QilNode
        protected override QilNode Visit(QilNode nd) {
            if (nd != null) {
                if (this[XmlILOptimization.EliminateNamespaceDecl]) {
                    // Eliminate redundant namespaces in the tree.  Don't perform the scan on an ElementCtor which
                    // has already been marked as having a redundant namespace.
                    switch (nd.NodeType) {
                        case QilNodeType.QilExpression:
                            // Perform namespace analysis on root expression (xmlns="" is in-scope for this expression)
                            this.nmspAnalyzer.Analyze(((QilExpression) nd).Root, true);
                            break;

                        case QilNodeType.ElementCtor:
                            if (!XmlILConstructInfo.Read(nd).IsNamespaceInScope)
                                this.nmspAnalyzer.Analyze(nd, false);
                            break;

                        case QilNodeType.DocumentCtor:
                            this.nmspAnalyzer.Analyze(nd, true);
                            break;
                    }
                }
            }

            // Continue visitation
            return base.Visit(nd);
        }
XmlILOptimizerVisitor