System.Xml.Xsl.Xslt.QilGenerator.CompileLiteralElement C# (CSharp) Method

CompileLiteralElement() private method

private CompileLiteralElement ( XslNode node ) : QilNode
node XslNode
return QilNode
        private QilNode CompileLiteralElement(XslNode node)
        {
            // IlGen requires that namespace declarations do not conflict with the namespace used by the element
            // constructor, see XmlILNamespaceAnalyzer.CheckNamespaceInScope() and SQLBUDT 389481, 389482. First
            // we try to replace all prefixes bound to aliases by result-prefixes of the corresponding
            // xsl:namespace-alias instructions. If there is at least one conflict, we leave all prefixes
            // untouched, changing only namespace URIs.
            bool changePrefixes = true;

        Start:
            _prefixesInUse.Clear();

            QilName qname = node.Name;
            string prefix = qname.Prefix;
            string nsUri = qname.NamespaceUri;

            _compiler.ApplyNsAliases(ref prefix, ref nsUri);
            if (changePrefixes)
            {
                _prefixesInUse.Add(prefix, nsUri);
            }
            else
            {
                prefix = qname.Prefix;
            }

            _outputScope.PushScope();

            // Declare all namespaces that should be declared
            // <spec>http://www.w3.org/TR/xslt.html#literal-result-element</spec>
            QilList nsList = InstructionList();
            foreach (ScopeRecord rec in _scope)
            {
                string recPrefix = rec.ncName;
                string recNsUri = rec.nsUri;
                if (recNsUri != XmlReservedNs.NsXslt && !_scope.IsExNamespace(recNsUri))
                {
                    _compiler.ApplyNsAliases(ref recPrefix, ref recNsUri);
                    if (changePrefixes)
                    {
                        if (_prefixesInUse.Contains(recPrefix))
                        {
                            if ((string)_prefixesInUse[recPrefix] != recNsUri)
                            {
                                // Found a prefix conflict. Start again from the beginning leaving all prefixes untouched.
                                _outputScope.PopScope();
                                changePrefixes = false;
                                goto Start;
                            }
                        }
                        else
                        {
                            _prefixesInUse.Add(recPrefix, recNsUri);
                        }
                    }
                    else
                    {
                        recPrefix = rec.ncName;
                    }
                    AddNsDecl(nsList, recPrefix, recNsUri);
                }
            }

            QilNode content = CompileInstructions(node.Content, nsList);
            _outputScope.PopScope();

            qname.Prefix = prefix;
            qname.NamespaceUri = nsUri;
            return _f.ElementCtor(qname, content);
        }
QilGenerator