public override XmlWriter AppendChild() { switch (this.source.NodeType) { case XmlNodeType.Document: case XmlNodeType.DocumentFragment: case XmlNodeType.Element: { DocumentXmlWriter writer = new DocumentXmlWriter(DocumentXmlWriterType.AppendChild, this.source, this.document) { NamespaceManager = GetNamespaceManager(this.source, this.document) }; return new XmlWellFormedWriter(writer, writer.Settings); } } throw new InvalidOperationException(Res.GetString("Xpn_BadPosition")); }
public override XmlWriter ReplaceRange(XPathNavigator lastSiblingToReplace) { DocumentXPathNavigator that = lastSiblingToReplace as DocumentXPathNavigator; if (that == null) { if (lastSiblingToReplace == null) { throw new ArgumentNullException("lastSiblingToReplace"); } else { throw new NotSupportedException(); } } this.CalibrateText(); that.CalibrateText(); XmlNode node = _source; XmlNode end = that._source; if (node == end) { switch (node.NodeType) { case XmlNodeType.Attribute: case XmlNodeType.Document: case XmlNodeType.DocumentFragment: throw new InvalidOperationException(SR.Xpn_BadPosition); case XmlNodeType.Text: case XmlNodeType.CDATA: case XmlNodeType.SignificantWhitespace: case XmlNodeType.Whitespace: end = that.TextEnd(end); break; default: break; } } else { if (end.IsText()) { end = that.TextEnd(end); } if (!IsFollowingSibling(node, end)) { throw new InvalidOperationException(SR.Xpn_BadPosition); } } DocumentXmlWriter writer = new DocumentXmlWriter(DocumentXmlWriterType.ReplaceToFollowingSibling, node, _document); writer.NamespaceManager = GetNamespaceManager(node.ParentNode, _document); writer.Navigator = this; writer.EndNode = end; return new XmlWellFormedWriter(writer, writer.Settings); }
public override XmlWriter CreateAttributes() { if (_source.NodeType != XmlNodeType.Element) { throw new InvalidOperationException(SR.Xpn_BadPosition); } DocumentXmlWriter writer = new DocumentXmlWriter(DocumentXmlWriterType.AppendAttribute, _source, _document); writer.NamespaceManager = GetNamespaceManager(_source, _document); return new XmlWellFormedWriter(writer, writer.Settings); }
public override XmlWriter InsertBefore() { switch (_source.NodeType) { case XmlNodeType.Attribute: case XmlNodeType.Document: case XmlNodeType.DocumentFragment: throw new InvalidOperationException(SR.Xpn_BadPosition); case XmlNodeType.Text: case XmlNodeType.CDATA: case XmlNodeType.SignificantWhitespace: case XmlNodeType.Whitespace: CalibrateText(); break; default: break; } DocumentXmlWriter writer = new DocumentXmlWriter(DocumentXmlWriterType.InsertSiblingBefore, _source, _document); writer.NamespaceManager = GetNamespaceManager(_source.ParentNode, _document); return new XmlWellFormedWriter(writer, writer.Settings); }
public override XmlWriter AppendChild() { switch (_source.NodeType) { case XmlNodeType.Element: case XmlNodeType.Document: case XmlNodeType.DocumentFragment: break; default: throw new InvalidOperationException(SR.Xpn_BadPosition); } DocumentXmlWriter writer = new DocumentXmlWriter(DocumentXmlWriterType.AppendChild, _source, _document); writer.NamespaceManager = GetNamespaceManager(_source, _document); return new XmlWellFormedWriter(writer, writer.Settings); }
public override XmlWriter InsertBefore() { switch (this.source.NodeType) { case XmlNodeType.Attribute: case XmlNodeType.Document: case XmlNodeType.DocumentFragment: throw new InvalidOperationException(Res.GetString("Xpn_BadPosition")); case XmlNodeType.Text: case XmlNodeType.CDATA: case XmlNodeType.Whitespace: case XmlNodeType.SignificantWhitespace: this.CalibrateText(); break; } DocumentXmlWriter writer = new DocumentXmlWriter(DocumentXmlWriterType.InsertSiblingBefore, this.source, this.document) { NamespaceManager = GetNamespaceManager(this.source.ParentNode, this.document) }; return new XmlWellFormedWriter(writer, writer.Settings); }
public override XmlWriter CreateAttributes() { if (this.source.NodeType != XmlNodeType.Element) { throw new InvalidOperationException(Res.GetString("Xpn_BadPosition")); } DocumentXmlWriter writer = new DocumentXmlWriter(DocumentXmlWriterType.AppendAttribute, this.source, this.document) { NamespaceManager = GetNamespaceManager(this.source, this.document) }; return new XmlWellFormedWriter(writer, writer.Settings); }
public override XmlWriter ReplaceRange(XPathNavigator lastSiblingToReplace) { DocumentXPathNavigator navigator = lastSiblingToReplace as DocumentXPathNavigator; if (navigator == null) { if (lastSiblingToReplace == null) { throw new ArgumentNullException("lastSiblingToReplace"); } throw new NotSupportedException(); } this.CalibrateText(); navigator.CalibrateText(); XmlNode source = this.source; XmlNode node = navigator.source; if (source == node) { switch (source.NodeType) { case XmlNodeType.Attribute: case XmlNodeType.Document: case XmlNodeType.DocumentFragment: throw new InvalidOperationException(Res.GetString("Xpn_BadPosition")); case XmlNodeType.Text: case XmlNodeType.CDATA: case XmlNodeType.Whitespace: case XmlNodeType.SignificantWhitespace: node = navigator.TextEnd(node); break; } } else { if (node.IsText) { node = navigator.TextEnd(node); } if (!IsFollowingSibling(source, node)) { throw new InvalidOperationException(Res.GetString("Xpn_BadPosition")); } } DocumentXmlWriter writer = new DocumentXmlWriter(DocumentXmlWriterType.ReplaceToFollowingSibling, source, this.document) { NamespaceManager = GetNamespaceManager(source.ParentNode, this.document), Navigator = this, EndNode = node }; return new XmlWellFormedWriter(writer, writer.Settings); }
public override XmlWriter InsertAfter() { XmlNode node = source; switch (node.NodeType) { case XmlNodeType.Attribute: case XmlNodeType.Document: case XmlNodeType.DocumentFragment: throw new InvalidOperationException(Res.GetString(Res.Xpn_BadPosition)); case XmlNodeType.Text: case XmlNodeType.CDATA: case XmlNodeType.SignificantWhitespace: case XmlNodeType.Whitespace: node = TextEnd(node); break; default: break; } DocumentXmlWriter writer = new DocumentXmlWriter(DocumentXmlWriterType.InsertSiblingAfter, node, document); writer.NamespaceManager = GetNamespaceManager(node.ParentNode, document); return new XmlWellFormedWriter(writer, writer.Settings); }