Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / XmlUtils / System / Xml / Xsl / Xslt / Stylesheet.cs / 1 / Stylesheet.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System.Collections.Generic; using System.Diagnostics; using System.Xml.Xsl.Qil; namespace System.Xml.Xsl.Xslt { internal class Stylesheet { private Compiler compiler; public ListImportHrefs = new List (); public Stylesheet[] Imports = null; public List Templates = new List(); public List GlobalVarPars = new List (); // xsl:attribute-set/@name -> AttributeSet public Dictionary AttributeSets = new Dictionary (); // xsl:template/@mode -> list of @match'es public Dictionary > TemplateMatches = new Dictionary >(); // mode -> xsl:apply-import functions for that mode public Dictionary > ApplyImportsFunctions = new Dictionary >(); private int importPrecedence; private int orderNumber = 0; /* WhitespaceRules[0] - rules with default priority 0 WhitespaceRules[1] - rules with default priority -0.25 WhitespaceRules[2] - rules with default priority -0.5 */ public List [] WhitespaceRules = new List [3]; public Stylesheet(Compiler compiler, int importPrecedence) { this.compiler = compiler; this.importPrecedence = importPrecedence; WhitespaceRules[0] = new List (); WhitespaceRules[1] = new List (); WhitespaceRules[2] = new List (); } public int ImportPrecedence { get { return importPrecedence; } } public void AddWhitespaceRule(int index, WhitespaceRule rule) { WhitespaceRules[index].Add(rule); } public bool AddVarPar(VarPar var) { Debug.Assert(var.NodeType == XslNodeType.Variable || var.NodeType == XslNodeType.Param); Debug.Assert(var.Name.NamespaceUri != null, "Name must be resolved in XsltLoader"); foreach (XslNode prevVar in GlobalVarPars) { if (prevVar.Name.Equals(var.Name)) { // [ERR XT0630] It is a static error if a stylesheet contains more than one binding // of a global variable with the same name and same import precedence, unless it also // contains another binding with the same name and higher import precedence. return compiler.AllGlobalVarPars.ContainsKey(var.Name); } } GlobalVarPars.Add(var); return true; } public bool AddTemplate(Template template) { Debug.Assert(template.ImportPrecedence == 0); template.ImportPrecedence = this.importPrecedence; template.OrderNumber = this.orderNumber++; compiler.AllTemplates.Add(template); if (template.Name != null) { Template old; if (!compiler.NamedTemplates.TryGetValue(template.Name, out old)) { compiler.NamedTemplates[template.Name] = template; } else { Debug.Assert(template.ImportPrecedence <= old.ImportPrecedence, "Global objects are processed in order of decreasing import precedence"); if (old.ImportPrecedence == template.ImportPrecedence) { return false; } } } if (template.Match != null) { Templates.Add(template); } return true; } public void AddTemplateMatch(Template template, QilLoop filter) { List matchesForMode; if (!TemplateMatches.TryGetValue(template.Mode, out matchesForMode)) { matchesForMode = TemplateMatches[template.Mode] = new List (); } matchesForMode.Add(new TemplateMatch(template, filter)); } public void SortTemplateMatches() { foreach (QilName mode in TemplateMatches.Keys) { TemplateMatches[mode].Sort(TemplateMatch.Comparer); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System.Collections.Generic; using System.Diagnostics; using System.Xml.Xsl.Qil; namespace System.Xml.Xsl.Xslt { internal class Stylesheet { private Compiler compiler; public ListImportHrefs = new List (); public Stylesheet[] Imports = null; public List Templates = new List(); public List GlobalVarPars = new List (); // xsl:attribute-set/@name -> AttributeSet public Dictionary AttributeSets = new Dictionary (); // xsl:template/@mode -> list of @match'es public Dictionary > TemplateMatches = new Dictionary >(); // mode -> xsl:apply-import functions for that mode public Dictionary > ApplyImportsFunctions = new Dictionary >(); private int importPrecedence; private int orderNumber = 0; /* WhitespaceRules[0] - rules with default priority 0 WhitespaceRules[1] - rules with default priority -0.25 WhitespaceRules[2] - rules with default priority -0.5 */ public List [] WhitespaceRules = new List [3]; public Stylesheet(Compiler compiler, int importPrecedence) { this.compiler = compiler; this.importPrecedence = importPrecedence; WhitespaceRules[0] = new List (); WhitespaceRules[1] = new List (); WhitespaceRules[2] = new List (); } public int ImportPrecedence { get { return importPrecedence; } } public void AddWhitespaceRule(int index, WhitespaceRule rule) { WhitespaceRules[index].Add(rule); } public bool AddVarPar(VarPar var) { Debug.Assert(var.NodeType == XslNodeType.Variable || var.NodeType == XslNodeType.Param); Debug.Assert(var.Name.NamespaceUri != null, "Name must be resolved in XsltLoader"); foreach (XslNode prevVar in GlobalVarPars) { if (prevVar.Name.Equals(var.Name)) { // [ERR XT0630] It is a static error if a stylesheet contains more than one binding // of a global variable with the same name and same import precedence, unless it also // contains another binding with the same name and higher import precedence. return compiler.AllGlobalVarPars.ContainsKey(var.Name); } } GlobalVarPars.Add(var); return true; } public bool AddTemplate(Template template) { Debug.Assert(template.ImportPrecedence == 0); template.ImportPrecedence = this.importPrecedence; template.OrderNumber = this.orderNumber++; compiler.AllTemplates.Add(template); if (template.Name != null) { Template old; if (!compiler.NamedTemplates.TryGetValue(template.Name, out old)) { compiler.NamedTemplates[template.Name] = template; } else { Debug.Assert(template.ImportPrecedence <= old.ImportPrecedence, "Global objects are processed in order of decreasing import precedence"); if (old.ImportPrecedence == template.ImportPrecedence) { return false; } } } if (template.Match != null) { Templates.Add(template); } return true; } public void AddTemplateMatch(Template template, QilLoop filter) { List matchesForMode; if (!TemplateMatches.TryGetValue(template.Mode, out matchesForMode)) { matchesForMode = TemplateMatches[template.Mode] = new List (); } matchesForMode.Add(new TemplateMatch(template, filter)); } public void SortTemplateMatches() { foreach (QilName mode in TemplateMatches.Keys) { TemplateMatches[mode].Sort(TemplateMatch.Comparer); } } } } // 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
- DataGridParentRows.cs
- ProxyWebPart.cs
- BitmapCodecInfoInternal.cs
- BooleanAnimationUsingKeyFrames.cs
- AppSettingsExpressionBuilder.cs
- ParameterCollectionEditorForm.cs
- DllNotFoundException.cs
- FileDialog.cs
- DocumentPage.cs
- XmlCompatibilityReader.cs
- nulltextcontainer.cs
- TextEditorContextMenu.cs
- RoleGroup.cs
- ToolboxItemFilterAttribute.cs
- RelatedPropertyManager.cs
- securitycriticaldataClass.cs
- MimeTypeMapper.cs
- SystemIcmpV4Statistics.cs
- EditorPartChrome.cs
- DefaultDiscoveryServiceExtension.cs
- MatchingStyle.cs
- MobileControlDesigner.cs
- WebMessageFormatHelper.cs
- Rule.cs
- SoapServerProtocol.cs
- CollectionViewGroupRoot.cs
- Queue.cs
- ExtendLockAsyncResult.cs
- HtmlInputReset.cs
- EmbeddedObject.cs
- Renderer.cs
- CodeTypeOfExpression.cs
- Int32Converter.cs
- HtmlMeta.cs
- ProcessModelSection.cs
- ServiceOperationInvoker.cs
- Context.cs
- DetailsViewPageEventArgs.cs
- QueryOptionExpression.cs
- AttachedPropertyMethodSelector.cs
- PrivilegeNotHeldException.cs
- PtsHelper.cs
- CqlGenerator.cs
- DataControlLinkButton.cs
- ToolStripItemTextRenderEventArgs.cs
- EnumValAlphaComparer.cs
- ResourceReader.cs
- WindowsAuthenticationModule.cs
- ValueExpressions.cs
- DesignerVerb.cs
- HtmlInputText.cs
- SqlCacheDependency.cs
- ContextInformation.cs
- PrintPreviewGraphics.cs
- ExceptionHelpers.cs
- SecurityBindingElement.cs
- GridView.cs
- MessageCredentialType.cs
- TrackingLocationCollection.cs
- MouseCaptureWithinProperty.cs
- WSSecureConversationDec2005.cs
- PngBitmapEncoder.cs
- ConfigXmlSignificantWhitespace.cs
- PrefixQName.cs
- WebControlsSection.cs
- RegexWriter.cs
- HtmlElement.cs
- ExcludePathInfo.cs
- ResourcePool.cs
- PackUriHelper.cs
- BuildProviderInstallComponent.cs
- HttpWriter.cs
- HwndSourceParameters.cs
- DocumentOrderQuery.cs
- CollectionViewProxy.cs
- Group.cs
- DiscreteKeyFrames.cs
- OdbcReferenceCollection.cs
- CachedBitmap.cs
- SapiRecoInterop.cs
- XmlSchemaFacet.cs
- TextElementEnumerator.cs
- Activity.cs
- DeclarationUpdate.cs
- ControlCollection.cs
- PluralizationService.cs
- UserControlAutomationPeer.cs
- Pair.cs
- BitmapCacheBrush.cs
- BitSet.cs
- OdbcConnectionFactory.cs
- XPathEmptyIterator.cs
- MembershipValidatePasswordEventArgs.cs
- ArrayElementGridEntry.cs
- HttpCachePolicy.cs
- CompositeCollection.cs
- WaitingCursor.cs
- Image.cs
- ImportStoreException.cs
- DataChangedEventManager.cs