Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / XmlUtils / System / Xml / Xsl / XsltOld / WriterOutput.cs / 1305376 / WriterOutput.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; using System.Collections; internal class WriterOutput : RecordOutput { private XmlWriter writer; private Processor processor; internal WriterOutput(Processor processor, XmlWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } this.writer = writer; this.processor = processor; } // RecordOutput interface method implementation // public Processor.OutputResult RecordDone(RecordBuilder record) { BuilderInfo mainNode = record.MainNode; switch (mainNode.NodeType) { case XmlNodeType.Element: this.writer.WriteStartElement(mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI); WriteAttributes(record.AttributeList, record.AttributeCount); if (mainNode.IsEmptyTag) { this.writer.WriteEndElement(); } break; case XmlNodeType.Text: case XmlNodeType.Whitespace: case XmlNodeType.SignificantWhitespace: this.writer.WriteString(mainNode.Value); break; case XmlNodeType.CDATA: Debug.Assert(false, "XSLT never gives us CDATA"); this.writer.WriteCData(mainNode.Value); break; case XmlNodeType.EntityReference: this.writer.WriteEntityRef(mainNode.LocalName); break; case XmlNodeType.ProcessingInstruction: this.writer.WriteProcessingInstruction(mainNode.LocalName, mainNode.Value); break; case XmlNodeType.Comment: this.writer.WriteComment(mainNode.Value); break; case XmlNodeType.Document: break; case XmlNodeType.DocumentType: this.writer.WriteRaw(mainNode.Value); break; case XmlNodeType.EndElement: this.writer.WriteFullEndElement(); break; case XmlNodeType.None: case XmlNodeType.Attribute: case XmlNodeType.Entity: case XmlNodeType.Notation: case XmlNodeType.DocumentFragment: case XmlNodeType.EndEntity: break; default: Debug.Fail("Invalid NodeType on output: " + mainNode.NodeType); break; } record.Reset(); return Processor.OutputResult.Continue; } public void TheEnd() { this.writer.Flush(); this.writer = null; } private void WriteAttributes(ArrayList list, int count) { Debug.Assert(list.Count >= count); for (int attrib = 0; attrib < count; attrib ++) { Debug.Assert(list[attrib] is BuilderInfo); BuilderInfo attribute = (BuilderInfo) list[attrib]; this.writer.WriteAttributeString(attribute.Prefix, attribute.LocalName, attribute.NamespaceURI, attribute.Value); } } } } // 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; using System.Collections; internal class WriterOutput : RecordOutput { private XmlWriter writer; private Processor processor; internal WriterOutput(Processor processor, XmlWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } this.writer = writer; this.processor = processor; } // RecordOutput interface method implementation // public Processor.OutputResult RecordDone(RecordBuilder record) { BuilderInfo mainNode = record.MainNode; switch (mainNode.NodeType) { case XmlNodeType.Element: this.writer.WriteStartElement(mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI); WriteAttributes(record.AttributeList, record.AttributeCount); if (mainNode.IsEmptyTag) { this.writer.WriteEndElement(); } break; case XmlNodeType.Text: case XmlNodeType.Whitespace: case XmlNodeType.SignificantWhitespace: this.writer.WriteString(mainNode.Value); break; case XmlNodeType.CDATA: Debug.Assert(false, "XSLT never gives us CDATA"); this.writer.WriteCData(mainNode.Value); break; case XmlNodeType.EntityReference: this.writer.WriteEntityRef(mainNode.LocalName); break; case XmlNodeType.ProcessingInstruction: this.writer.WriteProcessingInstruction(mainNode.LocalName, mainNode.Value); break; case XmlNodeType.Comment: this.writer.WriteComment(mainNode.Value); break; case XmlNodeType.Document: break; case XmlNodeType.DocumentType: this.writer.WriteRaw(mainNode.Value); break; case XmlNodeType.EndElement: this.writer.WriteFullEndElement(); break; case XmlNodeType.None: case XmlNodeType.Attribute: case XmlNodeType.Entity: case XmlNodeType.Notation: case XmlNodeType.DocumentFragment: case XmlNodeType.EndEntity: break; default: Debug.Fail("Invalid NodeType on output: " + mainNode.NodeType); break; } record.Reset(); return Processor.OutputResult.Continue; } public void TheEnd() { this.writer.Flush(); this.writer = null; } private void WriteAttributes(ArrayList list, int count) { Debug.Assert(list.Count >= count); for (int attrib = 0; attrib < count; attrib ++) { Debug.Assert(list[attrib] is BuilderInfo); BuilderInfo attribute = (BuilderInfo) list[attrib]; this.writer.WriteAttributeString(attribute.Prefix, attribute.LocalName, attribute.NamespaceURI, attribute.Value); } } } } // 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
- WindowsStatic.cs
- StringAnimationBase.cs
- sqlser.cs
- TypeListConverter.cs
- RoutedEventConverter.cs
- ReferencedAssembly.cs
- WindowInteractionStateTracker.cs
- ProgressiveCrcCalculatingStream.cs
- StringFreezingAttribute.cs
- TypeBuilder.cs
- StorageInfo.cs
- DataGridViewHeaderCell.cs
- Nodes.cs
- SiteMapNode.cs
- Triangle.cs
- FixedSOMContainer.cs
- BitmapEffect.cs
- RuleInfoComparer.cs
- Classification.cs
- MasterPageBuildProvider.cs
- CommonXSendMessage.cs
- XmlChildEnumerator.cs
- ApplicationManager.cs
- AuthenticationConfig.cs
- XMLDiffLoader.cs
- Int32Rect.cs
- SqlComparer.cs
- BackStopAuthenticationModule.cs
- Point3DConverter.cs
- NextPreviousPagerField.cs
- OdbcEnvironmentHandle.cs
- ReferenceService.cs
- BuildManagerHost.cs
- ReadOnlyDataSourceView.cs
- httpserverutility.cs
- DetailsViewPagerRow.cs
- TitleStyle.cs
- SingleConverter.cs
- TableLayout.cs
- Timeline.cs
- SubpageParagraph.cs
- Privilege.cs
- Interlocked.cs
- WindowsFormsSectionHandler.cs
- MediaSystem.cs
- StreamReader.cs
- RequestContextBase.cs
- GPRECT.cs
- StyleSelector.cs
- cookie.cs
- CacheChildrenQuery.cs
- shaperfactoryquerycacheentry.cs
- DataGridViewTopLeftHeaderCell.cs
- ProtocolsConfigurationEntry.cs
- StylusPointProperties.cs
- AggregateNode.cs
- DurableInstanceProvider.cs
- WindowsImpersonationContext.cs
- Soap.cs
- VectorKeyFrameCollection.cs
- DataSourceXmlSerializationAttribute.cs
- EmptyReadOnlyDictionaryInternal.cs
- CheckBoxFlatAdapter.cs
- DataGridViewRowHeaderCell.cs
- XmlSchemaIdentityConstraint.cs
- Int16KeyFrameCollection.cs
- ImageSource.cs
- SerialErrors.cs
- DataControlField.cs
- RIPEMD160.cs
- ElementMarkupObject.cs
- AtomParser.cs
- WebBrowserPermission.cs
- StateBag.cs
- KeyValueConfigurationElement.cs
- CacheEntry.cs
- RowToFieldTransformer.cs
- XmlFormatReaderGenerator.cs
- TextDocumentView.cs
- QueryValue.cs
- EntityType.cs
- DataSysAttribute.cs
- Duration.cs
- RemotingSurrogateSelector.cs
- CommandID.cs
- KeyboardNavigation.cs
- TemplateXamlParser.cs
- ParserOptions.cs
- FrameworkTemplate.cs
- BuildDependencySet.cs
- KeySplineConverter.cs
- FrugalMap.cs
- EmptyElement.cs
- RefreshPropertiesAttribute.cs
- SettingsProperty.cs
- XmlWrappingReader.cs
- WorkflowDebuggerSteppingAttribute.cs
- SafeWaitHandle.cs
- RefExpr.cs
- TextChangedEventArgs.cs