public void TextEinfuegen(string rohText, XMLRegelwerk regelwerk, out XmlNode ersatzNode) { string text = regelwerk.EinfuegeTextPreProcessing(rohText, this, out ersatzNode); if (ersatzNode == null) { switch (this.PosAmNode) { case XMLCursorPositionen.CursorAufNodeSelbstVorderesTag: case XMLCursorPositionen.CursorAufNodeSelbstHinteresTag: if (regelwerk.IstDiesesTagAnDieserStelleErlaubt("#PCDATA", this)) { XmlText xmlText2 = this.AktNode.OwnerDocument.CreateTextNode(text); this.AktNode.ParentNode.ReplaceChild(this.AktNode, xmlText2); this.CursorSetzen(xmlText2, XMLCursorPositionen.CursorHinterDemNode); } throw new ApplicationException(string.Format("TextEinfuegen: unbehandelte CursorPos {0}", this.PosAmNode)); case XMLCursorPositionen.CursorHinterDemNode: this.TextZwischenZweiNodesEinfuegen(this.AktNode, this.AktNode.NextSibling, text, regelwerk); break; case XMLCursorPositionen.CursorVorDemNode: this.TextZwischenZweiNodesEinfuegen(this.AktNode.PreviousSibling, this.AktNode, text, regelwerk); break; case XMLCursorPositionen.CursorInDemLeeremNode: if (regelwerk.IstDiesesTagAnDieserStelleErlaubt("#PCDATA", this)) { XmlText xmlText = this.AktNode.OwnerDocument.CreateTextNode(text); this.AktNode.AppendChild(xmlText); this.CursorSetzen(xmlText, XMLCursorPositionen.CursorHinterDemNode); } break; case XMLCursorPositionen.CursorInnerhalbDesTextNodes: { string str = this.AktNode.InnerText.Substring(0, this.PosImTextnode); string str2 = this.AktNode.InnerText.Substring(this.PosImTextnode, this.AktNode.InnerText.Length - this.PosImTextnode); this.AktNode.InnerText = str + text + str2; this.CursorSetzen(this.AktNode, this.PosAmNode, this.PosImTextnode + text.Length); break; } default: throw new ApplicationException(string.Format("TextEinfuegen: Unbekannte CursorPos {0}", this.PosAmNode)); } } }
private void TextZwischenZweiNodesEinfuegen(XmlNode nodeVorher, XmlNode nodeNachher, string text, XMLRegelwerk regelwerk) { if (ToolboxXML.IstTextOderKommentarNode(nodeVorher)) { nodeVorher.InnerText += text; this.CursorSetzen(nodeVorher, XMLCursorPositionen.CursorInnerhalbDesTextNodes, nodeVorher.InnerText.Length); } else if (ToolboxXML.IstTextOderKommentarNode(nodeNachher)) { nodeNachher.InnerText = text + nodeNachher.InnerText; this.CursorSetzen(nodeNachher, XMLCursorPositionen.CursorInnerhalbDesTextNodes, text.Length); } else if (regelwerk.IstDiesesTagAnDieserStelleErlaubt("#PCDATA", this)) { XmlText node = this.AktNode.OwnerDocument.CreateTextNode(text); this.InsertXMLNode(node, regelwerk, false); } }