private void Stream(XmlCharacterData characterData) { Data.Add(new ClassSeparatorData(typeof(XmlCharacterData))); Data.Add(new IntData("Length", characterData.Length)); Data.Add(new StringData("Data", characterData.Data)); switch (characterData) { case XmlCDataSection dataSection: Stream(dataSection); return; case XmlComment comment: Stream(comment); return; case XmlSignificantWhitespace significantWhitespace: Stream(significantWhitespace); return; case XmlText text: Stream(text); return; case XmlWhitespace whitespace: Stream(whitespace); return; } }
private void Stream(XmlCharacterData charData) { MDataObjs.Add(new ClassSeparator(typeof(XmlCharacterData))); MDataObjs.Add(new Int("Length", charData.Length)); MDataObjs.Add(new String("Data", charData.Data)); switch (charData) { case XmlCDataSection cDataSection: Stream(cDataSection); return; case XmlComment comment: Stream(comment); return; case XmlSignificantWhitespace swSpace: Stream(swSpace); return; case XmlText txt: Stream(txt); return; case XmlWhitespace wSpace: Stream(wSpace); return; } }
private static void AppendNullToXmlCharacterData(XmlCharacterData xmlCharacterData) { var dataBefore = xmlCharacterData.Data; xmlCharacterData.AppendData(null); Assert.Equal(dataBefore, xmlCharacterData.Data); }
public DOMText splitText(int offset) { if (offset < 0 || offset > this.dataLengthImpl) { return(null); } if (!IsAssociated) { return(CreateDOMText(dataImpl.Substring(offset))); } else if (XmlCharacterData is XmlText xmlText) { return((DOMText)Create(xmlText.SplitText(offset))); } else { // In case of XmlWhitespace and XmlSignificantWhitespace int count = this.dataLengthImpl - offset; string splitData = XmlCharacterData.Substring(offset, count); XmlCharacterData.DeleteData(offset, count); XmlText newTextNode = XmlCharacterData.OwnerDocument.CreateTextNode(splitData); XmlCharacterData.ParentNode.InsertAfter(newTextNode, XmlCharacterData); return((DOMText)Create(newTextNode)); } }
protected TextFlowLayout(IContainer parent, XmlCharacterData t, int start) : this(parent, t) { // TODO: L: this is confusing since TrimStart changes ignoreStart TrimStart(start); ignoreStart = 0; Debug.Assert(len > 0, "TextFragment must be non-empty!"); }
static T CreateCharacterNode <T>(XmlCharacterData node, Func <string> resolveInnerText) where T : AbstractSavannahXmlNode, new() { return(new T { TagName = node.Name, InnerText = resolveInnerText() }); }
/// <summary> /// Inserts the specified string at the specified character offset. /// </summary> /// <param name="offset">The position within the string to insert the supplied string data.</param> /// <param name="arg">The string data that is to be inserted into the existing string.</param> public virtual void insertData(int offset, string arg) { if (offset < 0 || offset > XmlCharacterData.Length) { DOMException.Throw(ExceptionCode.IndexOutOfBounds); } XmlCharacterData.InsertData(offset, arg); }
/// <summary> /// Removes a range of characters from the node. /// </summary> /// <param name="offset">The position within the string to start deleting.</param> /// <param name="count">The number of characters to delete.</param> /// <returns><B>True</B> or <B>false</B>.</returns> public virtual void deleteData(int offset, int count) { if (offset < 0 || count < 0 || offset > XmlCharacterData.Length) { DOMException.Throw(ExceptionCode.IndexOutOfBounds); } XmlCharacterData.DeleteData(offset, count); }
/// <summary> /// Replaces the specified number of characters starting at the specified offset with the specified string. /// </summary> /// <param name="offset">The position within the string to start replacing.</param> /// <param name="count">The number of characters to replace.</param> /// <param name="arg">The new data that replaces the old string data.</param> /// <returns><B>True</B> or <B>false</B>.</returns> public virtual void replaceData(int offset, int count, string arg) { if (offset < 0 || count < 0 || offset > length) { DOMException.Throw(ExceptionCode.IndexOutOfBounds); } XmlCharacterData.ReplaceData(offset, count, arg); }
public TextLayoutBase(IContainer parent, XmlCharacterData t) : base(parent) { width = -1; height = -1; ascent = -1; textNode = t; len = t.Value.Length; }
/// <summary> /// Internals the append child. /// </summary> /// <param name="child">The child.</param> /// <param name="mayHaveChildren">if set to <c>true</c> [may have children].</param> protected override void InternalAppendChild(XmlNode child, bool mayHaveChildren) { if (m_current != null) { if (child.NodeType == XmlNodeType.Element && child.Name.ToLower() == "option") { // try to find the parent SELECT if (m_current.NodeType != XmlNodeType.Element || m_current.Name.ToLower() != "select") { bool found = false; XmlNode cur = m_current; while (cur != null && cur != this) { if (cur.NodeType == XmlNodeType.Element && cur.Name.ToLower() == "select") { found = true; break; } cur = cur.ParentNode; } if (found) { m_current = cur; } } } else if (m_current.NodeType == XmlNodeType.Element && m_current.Name.ToLower() == "script" && child.NodeType != XmlNodeType.CDATA && child.NodeType != XmlNodeType.Comment && child.NodeType != XmlNodeType.Whitespace && child.NodeType != XmlNodeType.SignificantWhitespace) { // wrap <SCRIPT> innards with a comment if they're not already wrapped by a comment or CDATA section m_current = m_current.AppendChild(CreateComment(null)); XmlCharacterData charData = child as XmlCharacterData; if (charData != null) { ((XmlComment)m_current).Value += charData.Value; return; } } else if (m_current.NodeType == XmlNodeType.Comment) { XmlCharacterData charData = child as XmlCharacterData; if (charData != null) { ((XmlComment)m_current).Value += charData.Value; return; } else { m_current = m_current.ParentNode; } } } base.InternalAppendChild(child, mayHaveChildren); }
public virtual string substringData(int offset, int count) { if (offset < 0 || count < 0 || offset > XmlCharacterData.Length) { DOMException.Throw(ExceptionCode.IndexOutOfBounds); return(null); } return(XmlCharacterData.Substring(offset, count)); }
/// <summary> /// Compares textual content. /// </summary> private ComparisonState CompareCharacterData(XmlCharacterData control, XPathContext controlContext, XmlCharacterData test, XPathContext testContext) { return(Compare(new Comparison(ComparisonType.TEXT_VALUE, control, GetXPath(controlContext), control.Data, GetParentXPath(controlContext), test, GetXPath(testContext), test.Data, GetParentXPath(testContext)))); }
public bool insertData(int offset, string arg) { if (offset < 0 || offset > XmlCharacterData.Length) { DOMException.Throw(ExceptionCode.IndexOutOfBounds); return(false); } XmlCharacterData.InsertData(offset, arg); return(true); }
public bool deleteData(int offset, int count) { if (offset < 0 || count < 0 || offset > XmlCharacterData.Length) { DOMException.Throw(ExceptionCode.IndexOutOfBounds); return(false); } XmlCharacterData.DeleteData(offset, count); return(true); }
public bool replaceData(int offset, int count, string arg) { if (offset < 0 || count < 0 || offset > length) { DOMException.Throw(ExceptionCode.IndexOutOfBounds); return(false); } XmlCharacterData.ReplaceData(offset, count, arg); return(true); }
/// <summary> /// text --> UsefulContent /// comment --> MeaninglessJunk /// </summary> /// <param name="o"></param> /// <returns></returns> private InformationType EvaluateInformationType(XmlCharacterData o) { if (o is XmlText) { return(InformationType.UsefulContent); } else if (o is XmlComment) { return(InformationType.MeaninglessJunk); } else { return(InformationType.NeutralData); } }
private void AppendText(StringBuilder sb, XmlCharacterData aNode) { sb.Append("<") .Append(aNode.ParentNode.Name) .Append(" ...>"); if (aNode is XmlCDataSection) { sb.Append("<![CDATA[") .Append(aNode.Value) .Append("]]>"); } else { sb.Append(aNode.Value); } sb.Append("</") .Append(aNode.ParentNode.Name) .Append(">"); }
/// <summary> /// Appends the specified string to the end of the character data of the node. /// </summary> /// <param name="arg">The string to insert into the existing string.</param> public virtual void appendData(string arg) => XmlCharacterData.AppendData(arg);
void ValidateText(XmlCharacterData text) { this.nsResolver.Context = text; CheckCharacters(); validator.ValidateText(new XmlValueGetter(GetText)); }
public TextLiteralLayout(IContainer parent, XmlCharacterData t, int start) : this(parent, t) { TrimStart(start); Debug.Assert(len > 0, "TextFragment must be non-empty!"); }
public TextFlowLayout(IContainer parent, XmlCharacterData t) : base(parent, t) { }
/// <summary> /// This constructor can be used either with proper <see cref="XmlText"/> or with <see cref="XmlWhitespace"/> /// or <see cref="XmlSignificantWhitespace"/>. PHP uses <see cref="DOMText"/> for all these cases. /// </summary> internal DOMText(XmlCharacterData /*!*/ xmlCharacterData) { this.XmlCharacterData = xmlCharacterData; }
private void btSaveUserFile_Click(object sender, EventArgs e) { String kakutyoushi = null; String name = null; String start = null; String end = null; String type = "0"; //入力チェック if (txtKakutyousi.Text.Length == 0) { MessageBox.Show("拡張子が入力されていません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (txtName.Text.Length == 0) { MessageBox.Show("ユーザー設定名が入力されていません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (txtStart.Text.Length == 0) { MessageBox.Show("STARTヘッダが入力されていません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } kakutyoushi = txtKakutyousi.Text; name = txtName.Text; start = txtStart.Text; end = txtEnd.Text; // 同じ設定名だった場合は警告をだす if (true == isExistNameCheack(name)) { MessageBox.Show("ユーザー設定名がすでにあります、別の名前にしてください。", "重複エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // http://msdn.microsoft.com/ja-jp/academic/cc987569.aspx XmlDocument doc = new XmlDocument(); //インスタンスの生成 doc.Load(selectedFileFullPath); //XML文書の読み込み XmlNode root = doc.DocumentElement; //ルートノードの参照 XmlElement elem = doc.CreateElement("attribute"); //要素ノードの作成 root.PrependChild(elem); //ルートノードに要素ノードを付加 elem = doc.CreateElement("type"); root.FirstChild.PrependChild(elem); XmlCharacterData text = doc.CreateTextNode(type); root.FirstChild.FirstChild.PrependChild(text); if (end.Length > 0) { elem = doc.CreateElement("end"); root.FirstChild.PrependChild(elem); text = doc.CreateTextNode(end); root.FirstChild.FirstChild.PrependChild(text); } elem = doc.CreateElement("start"); root.FirstChild.PrependChild(elem); text = doc.CreateTextNode(start); root.FirstChild.FirstChild.PrependChild(text); elem = doc.CreateElement("kakutyoushi"); root.FirstChild.PrependChild(elem); text = doc.CreateTextNode(kakutyoushi); root.FirstChild.FirstChild.PrependChild(text); elem = doc.CreateElement("name"); //要素ノードの作成 root.FirstChild.PrependChild(elem); //ルートノードに要素ノードを付加 text = doc.CreateTextNode(name); //テキストノードの作成 root.FirstChild.FirstChild.PrependChild(text); //作成した要素ノードにテキストノードを付加 doc.Save(selectedFileFullPath); //XMLファイルの保存 MessageBox.Show("項目を追加して保存しました。", "保存確認", MessageBoxButtons.OK, MessageBoxIcon.Information); //リロード listGUIAddNameList(UserXmlLoad(selectedFileFullPath)); // 読み込んだ別ファイルをセーブするのも想定 }
public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { XmlCharacterData node = nodeList.Current as XmlCharacterData; ProcessString(node, node.Value, engine); }
private ulong ComputeHashXmlNode(XmlNode node) { switch (node.NodeType) { case XmlNodeType.Element: { XmlElement el = (XmlElement)node; HashAlgorithm ha = new HashAlgorithm(); HashElement(ha, el.LocalName, el.Prefix, el.NamespaceURI); ComputeHashXmlChildren(ha, el); return(ha.Hash); } case XmlNodeType.Attribute: // attributes are hashed in ComputeHashXmlChildren; Debug.Assert(false); return(0); case XmlNodeType.Whitespace: return(0); case XmlNodeType.SignificantWhitespace: if (!_bIgnoreWhitespace) { goto case XmlNodeType.Text; } return(0); case XmlNodeType.Comment: if (!_bIgnoreComments) { return(HashCharacterNode(XmlNodeType.Comment, ((XmlCharacterData)node).Value)); } return(0); case XmlNodeType.Text: { XmlCharacterData cd = (XmlCharacterData)node; if (_bIgnoreWhitespace) { return(HashCharacterNode(cd.NodeType, XmlDiff.NormalizeText(cd.Value))); } else { return(HashCharacterNode(cd.NodeType, cd.Value)); } } case XmlNodeType.CDATA: { XmlCharacterData cd = (XmlCharacterData)node; return(HashCharacterNode(cd.NodeType, cd.Value)); } case XmlNodeType.ProcessingInstruction: { if (_bIgnorePI) { return(0); } XmlProcessingInstruction pi = (XmlProcessingInstruction)node; return(HashPI(pi.Target, pi.Value)); } case XmlNodeType.EntityReference: { XmlEntityReference er = (XmlEntityReference)node; return(HashER(er.Name)); } case XmlNodeType.XmlDeclaration: { if (_bIgnoreXmlDecl) { return(0); } XmlDeclaration decl = (XmlDeclaration)node; return(HashXmlDeclaration(XmlDiff.NormalizeXmlDeclaration(decl.Value))); } case XmlNodeType.DocumentType: { if (_bIgnoreDtd) { return(0); } XmlDocumentType docType = (XmlDocumentType)node; return(HashDocumentType(docType.Name, docType.PublicId, docType.SystemId, docType.InternalSubset)); } case XmlNodeType.DocumentFragment: return(0); default: Debug.Assert(false); return(0); } }
private static AbstractSavannahXmlNode ConvertXmlCharacterData(XmlCharacterData node, bool isRemoveSpace, int space) {
public bool appendData(string arg) { XmlCharacterData.AppendData(arg); return(true); }
public XmlCharacterDataTreeNode(XmlCharacterData characterData) { this.characterData = characterData; }
private void Serialize(XmlCharacterData node, Stream outStream) { string val = (text.Length == 0 ? node.Value.TrimStart() : node.Value); text.Append(val); }