Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / XmlUtils / System / Xml / Xsl / XsltOld / InputScopeManager.cs / 1 / InputScopeManager.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace System.Xml.Xsl.XsltOld { using Res = System.Xml.Utils.Res; using System; using System.Diagnostics; using System.Xml; using System.Xml.XPath; internal class InputScopeManager { private InputScope scopeStack; private string defaultNS = string.Empty; private XPathNavigator navigator; // We need this nsvigator for document() function implementation public InputScopeManager(XPathNavigator navigator, InputScope rootScope) { this.navigator = navigator; this.scopeStack = rootScope; } internal InputScope CurrentScope { get { return this.scopeStack; } } internal InputScope VariableScope { get { Debug.Assert(this.scopeStack != null); Debug.Assert(this.scopeStack.Parent != null); return this.scopeStack.Parent; } } internal InputScopeManager Clone() { InputScopeManager manager = new InputScopeManager(this.navigator, null); manager.scopeStack = this.scopeStack; manager.defaultNS = this.defaultNS; return manager; } public XPathNavigator Navigator { get {return this.navigator;} } internal InputScope PushScope() { this.scopeStack = new InputScope(this.scopeStack); return this.scopeStack; } internal void PopScope() { Debug.Assert(this.scopeStack != null, "Push/Pop disbalance"); if (this.scopeStack == null) { return; } for (NamespaceDecl scope = this.scopeStack.Scopes; scope != null; scope = scope.Next) { this.defaultNS = scope.PrevDefaultNsUri; } this.scopeStack = this.scopeStack.Parent; } internal void PushNamespace(string prefix, string nspace) { Debug.Assert(this.scopeStack != null, "PushScope wasn't called"); Debug.Assert(prefix != null); Debug.Assert(nspace != null); this.scopeStack.AddNamespace(prefix, nspace, this.defaultNS); if (prefix == null || prefix.Length == 0) { this.defaultNS = nspace; } } // CompileContext public string DefaultNamespace { get { return this.defaultNS; } } private string ResolveNonEmptyPrefix(string prefix) { Debug.Assert(this.scopeStack != null, "PushScope wasn't called"); Debug.Assert(prefix != null || prefix.Length != 0); if (prefix == Keywords.s_Xml) { return Keywords.s_XmlNamespace; } else if (prefix == Keywords.s_Xmlns) { return Keywords.s_XmlnsNamespace; } for (InputScope inputScope = this.scopeStack; inputScope != null; inputScope = inputScope.Parent) { string nspace = inputScope.ResolveNonAtom(prefix); if (nspace != null) { return nspace; } } throw XsltException.Create(Res.Xslt_InvalidPrefix, prefix); } public string ResolveXmlNamespace(string prefix) { Debug.Assert(prefix != null); if (prefix.Length == 0) { return this.defaultNS; } return ResolveNonEmptyPrefix(prefix); } public string ResolveXPathNamespace(string prefix) { Debug.Assert(prefix != null); if (prefix.Length == 0) { return string.Empty; } return ResolveNonEmptyPrefix(prefix); } internal void InsertExtensionNamespaces(string[] nsList) { Debug.Assert(this.scopeStack != null, "PushScope wasn't called"); Debug.Assert(nsList != null); for (int idx = 0; idx < nsList.Length; idx++) { this.scopeStack.InsertExtensionNamespace(nsList[idx]); } } internal bool IsExtensionNamespace(String nspace) { Debug.Assert(this.scopeStack != null, "PushScope wasn't called"); for (InputScope inputScope = this.scopeStack; inputScope != null; inputScope = inputScope.Parent) { if (inputScope.IsExtensionNamespace( nspace )) { return true; } } return false; } internal void InsertExcludedNamespaces(string[] nsList) { Debug.Assert(this.scopeStack != null, "PushScope wasn't called"); Debug.Assert(nsList != null); for (int idx = 0; idx < nsList.Length; idx++) { this.scopeStack.InsertExcludedNamespace(nsList[idx]); } } internal bool IsExcludedNamespace(String nspace) { Debug.Assert(this.scopeStack != null, "PushScope wasn't called"); for (InputScope inputScope = this.scopeStack; inputScope != null; inputScope = inputScope.Parent) { if (inputScope.IsExcludedNamespace( nspace )) { return true; } } return false; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace System.Xml.Xsl.XsltOld { using Res = System.Xml.Utils.Res; using System; using System.Diagnostics; using System.Xml; using System.Xml.XPath; internal class InputScopeManager { private InputScope scopeStack; private string defaultNS = string.Empty; private XPathNavigator navigator; // We need this nsvigator for document() function implementation public InputScopeManager(XPathNavigator navigator, InputScope rootScope) { this.navigator = navigator; this.scopeStack = rootScope; } internal InputScope CurrentScope { get { return this.scopeStack; } } internal InputScope VariableScope { get { Debug.Assert(this.scopeStack != null); Debug.Assert(this.scopeStack.Parent != null); return this.scopeStack.Parent; } } internal InputScopeManager Clone() { InputScopeManager manager = new InputScopeManager(this.navigator, null); manager.scopeStack = this.scopeStack; manager.defaultNS = this.defaultNS; return manager; } public XPathNavigator Navigator { get {return this.navigator;} } internal InputScope PushScope() { this.scopeStack = new InputScope(this.scopeStack); return this.scopeStack; } internal void PopScope() { Debug.Assert(this.scopeStack != null, "Push/Pop disbalance"); if (this.scopeStack == null) { return; } for (NamespaceDecl scope = this.scopeStack.Scopes; scope != null; scope = scope.Next) { this.defaultNS = scope.PrevDefaultNsUri; } this.scopeStack = this.scopeStack.Parent; } internal void PushNamespace(string prefix, string nspace) { Debug.Assert(this.scopeStack != null, "PushScope wasn't called"); Debug.Assert(prefix != null); Debug.Assert(nspace != null); this.scopeStack.AddNamespace(prefix, nspace, this.defaultNS); if (prefix == null || prefix.Length == 0) { this.defaultNS = nspace; } } // CompileContext public string DefaultNamespace { get { return this.defaultNS; } } private string ResolveNonEmptyPrefix(string prefix) { Debug.Assert(this.scopeStack != null, "PushScope wasn't called"); Debug.Assert(prefix != null || prefix.Length != 0); if (prefix == Keywords.s_Xml) { return Keywords.s_XmlNamespace; } else if (prefix == Keywords.s_Xmlns) { return Keywords.s_XmlnsNamespace; } for (InputScope inputScope = this.scopeStack; inputScope != null; inputScope = inputScope.Parent) { string nspace = inputScope.ResolveNonAtom(prefix); if (nspace != null) { return nspace; } } throw XsltException.Create(Res.Xslt_InvalidPrefix, prefix); } public string ResolveXmlNamespace(string prefix) { Debug.Assert(prefix != null); if (prefix.Length == 0) { return this.defaultNS; } return ResolveNonEmptyPrefix(prefix); } public string ResolveXPathNamespace(string prefix) { Debug.Assert(prefix != null); if (prefix.Length == 0) { return string.Empty; } return ResolveNonEmptyPrefix(prefix); } internal void InsertExtensionNamespaces(string[] nsList) { Debug.Assert(this.scopeStack != null, "PushScope wasn't called"); Debug.Assert(nsList != null); for (int idx = 0; idx < nsList.Length; idx++) { this.scopeStack.InsertExtensionNamespace(nsList[idx]); } } internal bool IsExtensionNamespace(String nspace) { Debug.Assert(this.scopeStack != null, "PushScope wasn't called"); for (InputScope inputScope = this.scopeStack; inputScope != null; inputScope = inputScope.Parent) { if (inputScope.IsExtensionNamespace( nspace )) { return true; } } return false; } internal void InsertExcludedNamespaces(string[] nsList) { Debug.Assert(this.scopeStack != null, "PushScope wasn't called"); Debug.Assert(nsList != null); for (int idx = 0; idx < nsList.Length; idx++) { this.scopeStack.InsertExcludedNamespace(nsList[idx]); } } internal bool IsExcludedNamespace(String nspace) { Debug.Assert(this.scopeStack != null, "PushScope wasn't called"); for (InputScope inputScope = this.scopeStack; inputScope != null; inputScope = inputScope.Parent) { if (inputScope.IsExcludedNamespace( nspace )) { return true; } } return false; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DispatchWrapper.cs
- WindowsListBox.cs
- SharedConnectionInfo.cs
- WmfPlaceableFileHeader.cs
- AnimationTimeline.cs
- httpserverutility.cs
- ContainerActivationHelper.cs
- DataTableReaderListener.cs
- DataBindingHandlerAttribute.cs
- Types.cs
- Exceptions.cs
- RegularExpressionValidator.cs
- x509utils.cs
- ACE.cs
- PeerNameResolver.cs
- shaperfactory.cs
- BamlReader.cs
- DesignTimeType.cs
- DataFormats.cs
- SmiTypedGetterSetter.cs
- BamlLocalizer.cs
- GroupPartitionExpr.cs
- HMACSHA256.cs
- RelOps.cs
- SendContent.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- WebPartConnectionsDisconnectVerb.cs
- WeakRefEnumerator.cs
- SizeConverter.cs
- SharedConnectionInfo.cs
- XmlSerializerAssemblyAttribute.cs
- CSharpCodeProvider.cs
- ControlIdConverter.cs
- QueryOutputWriter.cs
- Binding.cs
- Cursor.cs
- XmlNamespaceMapping.cs
- MouseGestureValueSerializer.cs
- MiniAssembly.cs
- DataKeyArray.cs
- StringAnimationUsingKeyFrames.cs
- Stroke2.cs
- HostingEnvironment.cs
- DataServiceClientException.cs
- PropertyChangedEventArgs.cs
- XsltException.cs
- WebControlsSection.cs
- COM2TypeInfoProcessor.cs
- WorkItem.cs
- Avt.cs
- PolyQuadraticBezierSegment.cs
- CheckBoxField.cs
- ToolboxCategory.cs
- DesignerCategoryAttribute.cs
- NativeRightsManagementAPIsStructures.cs
- IsolatedStorageException.cs
- ParameterRefs.cs
- LabelDesigner.cs
- ExceptionTrace.cs
- Int32AnimationUsingKeyFrames.cs
- InputLanguageEventArgs.cs
- BatchStream.cs
- RelativeSource.cs
- SchemaTypeEmitter.cs
- RealizationDrawingContextWalker.cs
- SQLBoolean.cs
- EndSelectCardRequest.cs
- TableRowCollection.cs
- WebFaultException.cs
- x509store.cs
- InlinedAggregationOperator.cs
- EventArgs.cs
- XPathDocument.cs
- LiteralSubsegment.cs
- Validator.cs
- ColorConvertedBitmap.cs
- metadatamappinghashervisitor.cs
- DPTypeDescriptorContext.cs
- Win32SafeHandles.cs
- DesignTimeType.cs
- ResXBuildProvider.cs
- BehaviorEditorPart.cs
- XmlBuffer.cs
- Model3D.cs
- DESCryptoServiceProvider.cs
- ModuleConfigurationInfo.cs
- TextModifier.cs
- SmtpDigestAuthenticationModule.cs
- CompilerGlobalScopeAttribute.cs
- SoapCodeExporter.cs
- OutputBuffer.cs
- XmlSchemaComplexType.cs
- ManagementScope.cs
- DataGridViewColumnCollection.cs
- AmbientValueAttribute.cs
- NativeRightsManagementAPIsStructures.cs
- ResizeGrip.cs
- MailAddress.cs
- CachedResourceDictionaryExtension.cs
- PlatformNotSupportedException.cs