Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / XmlUtils / System / Xml / Xsl / XsltOld / NavigatorOutput.cs / 1 / NavigatorOutput.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 MS.Internal.Xml.Cache; internal class NavigatorOutput : RecordOutput { private XPathDocument doc; private int documentIndex; private XmlRawWriter wr; internal XPathNavigator Navigator { get { return ((IXPathNavigable)doc).CreateNavigator(); } } internal NavigatorOutput(string baseUri) { doc = new XPathDocument(); this.wr = doc.LoadFromWriter(XPathDocument.LoadFlags.AtomizeNames, baseUri); } public Processor.OutputResult RecordDone(RecordBuilder record) { Debug.Assert(record != null); BuilderInfo mainNode = record.MainNode; documentIndex++; switch(mainNode.NodeType) { case XmlNodeType.Element: { wr.WriteStartElement( mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI ); for (int attrib = 0; attrib < record.AttributeCount; attrib ++) { documentIndex++; Debug.Assert(record.AttributeList[attrib] is BuilderInfo); BuilderInfo attrInfo = (BuilderInfo) record.AttributeList[attrib]; if (attrInfo.NamespaceURI == Keywords.s_XmlnsNamespace) { if( attrInfo.Prefix.Length == 0 ) wr.WriteNamespaceDeclaration(string.Empty, attrInfo.Value ); else wr.WriteNamespaceDeclaration( attrInfo.LocalName, attrInfo.Value ); } else { wr.WriteAttributeString( attrInfo.Prefix, attrInfo.LocalName, attrInfo.NamespaceURI, attrInfo.Value ); } } wr.StartElementContent(); if (mainNode.IsEmptyTag) wr.WriteEndElement( mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI ); break; } case XmlNodeType.Text: wr.WriteString( mainNode.Value ); break; case XmlNodeType.Whitespace: break; case XmlNodeType.SignificantWhitespace: wr.WriteString( mainNode.Value ); break; case XmlNodeType.ProcessingInstruction: wr.WriteProcessingInstruction( mainNode.LocalName, mainNode.Value ); break; case XmlNodeType.Comment: wr.WriteComment( mainNode.Value ); break; case XmlNodeType.Document: break; case XmlNodeType.EndElement: wr.WriteEndElement( mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI ); break; default: Debug.Fail("Invalid NodeType on output: " + mainNode.NodeType); break; } record.Reset(); return Processor.OutputResult.Continue; } public void TheEnd() { wr.Close(); } } } // 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 MS.Internal.Xml.Cache; internal class NavigatorOutput : RecordOutput { private XPathDocument doc; private int documentIndex; private XmlRawWriter wr; internal XPathNavigator Navigator { get { return ((IXPathNavigable)doc).CreateNavigator(); } } internal NavigatorOutput(string baseUri) { doc = new XPathDocument(); this.wr = doc.LoadFromWriter(XPathDocument.LoadFlags.AtomizeNames, baseUri); } public Processor.OutputResult RecordDone(RecordBuilder record) { Debug.Assert(record != null); BuilderInfo mainNode = record.MainNode; documentIndex++; switch(mainNode.NodeType) { case XmlNodeType.Element: { wr.WriteStartElement( mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI ); for (int attrib = 0; attrib < record.AttributeCount; attrib ++) { documentIndex++; Debug.Assert(record.AttributeList[attrib] is BuilderInfo); BuilderInfo attrInfo = (BuilderInfo) record.AttributeList[attrib]; if (attrInfo.NamespaceURI == Keywords.s_XmlnsNamespace) { if( attrInfo.Prefix.Length == 0 ) wr.WriteNamespaceDeclaration(string.Empty, attrInfo.Value ); else wr.WriteNamespaceDeclaration( attrInfo.LocalName, attrInfo.Value ); } else { wr.WriteAttributeString( attrInfo.Prefix, attrInfo.LocalName, attrInfo.NamespaceURI, attrInfo.Value ); } } wr.StartElementContent(); if (mainNode.IsEmptyTag) wr.WriteEndElement( mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI ); break; } case XmlNodeType.Text: wr.WriteString( mainNode.Value ); break; case XmlNodeType.Whitespace: break; case XmlNodeType.SignificantWhitespace: wr.WriteString( mainNode.Value ); break; case XmlNodeType.ProcessingInstruction: wr.WriteProcessingInstruction( mainNode.LocalName, mainNode.Value ); break; case XmlNodeType.Comment: wr.WriteComment( mainNode.Value ); break; case XmlNodeType.Document: break; case XmlNodeType.EndElement: wr.WriteEndElement( mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI ); break; default: Debug.Fail("Invalid NodeType on output: " + mainNode.NodeType); break; } record.Reset(); return Processor.OutputResult.Continue; } public void TheEnd() { wr.Close(); } } } // 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
- TrackingProfileDeserializationException.cs
- HttpPostServerProtocol.cs
- initElementDictionary.cs
- TaskResultSetter.cs
- AttributeSetAction.cs
- ApplyImportsAction.cs
- TypeElement.cs
- Point4DConverter.cs
- SerializationInfoEnumerator.cs
- EntityContainerEmitter.cs
- Camera.cs
- SimpleHandlerBuildProvider.cs
- Roles.cs
- TextFormattingConverter.cs
- ContextMarshalException.cs
- COMException.cs
- CodeParameterDeclarationExpressionCollection.cs
- ParameterModifier.cs
- XmlSchemaObject.cs
- FileInfo.cs
- CustomAttribute.cs
- DbProviderFactoriesConfigurationHandler.cs
- TreeViewItem.cs
- UpdatePanelTriggerCollection.cs
- validation.cs
- EntityCommandExecutionException.cs
- StringArrayEditor.cs
- ContextProperty.cs
- CompoundFileStorageReference.cs
- UdpReplyToBehavior.cs
- altserialization.cs
- TypeName.cs
- SubclassTypeValidatorAttribute.cs
- Switch.cs
- XmlValidatingReader.cs
- ProcessModule.cs
- PropertyRef.cs
- AutoGeneratedFieldProperties.cs
- IndentTextWriter.cs
- TreeNodeMouseHoverEvent.cs
- ProxyAttribute.cs
- NetworkInformationException.cs
- mongolianshape.cs
- TabItemWrapperAutomationPeer.cs
- StructuredTypeInfo.cs
- DocumentPageTextView.cs
- VersionUtil.cs
- WSMessageEncoding.cs
- RuntimeUtils.cs
- XmlSchemaComplexContentExtension.cs
- CustomExpressionEventArgs.cs
- ParseElementCollection.cs
- ScrollableControlDesigner.cs
- XXXOnTypeBuilderInstantiation.cs
- BrowserCapabilitiesFactoryBase.cs
- ClockController.cs
- AspNetSynchronizationContext.cs
- XPathParser.cs
- CompilerTypeWithParams.cs
- CompilationLock.cs
- HwndSourceKeyboardInputSite.cs
- MappedMetaModel.cs
- GeneralTransformGroup.cs
- HotCommands.cs
- DocumentViewerBaseAutomationPeer.cs
- SecureEnvironment.cs
- PhysicalOps.cs
- EventlogProvider.cs
- httpserverutility.cs
- DataGridComponentEditor.cs
- EventLogPermissionEntryCollection.cs
- ProxyOperationRuntime.cs
- Point3DCollection.cs
- Comparer.cs
- StreamDocument.cs
- EventSource.cs
- RegexMatch.cs
- HtmlEmptyTagControlBuilder.cs
- safesecurityhelperavalon.cs
- LedgerEntry.cs
- ProtocolViolationException.cs
- InternalCache.cs
- DataGridPageChangedEventArgs.cs
- OracleDateTime.cs
- ObjectConverter.cs
- SqlParameterCollection.cs
- FullTrustAssemblyCollection.cs
- VectorConverter.cs
- EntryIndex.cs
- XmlEntity.cs
- DataBinder.cs
- SliderAutomationPeer.cs
- ImageCollectionEditor.cs
- OAVariantLib.cs
- RuntimeConfigLKG.cs
- DataViewSettingCollection.cs
- FileStream.cs
- httpserverutility.cs
- WebHttpElement.cs
- CompositeTypefaceMetrics.cs