/// <include file='doc\XmlNamespaceManager.uex' path='docs/doc[@for="XmlNamespaceManager.PushScope"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public virtual void PushScope() { Scope current = (Scope)scopes.Push(); if (current == null) { current = new Scope(); scopes.AddToTop(current); } current.Default = defaultNs; current.Count = count; count = 0; }
/// <include file='doc\XmlNamespaceManager.uex' path='docs/doc[@for="XmlNamespaceManager.AddNamespace"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public virtual void AddNamespace(string prefix, string uri) { if (uri == null) { throw new ArgumentNullException("uri"); } if (prefix == null) { throw new ArgumentNullException("prefix"); } prefix = nameTable.Add(prefix); uri = nameTable.Add(uri); if (Ref.Equal(xml, prefix) || Ref.Equal(xmlNs, prefix)) { throw new ArgumentException(Res.GetString(Res.Xml_InvalidPrefix)); } for (int declIndex = decls.Length - 1; declIndex >= decls.Length - count; declIndex--) { NsDecl decl = (NsDecl)decls[declIndex]; if (Ref.Equal(decl.Prefix, prefix)) { decl.Uri = uri; return; // redefine } } /* else */ { NsDecl decl = (NsDecl)decls.Push(); if (decl == null) { decl = new NsDecl(); decls.AddToTop(decl); } decl.Prefix = prefix; decl.Uri = uri; count++; if (prefix == string.Empty) { defaultNs = decl; } } }
internal OutputScopeManager(XmlNameTable nameTable, OutKeywords atoms) { Debug.Assert(nameTable != null); Debug.Assert(atoms != null); _elementScopesStack = new HWStack(STACK_INCREMENT); _nameTable = nameTable; _atoms = atoms; _defaultNS = _atoms.Empty; // We always adding rootElementScope to garantee that CurrentElementScope != null // This context is active between PI and first element for example OutputScope rootElementScope = (OutputScope)_elementScopesStack.Push(); if (rootElementScope == null) { rootElementScope = new OutputScope(); _elementScopesStack.AddToTop(rootElementScope); } rootElementScope.Init(string.Empty, string.Empty, string.Empty, /*space:*/XmlSpace.None, /*lang:*/string.Empty, /*mixed:*/false); }