Example #1
0
 internal void ReplaceNamespaceAlias(Compiler compiler)
 {
     if (_modeManagers != null)
     {
         IDictionaryEnumerator enumerator = _modeManagers.GetEnumerator();
         while (enumerator.MoveNext())
         {
             TemplateManager manager = (TemplateManager)enumerator.Value;
             if (manager.templates != null)
             {
                 for (int i = 0; i < manager.templates.Count; i++)
                 {
                     TemplateAction template = (TemplateAction)manager.templates[i];
                     template.ReplaceNamespaceAlias(compiler);
                 }
             }
         }
     }
     if (_templateNameTable != null)
     {
         IDictionaryEnumerator enumerator = _templateNameTable.GetEnumerator();
         while (enumerator.MoveNext())
         {
             TemplateAction template = (TemplateAction)enumerator.Value;
             template.ReplaceNamespaceAlias(compiler);
         }
     }
     if (_imports != null)
     {
         for (int importIndex = _imports.Count - 1; importIndex >= 0; importIndex--)
         {
             Stylesheet stylesheet = (Stylesheet)_imports[importIndex];
             stylesheet.ReplaceNamespaceAlias(compiler);
         }
     }
 }
Example #2
0
        internal void AddTemplate(TemplateAction template) {
            XmlQualifiedName mode = template.Mode;

            //
            // Ensure template has a unique name
            //

            Debug.Assert(this.templateNameTable != null);

            if (template.Name != null) {
                if (this.templateNameTable.ContainsKey(template.Name) == false) {
                    this.templateNameTable[template.Name] = template;
                }
                else {
                    throw XsltException.Create(Res.Xslt_DupTemplateName, template.Name.ToString());
                }
            }


            if (template.MatchKey != Compiler.InvalidQueryKey) {
                if (this.modeManagers == null) {
                    this.modeManagers = new Hashtable();
                }
                Debug.Assert(this.modeManagers != null);

                if (mode == null) {
                    mode = XmlQualifiedName.Empty;
                }

                TemplateManager manager = (TemplateManager) this.modeManagers[mode];

                if (manager == null) {
                    manager = new TemplateManager(this, mode);

                    this.modeManagers[mode] = manager;

                    if (mode.IsEmpty) {
                        Debug.Assert(this.templates == null);
                        this.templates = manager;
                    }
                }
                Debug.Assert(manager != null);

                template.TemplateId = ++ this.templateCount;
                manager.AddTemplate(template);
            }
        }