public void LiesAusString(string inhalt) { inhalt = this.AIMLInhaltBereinigen(inhalt); try { this.XML.LoadXml(inhalt); ToolboxXML.WhitespacesBereinigen(this.XML.DocumentElement); } catch (XmlException ex) { throw new AIMLDateiNichtGeladenException(string.Format(ResReader.Reader.GetString("AIMLDateiInhaltlichFehlerhaft"), ex.Message)); } catch (Exception ex2) { throw new AIMLDateiNichtGeladenException(string.Format(ResReader.Reader.GetString("AIMLDateiDefekt"), ex2.Message)); } if (!this.XML.DocumentElement.Name.Equals("aiml")) { throw new AIMLDateiNichtGeladenException(string.Format(ResReader.Reader.GetString("AIMLDateiDefekt"), ResReader.Reader.GetString("DokumentElementNichtAIML"))); } if (this.XML.SelectNodes("/aiml").Count != 1) { throw new AIMLDateiNichtGeladenException(string.Format(ResReader.Reader.GetString("AIMLDateiDefekt"), ResReader.Reader.GetString("DokumentElementAIMLNurEinmal"))); } if (ToolboxSonstiges.IstEntwicklungsmodus) { this.GegenAIMLDTDPruefen(PruefFehlerVerhalten.NiemalsFehlerZeigen); } else { this.GegenAIMLDTDPruefen(PruefFehlerVerhalten.BeiFehlerFragenObAnzeigen); } this.TopicListeBereitstellen(); this.IsChanged = false; }
public void LiesAusString(string inhalt) { inhalt = this.StartUpInhaltBereinigen(inhalt); try { this.XML.LoadXml(inhalt); ToolboxXML.WhitespacesBereinigen((XmlNode)this.XML.DocumentElement); } catch (XmlException ex) { throw new StartupDatei.StartUpDateiNichtGeladenException(string.Format(ResReader.Reader.GetString("StartupDateiInhaltlichFehlerhaft"), (object)ex.Message)); } catch (Exception ex) { throw new StartupDatei.StartUpDateiNichtGeladenException(string.Format(ResReader.Reader.GetString("StartupDateiDefekt"), (object)ex.Message)); } if (!this.XML.DocumentElement.Name.Equals("gaitobot-startup")) { throw new StartupDatei.StartUpDateiNichtGeladenException(string.Format(ResReader.Reader.GetString("StartupDateiDefekt"), (object)ResReader.Reader.GetString("DokumentElementNichtGaitoBotStartup"))); } if (this.XML.SelectNodes("/gaitobot-startup").Count != 1) { throw new StartupDatei.StartUpDateiNichtGeladenException(string.Format(ResReader.Reader.GetString("StartupDateiDefekt"), (object)ResReader.Reader.GetString("DokumentElementStartupNurEinmal"))); } if (ToolboxSonstiges.IstEntwicklungsmodus) { this.GegenStartupDTDPruefen(StartupDatei.PruefFehlerVerhalten.NiemalsFehlerZeigen); } else { this.GegenStartupDTDPruefen(StartupDatei.PruefFehlerVerhalten.BeiFehlerFragenObAnzeigen); } this.IsChanged = false; }
public void SelektionOptimieren() { if (this._startPos.AktNode == null) { return; } if (this._startPos.AktNode == this._endPos.AktNode) { if (this._startPos.PosAmNode > this._endPos.PosAmNode) { XMLCursorPositionen posAmNode = this._startPos.PosAmNode; int posImTextnode = this._startPos.PosImTextnode; this._startPos.CursorSetzen(this._endPos.AktNode, this._endPos.PosAmNode, this._endPos.PosImTextnode); this._endPos.CursorSetzen(this._endPos.AktNode, posAmNode, posImTextnode); } else if (this._startPos.PosAmNode == XMLCursorPositionen.CursorInnerhalbDesTextNodes && this._endPos.PosAmNode == XMLCursorPositionen.CursorInnerhalbDesTextNodes && this._startPos.PosImTextnode > this._endPos.PosImTextnode) { int posImTextnode = this._startPos.PosImTextnode; this._startPos.CursorSetzen(this._startPos.AktNode, XMLCursorPositionen.CursorInnerhalbDesTextNodes, this._endPos.PosImTextnode); this._endPos.CursorSetzen(this._startPos.AktNode, XMLCursorPositionen.CursorInnerhalbDesTextNodes, posImTextnode); } } else { if (ToolboxXML.Node1LiegtVorNode2(this._endPos.AktNode, this._startPos.AktNode)) { XMLCursorPos startPos = this._startPos; this._startPos = this._endPos; this._endPos = startPos; } if (ToolboxXML.IstChild(this._endPos.AktNode, this._startPos.AktNode)) { this.BeideCursorPosSetzen(this._startPos.AktNode, XMLCursorPositionen.CursorAufNodeSelbstVorderesTag); } if (this._startPos.AktNode.ParentNode != this._endPos.AktNode.ParentNode) { XmlNode xmlNode = this.TiefsterGemeinsamerParent(this._startPos.AktNode, this._endPos.AktNode); XmlNode aktNode1 = this._startPos.AktNode; while (aktNode1.ParentNode != xmlNode) { aktNode1 = aktNode1.ParentNode; } XmlNode aktNode2 = this._endPos.AktNode; while (aktNode2.ParentNode != xmlNode) { aktNode2 = aktNode2.ParentNode; } this._startPos.CursorSetzen(aktNode1, XMLCursorPositionen.CursorAufNodeSelbstVorderesTag); this._endPos.CursorSetzen(aktNode2, XMLCursorPositionen.CursorAufNodeSelbstVorderesTag); } } }
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); } }
private void OwnerDocument_NodeChanged(object sender, XmlNodeChangedEventArgs e) { if (e.Node == this._node) { this.BufferLeeren(); } else { switch (e.Action) { case XmlNodeChangedAction.Insert: if (e.NewParent == this._node) { this.BufferLeeren(); break; } if (ToolboxXML.IstChild(e.NewParent, this._node)) { this.BufferLeeren(); } break; case XmlNodeChangedAction.Remove: if (e.OldParent == this._node) { this.BufferLeeren(); break; } if (ToolboxXML.IstChild(e.OldParent, this._node)) { this.BufferLeeren(); } break; case XmlNodeChangedAction.Change: if (ToolboxXML.IstChild(e.Node, this._node)) { this.BufferLeeren(); break; } break; } } }
public void AimldomDokumentVerarbeiten(XmlDocument doc, string aimlDateiname, GaitoBotEigenschaften botEigenschaften) { this.AimlDateiWirdGeladenEvent(aimlDateiname); ToolboxXML.WhitespacesBereinigen(doc.OwnerDocument); XmlNodeList childNodes = doc.DocumentElement.ChildNodes; foreach (XmlNode item in childNodes) { string name = item.Name; if (!(name == "topic")) { if (name == "category") { this.CategoryVerarbeiten(item, aimlDateiname, botEigenschaften); } } else { this.TopicVerarbeiten(item, aimlDateiname, botEigenschaften); } } }
public bool LiegtNodeVorDieserPos(XmlNode node) { return(ToolboxXML.Node1LiegtVorNode2(node, this._aktNode)); }
public bool MoveRight(XmlNode rootnode, XMLRegelwerk regelwerk) { XmlNode aktNode = this.AktNode; switch (this.PosAmNode) { case XMLCursorPositionen.CursorAufNodeSelbstVorderesTag: case XMLCursorPositionen.CursorAufNodeSelbstHinteresTag: this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorHinterDemNode); goto IL_0208; case XMLCursorPositionen.CursorHinterDemNode: if (aktNode.NextSibling != null) { this.CursorSetzen(aktNode.NextSibling, XMLCursorPositionen.CursorVorDemNode); this.MoveRight(rootnode, regelwerk); goto IL_0208; } if (aktNode.ParentNode != rootnode) { this.CursorSetzen(aktNode.ParentNode, XMLCursorPositionen.CursorHinterDemNode); if (!regelwerk.IstSchliessendesTagSichtbar(aktNode.ParentNode)) { this.MoveRight(rootnode, regelwerk); } goto IL_0208; } return(false); case XMLCursorPositionen.CursorInDemLeeremNode: this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorHinterDemNode); goto IL_0208; case XMLCursorPositionen.CursorVorDemNode: if (ToolboxXML.IstTextOderKommentarNode(aktNode)) { if (ToolboxXML.TextAusTextNodeBereinigt(aktNode).Length > 1) { this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorInnerhalbDesTextNodes, 1); } else { this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorHinterDemNode); } } else if (aktNode.ChildNodes.Count < 1) { if (!regelwerk.IstSchliessendesTagSichtbar(aktNode)) { this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorHinterDemNode); } else { this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorInDemLeeremNode); } } else { this.CursorSetzen(aktNode.FirstChild, XMLCursorPositionen.CursorVorDemNode); } goto IL_0208; case XMLCursorPositionen.CursorInnerhalbDesTextNodes: if (ToolboxXML.IstTextOderKommentarNode(aktNode)) { if (ToolboxXML.TextAusTextNodeBereinigt(aktNode).Length > this.PosImTextnode + 1) { this.CursorSetzen(this.AktNode, this.PosAmNode, this.PosImTextnode + 1); } else { this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorHinterDemNode); } goto IL_0208; } throw new ApplicationException(string.Format("XMLCurorPos.MoveRight: CursorPos ist XMLCursorPositionen.CursorInnerhalbDesTextNodes, es ist aber kein Textnode gewählt, sondern der Node {0}", aktNode.OuterXml)); default: { throw new ApplicationException(string.Format("XMLCurorPos.MoveRight: Unbekannte CursorPos {0}", this.PosAmNode)); } IL_0208: return(true); } }
public bool SelektionLoeschen(out XMLCursorPos neueCursorPosNachLoeschen) { if (!this.IstEtwasSelektiert) { neueCursorPosNachLoeschen = this.StartPos.Clone(); return(false); } if (this.StartPos.AktNode == this.EndPos.AktNode) { switch (this.StartPos.PosAmNode) { case XMLCursorPositionen.CursorVorDemNode: if (ToolboxXML.IstTextOderKommentarNode(this.StartPos.AktNode)) { this.StartPos.CursorSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorInnerhalbDesTextNodes, 0); return(this.SelektionLoeschen(out neueCursorPosNachLoeschen)); } this.BeideCursorPosSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorAufNodeSelbstVorderesTag); return(this.SelektionLoeschen(out neueCursorPosNachLoeschen)); case XMLCursorPositionen.CursorAufNodeSelbstVorderesTag: case XMLCursorPositionen.CursorAufNodeSelbstHinteresTag: XmlNode aktNode = this.StartPos.AktNode; XmlNode previousSibling = aktNode.PreviousSibling; XmlNode nextSibling = aktNode.NextSibling; neueCursorPosNachLoeschen = new XMLCursorPos(); if (previousSibling != null && nextSibling != null && (previousSibling is XmlText && nextSibling is XmlText)) { neueCursorPosNachLoeschen.CursorSetzen(previousSibling, XMLCursorPositionen.CursorInnerhalbDesTextNodes, previousSibling.InnerText.Length); previousSibling.InnerText += nextSibling.InnerText; aktNode.ParentNode.RemoveChild(aktNode); nextSibling.ParentNode.RemoveChild(nextSibling); return(true); } if (previousSibling != null) { neueCursorPosNachLoeschen.CursorSetzen(previousSibling, XMLCursorPositionen.CursorHinterDemNode); } else if (nextSibling != null) { neueCursorPosNachLoeschen.CursorSetzen(nextSibling, XMLCursorPositionen.CursorVorDemNode); } else { neueCursorPosNachLoeschen.CursorSetzen(aktNode.ParentNode, XMLCursorPositionen.CursorInDemLeeremNode); } aktNode.ParentNode.RemoveChild(aktNode); return(true); case XMLCursorPositionen.CursorInDemLeeremNode: if (this.EndPos.PosAmNode != XMLCursorPositionen.CursorHinterDemNode && this.EndPos.PosAmNode != XMLCursorPositionen.CursorVorDemNode) { throw new ApplicationException("AuswahlLoeschen:#6363S undefined Endpos " + (object)this.EndPos.PosAmNode + "!"); } XMLCursor xmlCursor1 = new XMLCursor(); xmlCursor1.BeideCursorPosSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorAufNodeSelbstVorderesTag, 0); return(xmlCursor1.SelektionLoeschen(out neueCursorPosNachLoeschen)); case XMLCursorPositionen.CursorInnerhalbDesTextNodes: int posImTextnode = this.StartPos.PosImTextnode; int num = this.EndPos.PosImTextnode; if (this.EndPos.PosAmNode == XMLCursorPositionen.CursorHinterDemNode) { num = this.StartPos.AktNode.InnerText.Length; } if (posImTextnode == 0 && num >= this.StartPos.AktNode.InnerText.Length) { XMLCursor xmlCursor2 = new XMLCursor(); xmlCursor2.BeideCursorPosSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorAufNodeSelbstVorderesTag); return(xmlCursor2.SelektionLoeschen(out neueCursorPosNachLoeschen)); } this.StartPos.AktNode.InnerText = this.StartPos.AktNode.InnerText.Remove(posImTextnode, num - posImTextnode); neueCursorPosNachLoeschen = new XMLCursorPos(); if (posImTextnode == 0) { neueCursorPosNachLoeschen.CursorSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorVorDemNode); } else { neueCursorPosNachLoeschen.CursorSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorInnerhalbDesTextNodes, posImTextnode); } return(true); case XMLCursorPositionen.CursorHinterDemNode: if (ToolboxXML.IstTextOderKommentarNode(this.StartPos.AktNode)) { this.StartPos.CursorSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorInnerhalbDesTextNodes, this.StartPos.AktNode.InnerText.Length); return(this.SelektionLoeschen(out neueCursorPosNachLoeschen)); } this.BeideCursorPosSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorAufNodeSelbstVorderesTag); return(this.SelektionLoeschen(out neueCursorPosNachLoeschen)); default: throw new ApplicationException("AuswahlLoeschen:#63346 StartPos.PosAmNode " + (object)this.StartPos.PosAmNode + " not allowed!"); } } else { while (this.StartPos.AktNode.NextSibling != this.EndPos.AktNode) { this.StartPos.AktNode.ParentNode.RemoveChild(this.StartPos.AktNode.NextSibling); } XMLCursor xmlCursor2 = this.Clone(); xmlCursor2.StartPos.CursorSetzen(this.EndPos.AktNode, XMLCursorPositionen.CursorVorDemNode); XMLCursorPos neueCursorPosNachLoeschen1; xmlCursor2.SelektionLoeschen(out neueCursorPosNachLoeschen1); this.EndPos.CursorSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorHinterDemNode); return(this.SelektionLoeschen(out neueCursorPosNachLoeschen)); } }
public bool MoveLeft(XmlNode rootnode, XMLRegelwerk regelwerk) { XmlNode aktNode = this.AktNode; switch (this.PosAmNode) { case XMLCursorPositionen.CursorVorDemNode: if (aktNode == rootnode) { return(false); } if (aktNode.PreviousSibling != null) { this.CursorSetzen(aktNode.PreviousSibling, XMLCursorPositionen.CursorHinterDemNode); this.MoveLeft(rootnode, regelwerk); break; } this.CursorSetzen(aktNode.ParentNode, XMLCursorPositionen.CursorVorDemNode); break; case XMLCursorPositionen.CursorAufNodeSelbstVorderesTag: case XMLCursorPositionen.CursorAufNodeSelbstHinteresTag: this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorVorDemNode); break; case XMLCursorPositionen.CursorInDemLeeremNode: this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorVorDemNode); break; case XMLCursorPositionen.CursorInnerhalbDesTextNodes: if (!ToolboxXML.IstTextOderKommentarNode(aktNode)) { throw new ApplicationException(string.Format("XMLCursorPos.MoveLeft: CursorPos ist XMLCursorPositionen.CursorInnerhalbDesTextNodes, es ist aber kein Textnode gewählt, sondern der Node {0}", (object)aktNode.OuterXml)); } if (this.PosImTextnode > 1) { this.CursorSetzen(this.AktNode, this.PosAmNode, this.PosImTextnode - 1); break; } this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorVorDemNode); break; case XMLCursorPositionen.CursorHinterDemNode: if (ToolboxXML.IstTextOderKommentarNode(aktNode)) { this.CursorSetzen(aktNode, XMLCursorPositionen.CursorInnerhalbDesTextNodes, Math.Max(0, ToolboxXML.TextAusTextNodeBereinigt(aktNode).Length - 1)); break; } if (aktNode.ChildNodes.Count < 1) { if (regelwerk.IstSchliessendesTagSichtbar(aktNode)) { this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorInDemLeeremNode); } else { this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorVorDemNode); } } else { this.CursorSetzen(aktNode.LastChild, XMLCursorPositionen.CursorHinterDemNode); } break; default: throw new ApplicationException(string.Format("XMLCursorPos.MoveLeft: Unbekannte CursorPos {0}", (object)this.PosAmNode)); } return(true); }