AODL.Document.TextDocuments.TextDocument.CreateAttribute C# (CSharp) Method

CreateAttribute() public method

Create a new XmlAttribute for this document.
public CreateAttribute ( string name, string prefix ) : XmlAttribute
name string The attributename.
prefix string The prefixname.
return System.Xml.XmlAttribute
		public XmlAttribute CreateAttribute(string name, string prefix)
		{
			if (this.XmlDoc == null)
				throw new NullReferenceException("There is no XmlDocument loaded. Couldn't create Attribue "+name+" with Prefix "+prefix+". "+this.GetType().ToString());
			string nuri = this.GetNamespaceUri(prefix);
			return this.XmlDoc.CreateAttribute(prefix, name, nuri);
		}

Usage Example

示例#1
0
        /// <summary>
        /// Sets the outline style.
        /// </summary>
        /// <param name="outlineLevel">The outline level.</param>
        /// <param name="numFormat">The num format.</param>
        /// <param name="document">The text document.</param>
        public void SetOutlineStyle(int outlineLevel, string numFormat, TextDocument document)
        {
            try
            {
                XmlNode outlineStyleNode = null;
                foreach (IStyle iStyle in document.CommonStyles)
                {
                    if (iStyle.Node.Name == "text:outline-style")
                    {
                        outlineStyleNode = iStyle.Node;
                    }
                }
//				XmlNode outlineStyleNode		= this.Styles.SelectSingleNode(
//					"//text:outline-style",
//					document.NamespaceManager);

                XmlNode outlineLevelNode = null;
                if (outlineStyleNode != null)
                {
                    outlineLevelNode = outlineStyleNode.SelectSingleNode(
                        "text:outline-level-style[@text:level='" + outlineLevel.ToString() + "']",
                        document.NamespaceManager);
                }

                if (outlineLevelNode != null)
                {
                    XmlNode numberFormatNode = outlineLevelNode.SelectSingleNode(
                        "@style:num-format", document.NamespaceManager);
                    if (numberFormatNode != null)
                    {
                        numberFormatNode.InnerText = numFormat;
                    }

                    XmlAttribute xa = document.CreateAttribute(
                        "num-suffix", "style");
                    xa.InnerText = ".";
                    outlineLevelNode.Attributes.Append(xa);

                    if (outlineLevel > 1)
                    {
                        xa = document.CreateAttribute(
                            "display-levels", "text");
                        xa.InnerText = outlineLevel.ToString();
                        outlineLevelNode.Attributes.Append(xa);
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
All Usage Examples Of AODL.Document.TextDocuments.TextDocument::CreateAttribute