Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / XmlUtils / System / Xml / Xsl / XsltOld / ProcessingInstructionAction.cs / 1 / ProcessingInstructionAction.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 ProcessingInstructionAction : ContainerAction { private const int NameEvaluated = 2; private const int NameReady = 3; private Avt nameAvt; // Compile time precalculated AVT private string name; private const char CharX = 'X'; private const char Charx = 'x'; private const char CharM = 'M'; private const char Charm = 'm'; private const char CharL = 'L'; private const char Charl = 'l'; internal ProcessingInstructionAction() {} internal override void Compile(Compiler compiler) { CompileAttributes(compiler); CheckRequiredAttribute(compiler, this.nameAvt, Keywords.s_Name); if(this.nameAvt.IsConstant) { this.name = this.nameAvt.Evaluate(null, null); this.nameAvt = null; if (! IsProcessingInstructionName(this.name)) { // For Now: set to null to ignore action late; this.name = null; } } if (compiler.Recurse()) { CompileTemplate(compiler); compiler.ToParent(); } } internal override bool CompileAttribute(Compiler compiler) { string name = compiler.Input.LocalName; string value = compiler.Input.Value; if (Keywords.Equals(name, compiler.Atoms.Name)) { this.nameAvt = Avt.CompileAvt(compiler, value); } else { return false; } return true; } internal override void Execute(Processor processor, ActionFrame frame) { Debug.Assert(processor != null && frame != null); switch (frame.State) { case Initialized: if(this.nameAvt == null) { frame.StoredOutput = this.name; if(this.name == null) { // name was static but was bad; frame.Finished(); break; } } else { frame.StoredOutput = this.nameAvt.Evaluate(processor, frame); if (! IsProcessingInstructionName(frame.StoredOutput)) { frame.Finished(); break; } } goto case NameReady; case NameReady: Debug.Assert(frame.StoredOutput != null); if (processor.BeginEvent(XPathNodeType.ProcessingInstruction, string.Empty, frame.StoredOutput, string.Empty, false) == false) { // Come back later frame.State = NameReady; break; } processor.PushActionFrame(frame); frame.State = ProcessingChildren; break; // Allow children to run case ProcessingChildren: if (processor.EndEvent(XPathNodeType.ProcessingInstruction) == false) { frame.State = ProcessingChildren; break; } frame.Finished(); break; default: Debug.Fail("Invalid ElementAction execution state"); frame.Finished(); break; } } internal static bool IsProcessingInstructionName(string name) { if (name == null) { return false; } int nameLength = name.Length; int position = 0; XmlCharType xmlCharType = XmlCharType.Instance; while (position < nameLength && xmlCharType.IsWhiteSpace(name[position])) { position ++; } if (position >= nameLength) { return false; } if (position < nameLength && ! xmlCharType.IsStartNCNameChar(name[position])) { return false; } while (position < nameLength && xmlCharType.IsNCNameChar(name[position])) { position ++; } while (position < nameLength && xmlCharType.IsWhiteSpace(name[position])) { position ++; } if (position < nameLength) { return false; } if (nameLength == 3 && (name[0] == CharX || name[0] == Charx) && (name[1] == CharM || name[1] == Charm) && (name[2] == CharL || name[2] == Charl) ) { return false; } return true; } } } // 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 ProcessingInstructionAction : ContainerAction { private const int NameEvaluated = 2; private const int NameReady = 3; private Avt nameAvt; // Compile time precalculated AVT private string name; private const char CharX = 'X'; private const char Charx = 'x'; private const char CharM = 'M'; private const char Charm = 'm'; private const char CharL = 'L'; private const char Charl = 'l'; internal ProcessingInstructionAction() {} internal override void Compile(Compiler compiler) { CompileAttributes(compiler); CheckRequiredAttribute(compiler, this.nameAvt, Keywords.s_Name); if(this.nameAvt.IsConstant) { this.name = this.nameAvt.Evaluate(null, null); this.nameAvt = null; if (! IsProcessingInstructionName(this.name)) { // For Now: set to null to ignore action late; this.name = null; } } if (compiler.Recurse()) { CompileTemplate(compiler); compiler.ToParent(); } } internal override bool CompileAttribute(Compiler compiler) { string name = compiler.Input.LocalName; string value = compiler.Input.Value; if (Keywords.Equals(name, compiler.Atoms.Name)) { this.nameAvt = Avt.CompileAvt(compiler, value); } else { return false; } return true; } internal override void Execute(Processor processor, ActionFrame frame) { Debug.Assert(processor != null && frame != null); switch (frame.State) { case Initialized: if(this.nameAvt == null) { frame.StoredOutput = this.name; if(this.name == null) { // name was static but was bad; frame.Finished(); break; } } else { frame.StoredOutput = this.nameAvt.Evaluate(processor, frame); if (! IsProcessingInstructionName(frame.StoredOutput)) { frame.Finished(); break; } } goto case NameReady; case NameReady: Debug.Assert(frame.StoredOutput != null); if (processor.BeginEvent(XPathNodeType.ProcessingInstruction, string.Empty, frame.StoredOutput, string.Empty, false) == false) { // Come back later frame.State = NameReady; break; } processor.PushActionFrame(frame); frame.State = ProcessingChildren; break; // Allow children to run case ProcessingChildren: if (processor.EndEvent(XPathNodeType.ProcessingInstruction) == false) { frame.State = ProcessingChildren; break; } frame.Finished(); break; default: Debug.Fail("Invalid ElementAction execution state"); frame.Finished(); break; } } internal static bool IsProcessingInstructionName(string name) { if (name == null) { return false; } int nameLength = name.Length; int position = 0; XmlCharType xmlCharType = XmlCharType.Instance; while (position < nameLength && xmlCharType.IsWhiteSpace(name[position])) { position ++; } if (position >= nameLength) { return false; } if (position < nameLength && ! xmlCharType.IsStartNCNameChar(name[position])) { return false; } while (position < nameLength && xmlCharType.IsNCNameChar(name[position])) { position ++; } while (position < nameLength && xmlCharType.IsWhiteSpace(name[position])) { position ++; } if (position < nameLength) { return false; } if (nameLength == 3 && (name[0] == CharX || name[0] == Charx) && (name[1] == CharM || name[1] == Charm) && (name[2] == CharL || name[2] == Charl) ) { return false; } return true; } } } // 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
- TreeView.cs
- ScriptDescriptor.cs
- ReservationNotFoundException.cs
- PointAnimationBase.cs
- AutoResetEvent.cs
- SystemUdpStatistics.cs
- ExtractCollection.cs
- PaintEvent.cs
- DrawingAttributes.cs
- BaseTemplateBuildProvider.cs
- SymbolTable.cs
- MonthCalendar.cs
- NumberFormatter.cs
- BuildProvider.cs
- NotificationContext.cs
- HttpInputStream.cs
- RowParagraph.cs
- ApplicationHost.cs
- ArrayHelper.cs
- RoutingChannelExtension.cs
- DataGridItem.cs
- ToolStripPanelDesigner.cs
- EntityDataSourceContainerNameConverter.cs
- WorkflowApplicationEventArgs.cs
- AdornerPresentationContext.cs
- CaseStatementSlot.cs
- AncestorChangedEventArgs.cs
- TextStore.cs
- ObjectDataSourceMethodEventArgs.cs
- Encoder.cs
- AnimationLayer.cs
- ProviderSettingsCollection.cs
- Rule.cs
- NotificationContext.cs
- XmlSecureResolver.cs
- MarshalByRefObject.cs
- Options.cs
- FrameworkElementFactory.cs
- ParserStreamGeometryContext.cs
- ColumnHeaderConverter.cs
- AutoResetEvent.cs
- AttributeEmitter.cs
- AuthenticationConfig.cs
- DateTimeFormatInfo.cs
- Operand.cs
- DataRelation.cs
- GridProviderWrapper.cs
- ColumnHeaderConverter.cs
- Timer.cs
- ContentOperations.cs
- OleDbRowUpdatingEvent.cs
- SiteMapNodeItemEventArgs.cs
- CodeTypeDelegate.cs
- DataGridViewCellCollection.cs
- TypeConverterAttribute.cs
- AnnotationResourceChangedEventArgs.cs
- ProjectionPathBuilder.cs
- MsmqInputSessionChannelListener.cs
- ComponentCommands.cs
- XNameTypeConverter.cs
- FileFormatException.cs
- FilterElement.cs
- ClientScriptManager.cs
- NGCUIElementCollectionSerializerAsync.cs
- DataList.cs
- Setter.cs
- InkCanvas.cs
- UserControlParser.cs
- SectionInformation.cs
- ActivityScheduledQuery.cs
- DataGridViewImageCell.cs
- basecomparevalidator.cs
- ObjectDataSourceEventArgs.cs
- DesignTimeTemplateParser.cs
- ADMembershipProvider.cs
- ProcessProtocolHandler.cs
- DependencyObjectType.cs
- Tracer.cs
- DelimitedListTraceListener.cs
- InputDevice.cs
- NumberSubstitution.cs
- XmlNamespaceManager.cs
- SmtpReplyReaderFactory.cs
- CaseExpr.cs
- ScriptDescriptor.cs
- ThousandthOfEmRealPoints.cs
- RootBrowserWindowAutomationPeer.cs
- TextSelectionHelper.cs
- FakeModelItemImpl.cs
- ComponentResourceKeyConverter.cs
- Keywords.cs
- DnsElement.cs
- Stackframe.cs
- PrinterResolution.cs
- CodeCompiler.cs
- MaterialCollection.cs
- DetailsViewDeletedEventArgs.cs
- ProfileSettingsCollection.cs
- CngKeyCreationParameters.cs
- BaseInfoTable.cs