The Labs \ Source Viewer \ SSCLI \ System.Xml.Xsl.XsltOld \ DocumentScope

  1. //------------------------------------------------------------------------------
  2. // <copyright file="DocumentScope.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.Xml.Xsl.XsltOld
  16. {
  17.     using Res = System.Xml.Utils.Res;
  18.     using System;
  19.     using System.Diagnostics;
  20.     using System.Xml;
  21.     using System.Xml.XPath;
  22.    
  23.     internal class DocumentScope
  24.     {
  25.         protected NamespaceDecl scopes;
  26.        
  27.         internal NamespaceDecl Scopes {
  28.             get { return this.scopes; }
  29.         }
  30.        
  31.         internal NamespaceDecl AddNamespace(string prefix, string uri, string prevDefaultNsUri)
  32.         {
  33.             this.scopes = new NamespaceDecl(prefix, uri, prevDefaultNsUri, this.scopes);
  34.             return this.scopes;
  35.         }
  36.        
  37.         internal string ResolveAtom(string prefix)
  38.         {
  39.             Debug.Assert(prefix != null && prefix.Length > 0);
  40.            
  41.             for (NamespaceDecl scope = this.scopes; scope != null; scope = scope.Next) {
  42.                 if (Keywords.Equals(scope.Prefix, prefix)) {
  43.                     Debug.Assert(scope.Uri != null);
  44.                     return scope.Uri;
  45.                 }
  46.             }
  47.            
  48.             return null;
  49.         }
  50.        
  51.         internal string ResolveNonAtom(string prefix)
  52.         {
  53.             Debug.Assert(prefix != null && prefix.Length > 0);
  54.            
  55.             for (NamespaceDecl scope = this.scopes; scope != null; scope = scope.Next) {
  56.                 if (Keywords.Compare(scope.Prefix, prefix)) {
  57.                     Debug.Assert(scope.Uri != null);
  58.                     return scope.Uri;
  59.                 }
  60.             }
  61.             return null;
  62.         }
  63.     }
  64. }

Developer Fusion