Inheritance: XmlCharacterData
 private static void AddXmlCDataSection(StringBuilder sb, XmlCDataSection cdata)
 {
     sb.Append(string.Format(@"\cf{0}<![CDATA[\par ", (int)ColorKinds.CData));
     var cdataLines = cdata.Value.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
     sb.Append(string.Join(@"\par", cdataLines));
     sb.Append(@"\par]]>\par");
 }
Exemple #2
1
Fichier : Show.cs Projet : rh/mix
        public void Print(XmlCDataSection section)
        {
            if (SkipText)
            {
                return;
            }

            Context.Output.Write("<![CDATA[{0}]]>", section.Value);
        }
Exemple #3
1
Fichier : Task.cs Projet : rh/mix
 protected virtual void ExecuteCore(XmlCDataSection section)
 {
 }
Exemple #4
0
 protected override void ExecuteCore(XmlCDataSection section)
 {
     Validate();
     var element = section.OwnerDocument.CreateElement(Name);
     element.InnerText = section.Value;
     section.ParentNode.ReplaceChild(element, section);
 }
        public DeltaContainer()
        {
            // Retain for legacy use
            m_DeltaPaths = new List<DeltaPath>();

            // Now offers more functionality over DeltaPath
            m_DeltaFigures = new List<DeltaFigure>();

            XmlDocument doc = new XmlDocument();
            m_Comments = doc.CreateCDataSection(string.Empty);
        }
Exemple #6
0
 /// <summary>
 ///     创建并追加XmlNode的CData节点
 /// </summary>
 /// <param name="childNode">The child node.</param>
 /// <param name="value"></param>
 /// <returns></returns>
 public static void SetCDataElement(this XmlNode childNode, string value)
 {
     if (childNode.OwnerDocument != null)
     {
         XmlCDataSection cd = childNode.OwnerDocument.CreateCDataSection(value);
         childNode.AppendChild(cd);
     }
     else
     {
         Debug.Fail("childNode.OwnerDocument != null");
     }
 }
Exemple #7
0
 private void button1_Click(object sender, EventArgs e)
 {
     System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
     //System.Xml.XmlElement element = xmlDoc.CreateElement("xml",);
     //xmlDoc.Name = "xml";
     //xmlDoc.CreateElement();
     System.Xml.XmlNode node = xmlDoc.CreateNode(System.Xml.XmlNodeType.CDATA, "plan_id", "xml");
     node.Value = "456";
     //xmlDoc.AppendChild(node);
     System.Xml.XmlCDataSection cData = xmlDoc.CreateCDataSection("test");
     label1.Text = cData.ToString();
 }
Exemple #8
0
        protected override void ExecuteCore(XmlCDataSection section)
        {
            Validate();

            var element = section.ParentNode as XmlElement;

            if (element != null && element.Attributes[Name] == null)
            {
                var attribute = section.OwnerDocument.CreateAttribute(Name);
                attribute.Value = section.Value;
                element.Attributes.Append(attribute);
                element.RemoveChild(section);
            }
        }
		public void GetReady ()
		{
			document = new XmlDocument ();
			document.LoadXml ("<root><foo></foo></root>");
			section = document.CreateCDataSection ("CDataSection");
		}
Exemple #10
0
 protected override void ExecuteCore(XmlCDataSection section)
 {
     section.Value = Transform(section.Value);
 }
Exemple #11
0
 protected override void ExecuteCore(XmlCDataSection section)
 {
     section.Value = DoReplace(section.Value);
 }
Exemple #12
0
 protected override void ExecuteCore(XmlCDataSection section)
 {
     section.Value = NewGuid();
 }
Exemple #13
0
        /// <summary>
        ///     向XmlElement里追加一组节点,并设置这组节点的值。
        ///     如:<groups><item value="a"></item><item value="B"></item></groups>
        /// </summary>
        /// <param name="groupEle">将设置的XmlElement</param>
        /// <param name="itemNodeName">子XmlElement的LocalName</param>
        /// <param name="nodeType">数据存储的节点类型,值只能存放在Attribute,CDATA,Text三种类型的节点中</param>
        /// <param name="attributeName">当数据存储类型为Attribute时的属性的LocalName,当其他类型时输入Null</param>
        /// <param name="isRepeat">是否允许有重复的值,true允许,false不允许(如不允许将增加大量的运算时间)</param>
        /// <param name="valueList">值的集合</param>
        public static void AppendGroupItemsValue(this XmlElement groupEle, string itemNodeName, XmlNodeType nodeType, string attributeName, bool isRepeat, List <string> valueList)
        {
            switch (nodeType)
            {
                #region case

            case XmlNodeType.Attribute:
            {
                if (isRepeat)
                {
                    foreach (string value in valueList)
                    {
                        XmlElement item = groupEle.OwnerDocument?.CreateElement(itemNodeName);
                        item?.SetAttribute(attributeName, value);
                        if (item != null)
                        {
                            groupEle.AppendChild(item);
                        }
                    }
                }
                else
                {
                    var vList = new List <string>(GetGroupItemsValue(groupEle, itemNodeName, nodeType, ""));
                    foreach (string value in valueList)
                    {
                        if (!vList.Contains(value))
                        {
                            XmlElement item = groupEle.OwnerDocument.CreateElement(itemNodeName);
                            item.SetAttribute(attributeName, value);
                            groupEle.AppendChild(item);
                        }
                    }
                }
                break;
            }

            case XmlNodeType.CDATA:
            {
                if (isRepeat)
                {
                    foreach (string value in valueList)
                    {
                        XmlElement      item  = groupEle.OwnerDocument.CreateElement(itemNodeName);
                        XmlCDataSection cdata = groupEle.OwnerDocument.CreateCDataSection(value);
                        item.AppendChild(cdata);
                        groupEle.AppendChild(item);
                    }
                }
                else
                {
                    var vList = new List <string>(GetGroupItemsValue(groupEle, itemNodeName, nodeType, ""));
                    foreach (string value in valueList)
                    {
                        if (!vList.Contains(value))
                        {
                            XmlElement      item  = groupEle.OwnerDocument.CreateElement(itemNodeName);
                            XmlCDataSection cdata = groupEle.OwnerDocument.CreateCDataSection(value);
                            item.AppendChild(cdata);
                            groupEle.AppendChild(item);
                        }
                    }
                }
                break;
            }

            case XmlNodeType.Text:
            {
                if (isRepeat)
                {
                    foreach (string value in valueList)
                    {
                        XmlElement item = groupEle.OwnerDocument.CreateElement(itemNodeName);
                        item.InnerText = value;
                        groupEle.AppendChild(item);
                    }
                }
                else
                {
                    var vList = new List <string>(GetGroupItemsValue(groupEle, itemNodeName, nodeType, ""));
                    foreach (string value in valueList)
                    {
                        if (!vList.Contains(value))
                        {
                            XmlElement item = groupEle.OwnerDocument.CreateElement(itemNodeName);
                            item.InnerText = value;
                            groupEle.AppendChild(item);
                        }
                    }
                }
                break;
            }

            default:
                Debug.Fail("值只能存放在Attribute,CDATA,Text三种类型的节点中!");
                break;

                #endregion
            }
        }
Exemple #14
0
	public DvslNodeImpl(XmlCDataSection e) {
	    element = e;
	}
Exemple #15
0
        private XmlNode LoadNodeDirect()
        {
            XmlNode   node2;
            XmlReader reader     = this.reader;
            XmlNode   parentNode = null;

Label_0009:
            node2 = null;
            switch (reader.NodeType)
            {
            case XmlNodeType.Element:
            {
                bool       isEmptyElement = this.reader.IsEmptyElement;
                XmlElement newChild       = new XmlElement(this.reader.Prefix, this.reader.LocalName, this.reader.NamespaceURI, this.doc)
                {
                    IsEmpty = isEmptyElement
                };
                if (this.reader.MoveToFirstAttribute())
                {
                    XmlAttributeCollection attributes = newChild.Attributes;
                    do
                    {
                        XmlAttribute attribute = this.LoadAttributeNodeDirect();
                        attributes.Append(attribute);
                    }while (reader.MoveToNextAttribute());
                }
                if (!isEmptyElement)
                {
                    parentNode.AppendChildForLoad(newChild, this.doc);
                    parentNode = newChild;
                    goto Label_01FC;
                }
                node2 = newChild;
                break;
            }

            case XmlNodeType.Attribute:
                node2 = this.LoadAttributeNodeDirect();
                break;

            case XmlNodeType.Text:
                node2 = new XmlText(this.reader.Value, this.doc);
                break;

            case XmlNodeType.CDATA:
                node2 = new XmlCDataSection(this.reader.Value, this.doc);
                break;

            case XmlNodeType.EntityReference:
                node2 = this.LoadEntityReferenceNode(true);
                break;

            case XmlNodeType.ProcessingInstruction:
                node2 = new XmlProcessingInstruction(this.reader.Name, this.reader.Value, this.doc);
                break;

            case XmlNodeType.Comment:
                node2 = new XmlComment(this.reader.Value, this.doc);
                break;

            case XmlNodeType.Whitespace:
                if (!this.preserveWhitespace)
                {
                    goto Label_01FC;
                }
                node2 = new XmlWhitespace(this.reader.Value, this.doc);
                break;

            case XmlNodeType.SignificantWhitespace:
                node2 = new XmlSignificantWhitespace(this.reader.Value, this.doc);
                break;

            case XmlNodeType.EndElement:
                if (parentNode.ParentNode != null)
                {
                    parentNode = parentNode.ParentNode;
                    goto Label_01FC;
                }
                return(parentNode);

            case XmlNodeType.EndEntity:
                goto Label_01FC;

            default:
                throw UnexpectedNodeType(this.reader.NodeType);
            }
            if (parentNode != null)
            {
                parentNode.AppendChildForLoad(node2, this.doc);
            }
            else
            {
                return(node2);
            }
Label_01FC:
            if (reader.Read())
            {
                goto Label_0009;
            }
            return(null);
        }
Exemple #16
0
        // Used by the ReadNode method for recursively building a DOM subtree.
        internal XmlNode ReadNodeInternal(XmlReader r)
        {
            switch (r.NodeType)
            {
            case XmlNodeType.Attribute:
            {
                // create the attribute
                XmlAttribute att = CreateAttribute
                                       (r.Prefix, r.LocalName, r.NamespaceURI);

                // read and append the children
                ReadChildren(r, att);

                // return the attribute
                return(att);
            }
            // Not reached.

            case XmlNodeType.CDATA:
            {
                // create the character data section
                XmlCDataSection cdata = CreateCDataSection(r.Value);

                // advance the reader to the next node
                r.Read();

                // return the character data section
                return(cdata);
            }
            // Not reached.

            case XmlNodeType.Comment:
            {
                // create the comment
                XmlComment comment = CreateComment(r.Value);

                // advance the reader to the next node
                r.Read();

                // return the comment
                return(comment);
            }
            // Not reached.

            case XmlNodeType.DocumentType:
            {
                // create the document type
                XmlDocumentType doctype = CreateDocumentType
                                              (r.Name, r["PUBLIC"], r["SYSTEM"], r.Value);

                // advance the reader to the next node
                r.Read();

                // return the document type
                return(doctype);
            }
            // Not reached.

            case XmlNodeType.Element:
            {
                // create the element
                XmlElement elem = CreateElement
                                      (r.Prefix, r.LocalName, r.NamespaceURI);
                bool isEmptyElement = r.IsEmptyElement;

                // read the attributes
                while (r.MoveToNextAttribute())
                {
                    XmlAttribute att = (XmlAttribute)ReadNodeInternal(r);
                    elem.SetAttributeNode(att);
                }
                r.MoveToElement();

                // return now if there are no children
                if (isEmptyElement)
                {
                    // advance the reader to the next node
                    r.Read();

                    // return the empty element
                    return(elem);
                }

                elem.IsEmpty = isEmptyElement;

                // read and append the children
                ReadChildren(r, elem);

                // return the element
                return(elem);
            }
            // Not reached.

            case XmlNodeType.DocumentFragment:
            case XmlNodeType.EndElement:
            case XmlNodeType.EndEntity:
            case XmlNodeType.Entity:
            case XmlNodeType.Notation:
            {
                // TODO

                // advance the reader to the next node
                r.Read();

                // nothing to return
                return(null);
            }
            // Not reached.

            case XmlNodeType.EntityReference:
            {
                // create the entity reference
                XmlEntityReference er = CreateEntityReference(r.Name);

                // advance the reader to the next node
                r.Read();

                // return the entity reference
                return(er);
            }
            // Not reached.

            case XmlNodeType.ProcessingInstruction:
            {
                // create the processing instruction
                XmlProcessingInstruction pi = CreateProcessingInstruction
                                                  (r.Name, r.Value);

                // advance the reader to the next node
                r.Read();

                // return the processing instruction
                return(pi);
            }
            // Not reached.

            case XmlNodeType.SignificantWhitespace:
            {
                // create the significant whitespace
                XmlSignificantWhitespace sws = CreateSignificantWhitespace
                                                   (r.Value);

                // advance the reader to the next node
                r.Read();

                // return the significant whitespace
                return(sws);
            }
            // Not reached.

            case XmlNodeType.Text:
            {
                // create the text
                XmlText text = CreateTextNode(r.Value);

                // advance the reader to the next node
                r.Read();

                // return the text
                return(text);
            }
            // Not reached.

            case XmlNodeType.Whitespace:
            {
                // if whitespace preservation is off, skip whitespace
                if (!preserveWhitespace)
                {
                    while (r.Read())
                    {
                        if (r.NodeType != XmlNodeType.Whitespace)
                        {
                            return(null);
                        }
                    }
                    return(null);
                }

                // create the whitespace
                XmlWhitespace ws = CreateWhitespace(r.Value);

                // advance the reader to the next node
                r.Read();

                // return the whitespace
                return(ws);
            }
            // Not reached.

            case XmlNodeType.XmlDeclaration:
            {
                // set up the defaults
                String e = String.Empty;
                String s = String.Empty;

                // read the version
                r.MoveToNextAttribute();

                // read the optional attributes
                if (r.MoveToNextAttribute())
                {
                    if (r.Name == "encoding")
                    {
                        e = r.Value;
                        if (r.MoveToNextAttribute())
                        {
                            s = r.Value;
                        }
                    }
                    else
                    {
                        s = r.Value;
                    }
                }

                // create the xml declaration
                XmlDeclaration xml = CreateXmlDeclaration("1.0", e, s);

                // advance the reader to the next node
                r.Read();

                // return the xml declaration
                return(xml);
            }
            // Not reached.

            default:
            {
                throw new InvalidOperationException(/* TODO */);
            }
                // Not reached.
            }
        }
 IMessage[] ExtractMessages(XmlCDataSection data)
 {
     var messages = new XmlDocument();
     messages.LoadXml(data.Data);
     using (var stream = new MemoryStream())
     {
         messages.Save(stream);
         stream.Position = 0;
         return MessageSerializer.Deserialize(stream);
     }
 }
        public void CoauthorTableOfContents()
        {
            string oneWithFileData = ConfigurationManager.AppSettings["NotebookTableOfContents"];
            string filename        = oneWithFileData.Split('\\').Last().Split('.').First();

            // Upload a document
            SharepointClient.UploadFile(oneWithFileData);
            // Refresh web address
            Browser.Goto(Browser.DocumentAddress);
            // Find document on site
            IWebElement onetoc2           = Browser.webDriver.FindElement(By.CssSelector("a[href*='" + filename + ".onetoc2']"));
            string      DocumentWinHandle = Browser.webDriver.CurrentWindowHandle;

            // Open onetoc2 file in local Onenote App.
            Browser.RClick(onetoc2);
            Browser.Wait(By.LinkText("Open in OneNote"));
            var elementOpenInOneNote = Browser.webDriver.FindElement(By.LinkText("Open in OneNote"));

            Browser.Click(elementOpenInOneNote);
            Utility.WaitForOneNoteDocumentOpenning(filename, false, true);
            // Create a new section in local Onenote App.
            SendKeys.SendWait("^t");
            Thread.Sleep(8000);

            // Refresh web address
            Browser.Goto(Browser.DocumentAddress);
            // Find new create onenote section document on site
            IWebElement onenote = Browser.webDriver.FindElement(By.CssSelector("a[href*='New Section 1.one']"));

            Browser.Click(onenote);
            Thread.Sleep(4000);
            SendKeys.SendWait("New Page");
            //Thread.Sleep(10000);
            Thread.Sleep(3000);
            Browser.Wait(By.Id("WebApplicationFrame"));
            Browser.webDriver.SwitchTo().Frame("WebApplicationFrame");
            // Wait for online edit saved
            Thread.Sleep(3000);
            Browser.Wait(By.XPath("//a[@id='lblSyncStatus-Medium']/span[2][text()='Saving...']"));
            Thread.Sleep(10000);
            Browser.Wait(By.XPath("//a[@id='lblSyncStatus-Medium']/span[2][text()='Saved']"));
            Thread.Sleep(2000);

            // Refresh web address
            Browser.Goto(Browser.DocumentAddress);
            Thread.Sleep(3000);
            onenote = Browser.webDriver.FindElement(By.CssSelector("a[href*='New Section 1.one']"));
            // Open OneNote document in local Onenote App
            Browser.RClick(onenote);
            Thread.Sleep(1000);
            Browser.Wait(By.LinkText("Open in OneNote"));
            elementOpenInOneNote = Browser.webDriver.FindElement(By.LinkText("Open in OneNote"));
            Browser.Click(elementOpenInOneNote);

            // Get the opened OneNote process, and read the page title.
            OneNote.Application oneNoteApp = new OneNote.Application();
            string oneNoteXml;
            var    oneNoteWindow = oneNoteApp.Windows.CurrentWindow;

            oneNoteApp.GetPageContent(oneNoteWindow.CurrentPageId, out oneNoteXml);
            var xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(oneNoteXml);
            var nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);

            nsmgr.AddNamespace("one", "http://schemas.microsoft.com/office/onenote/2013/onenote");
            string titleXpath = "//one:Page/one:Title/one:OE/one:T";

            System.Xml.XmlCDataSection titleNode = xmlDoc.SelectSingleNode(titleXpath, nsmgr).FirstChild as System.Xml.XmlCDataSection;
            // If its title in local Onenote App is not updated and wait.
            while (!titleNode.Value.Contains("New Page"))
            {
                Thread.Sleep(5000);
                oneNoteWindow = oneNoteApp.Windows.CurrentWindow;
                oneNoteApp.GetPageContent(oneNoteWindow.CurrentPageId, out oneNoteXml);
                xmlDoc.LoadXml(oneNoteXml);
                titleNode = xmlDoc.SelectSingleNode(titleXpath, nsmgr).FirstChild as System.Xml.XmlCDataSection;
            }

            // Closed OneNote App.
            oneNoteApp.Windows.CurrentWindow.Active = true;
            SendKeys.SendWait("%{F4}");
            // Delete the new created section document
            SharepointClient.DeleteFile("New Section 1" + ".one");
            // Delete the new upload document
            SharepointClient.DeleteFile(filename + ".onetoc2");
            bool result = FormatConvert.SaveSAZ(TestBase.testResultPath, testName, out file);

            Assert.IsTrue(result, "The saz file should be saved successfully.");
            bool parsingResult = MessageParser.ParseMessageUsingWOPIInspector(file);

            Assert.IsTrue(parsingResult, "Case failed, check the details information in error.txt file.");
        }
        private XmlNode LoadNodeDirect()
        {
            XmlNode node2;
            XmlReader reader = this.reader;
            XmlNode parentNode = null;
        Label_0009:
            node2 = null;
            switch (reader.NodeType)
            {
                case XmlNodeType.Element:
                {
                    bool isEmptyElement = this.reader.IsEmptyElement;
                    XmlElement newChild = new XmlElement(this.reader.Prefix, this.reader.LocalName, this.reader.NamespaceURI, this.doc) {
                        IsEmpty = isEmptyElement
                    };
                    if (this.reader.MoveToFirstAttribute())
                    {
                        XmlAttributeCollection attributes = newChild.Attributes;
                        do
                        {
                            XmlAttribute attribute = this.LoadAttributeNodeDirect();
                            attributes.Append(attribute);
                        }
                        while (reader.MoveToNextAttribute());
                    }
                    if (!isEmptyElement)
                    {
                        parentNode.AppendChildForLoad(newChild, this.doc);
                        parentNode = newChild;
                        goto Label_01FC;
                    }
                    node2 = newChild;
                    break;
                }
                case XmlNodeType.Attribute:
                    node2 = this.LoadAttributeNodeDirect();
                    break;

                case XmlNodeType.Text:
                    node2 = new XmlText(this.reader.Value, this.doc);
                    break;

                case XmlNodeType.CDATA:
                    node2 = new XmlCDataSection(this.reader.Value, this.doc);
                    break;

                case XmlNodeType.EntityReference:
                    node2 = this.LoadEntityReferenceNode(true);
                    break;

                case XmlNodeType.ProcessingInstruction:
                    node2 = new XmlProcessingInstruction(this.reader.Name, this.reader.Value, this.doc);
                    break;

                case XmlNodeType.Comment:
                    node2 = new XmlComment(this.reader.Value, this.doc);
                    break;

                case XmlNodeType.Whitespace:
                    if (!this.preserveWhitespace)
                    {
                        goto Label_01FC;
                    }
                    node2 = new XmlWhitespace(this.reader.Value, this.doc);
                    break;

                case XmlNodeType.SignificantWhitespace:
                    node2 = new XmlSignificantWhitespace(this.reader.Value, this.doc);
                    break;

                case XmlNodeType.EndElement:
                    if (parentNode.ParentNode != null)
                    {
                        parentNode = parentNode.ParentNode;
                        goto Label_01FC;
                    }
                    return parentNode;

                case XmlNodeType.EndEntity:
                    goto Label_01FC;

                default:
                    throw UnexpectedNodeType(this.reader.NodeType);
            }
            if (parentNode != null)
            {
                parentNode.AppendChildForLoad(node2, this.doc);
            }
            else
            {
                return node2;
            }
        Label_01FC:
            if (reader.Read())
            {
                goto Label_0009;
            }
            return null;
        }
Exemple #20
0
 internal DOMCdataSection(XmlCDataSection/*!*/ xmlCDataSection)
 {
     this.XmlCDataSection = xmlCDataSection;
 }
		public void XmlCDataSectionInnerAndOuterXml ()
		{
			section = document.CreateCDataSection ("foo");
			AssertEquals (String.Empty, section.InnerXml);
			AssertEquals ("<![CDATA[foo]]>", section.OuterXml);
		}
Exemple #22
0
        // LoadNodeDirect does not use creator functions on XmlDocument. It is used loading nodes that are children of entity nodes, 
        // because we do not want to let users extend these (if we would allow this, XmlDataDocument would have a problem, because 
        // they do not know that those nodes should not be mapped). It can be also used for an optimized load path when if the 
        // XmlDocument is not extended if XmlDocumentType and XmlDeclaration handling is added.
        private XmlNode LoadNodeDirect()
        {
            XmlReader r = _reader;
            XmlNode parent = null;
            do
            {
                XmlNode node = null;
                switch (r.NodeType)
                {
                    case XmlNodeType.Element:
                        bool fEmptyElement = _reader.IsEmptyElement;
                        XmlElement element = new XmlElement(_reader.Prefix, _reader.LocalName, _reader.NamespaceURI, _doc);
                        element.IsEmpty = fEmptyElement;

                        if (_reader.MoveToFirstAttribute())
                        {
                            XmlAttributeCollection attributes = element.Attributes;
                            do
                            {
                                XmlAttribute attr = LoadAttributeNodeDirect();
                                attributes.Append(attr); // special case for load
                            } while (r.MoveToNextAttribute());
                        }

                        // recursively load all children.
                        if (!fEmptyElement)
                        {
                            parent.AppendChildForLoad(element, _doc);
                            parent = element;
                            continue;
                        }
                        else
                        {
                            node = element;
                            break;
                        }

                    case XmlNodeType.EndElement:
                        Debug.Assert(parent.NodeType == XmlNodeType.Element);
                        if (parent.ParentNode == null)
                        {
                            return parent;
                        }
                        parent = parent.ParentNode;
                        continue;

                    case XmlNodeType.EntityReference:
                        node = LoadEntityReferenceNode(true);
                        break;

                    case XmlNodeType.EndEntity:
                        continue;

                    case XmlNodeType.Attribute:
                        node = LoadAttributeNodeDirect();
                        break;

                    case XmlNodeType.SignificantWhitespace:
                        node = new XmlSignificantWhitespace(_reader.Value, _doc);
                        break;

                    case XmlNodeType.Whitespace:
                        if (_preserveWhitespace)
                        {
                            node = new XmlWhitespace(_reader.Value, _doc);
                        }
                        else
                        {
                            continue;
                        }
                        break;

                    case XmlNodeType.Text:
                        node = new XmlText(_reader.Value, _doc);
                        break;

                    case XmlNodeType.CDATA:
                        node = new XmlCDataSection(_reader.Value, _doc);
                        break;

                    case XmlNodeType.ProcessingInstruction:
                        node = new XmlProcessingInstruction(_reader.Name, _reader.Value, _doc);
                        break;

                    case XmlNodeType.Comment:
                        node = new XmlComment(_reader.Value, _doc);
                        break;

                    default:
                        throw UnexpectedNodeType(_reader.NodeType);
                }

                Debug.Assert(node != null);
                if (parent != null)
                {
                    parent.AppendChildForLoad(node, _doc);
                }
                else
                {
                    return node;
                }
            }
            while (r.Read());

            return null;
        }
Exemple #23
0
Fichier : Show.cs Projet : rh/mix
 protected override void ExecuteCore(XmlCDataSection section)
 {
     Print(section);
 }
 /// <summary>
 /// Posts the process set C data.
 /// </summary>
 /// <param name="m_cdata">The m_cdata.</param>
 protected virtual void PostProcessSetCData(XmlCDataSection m_cdata)
 {
 }
Exemple #25
0
        private XmlNode LoadEntityChildren() {
            XmlNode node = null;

            // We do not use creator functions on XmlDocument, b/c we do not want to let users extend the nodes that are children of entity nodes (also, if we do
            // this, XmlDataDocument will have a problem, b/c they do not know that those nodes should not be mapped).
            switch (reader.NodeType) {
                case XmlNodeType.EndElement:
                case XmlNodeType.EndEntity:
                    break;

                case XmlNodeType.Element: {
                    bool fEmptyElement = reader.IsEmptyElement;

                    XmlElement element = new XmlElement( reader.Prefix, reader.LocalName, reader.NamespaceURI, this.doc );
                    element.IsEmpty = fEmptyElement;

                    while(reader.MoveToNextAttribute()) {
                        XmlAttribute attr = (XmlAttribute) LoadEntityChildren();
                        element.Attributes.Append( attr );
                    }

                    // recursively load all children.
                    if (! fEmptyElement)
                        LoadEntityChildren( element );

                    node = element;
                    break;
                }

                case XmlNodeType.Attribute:
                    if (reader.IsDefault) {
                        XmlUnspecifiedAttribute attr = new XmlUnspecifiedAttribute( reader.Prefix, reader.LocalName, reader.NamespaceURI, this.doc );
                        LoadEntityAttributeChildren( attr );
                        attr.SetSpecified( false );
                        node = attr;
                    }
                    else {
                        XmlAttribute attr = new XmlAttribute( reader.Prefix, reader.LocalName, reader.NamespaceURI, this.doc );
                        LoadEntityAttributeChildren( attr );
                        node = attr;
                    }
                    break;

                case XmlNodeType.SignificantWhitespace:
                    node = new XmlSignificantWhitespace( reader.Value, this.doc );
                    break;

                case XmlNodeType.Whitespace:
                    if ( preserveWhitespace )
                        node = new XmlWhitespace( reader.Value, this.doc );
                    else {
                        // if preserveWhitespace is false skip all subsequent WS nodes and position on the first non-WS node
                        do {
                            if (! reader.Read() )
                                return null;
                        } while (reader.NodeType == XmlNodeType.Whitespace);
                        node = LoadEntityChildren();   // Skip WS node if preserveWhitespace is false
                    }
                    break;

                case XmlNodeType.Text:
                    node = new XmlText( reader.Value, this.doc );
                    break;

                case XmlNodeType.CDATA:
                    node = new XmlCDataSection( reader.Value, this.doc );
                    break;

                case XmlNodeType.EntityReference:{
                    XmlEntityReference eref = new XmlEntityReference( reader.Name, this.doc );
                    if ( reader.CanResolveEntity ) {
                        reader.ResolveEntity();
                        LoadEntityChildren( eref );
                        //what if eref doesn't have children at all? should we just put a Empty String text here?
                        if ( eref.ChildNodes.Count == 0 )
                            eref.AppendChild( new XmlText("") );
                    }
                    node = eref;
                    break;
                }

                case XmlNodeType.ProcessingInstruction:
                    node = new XmlProcessingInstruction( reader.Name, reader.Value, this.doc );
                    break;

                case XmlNodeType.Comment:
                    node = new XmlComment( reader.Value, this.doc );
                    break;

                default:
                    throw new InvalidOperationException(string.Format(Res.GetString(Res.Xdom_Load_NodeType),reader.NodeType.ToString()));
            }

            return node;
        }
Exemple #26
0
 protected override void ExecuteCore(XmlCDataSection section)
 {
     var text = section.OwnerDocument.CreateTextNode(section.Value);
     section.ParentNode.ReplaceChild(text, section);
 }
Exemple #27
0
		internal XamlTextValue(XamlDocument document, XmlCDataSection cDataSection, XmlSpace xmlSpace)
		{
			this.document = document;
			this.xmlSpace = xmlSpace;
			this.cDataSection = cDataSection;
		}
        /// <summary>
        /// Contexts the switch.
        /// </summary>
        /// <param name="newState">The new state.</param>
        protected virtual void ContextSwitch(State newState)
        {
            // Process the old state
            if (m_sb.Length > 0)
            {
                string token = m_sb.ToString();

                // this is the LAST state
                switch (m_state)
                {
                    case State.CloseElement:
                        token = PrepareElementName(token);
                        if (token != null)
                        {
                            string ns = TryApplyPrefixAndNamespace(ref token);

                            if (m_current.Name.Equals(token, StringComparison.InvariantCultureIgnoreCase))
                            {
                                m_current = m_current.ParentNode;
                            }
                        }
                        break;

                    case State.StartEntity:

                        token = PrepareEntityName(token);

                        if (token != null)
                        {
                            string entityValue = ConvertEntityToValue(token);
                            if (entityValue != null)
                            {
                                if (m_attribute != null)
                                {
                                    m_attribute.Value += entityValue;
                                }
                                else
                                {
                                    InternalAppendChild(CreateTextNode(entityValue), false);
                                }
                            }
                            else
                            {
                                if (m_attribute != null)
                                {
                                    m_attribute.Value += "&" + token + ";";
                                }
                                else
                                {
                                    InternalAppendChild(CreateEntityReference(token), false);
                                }
                            }
                        }

                        break;

                    case State.Element:
                    case State.InElement:
                        token = PrepareElementName(token);
                        if (token != null)
                        {
                            XmlElement el;

                            string ns = TryApplyPrefixAndNamespace(ref token);

                            if (m_lastElement != null)
                            {
                                PostProcessElement(m_lastElement);
                            }

                            if (ns == null)
                            {
                                el = CreateElement(token);
                            }
                            else
                            {
                                el = CreateElement(token, ns);
                            }

                            m_lastElement = el;

                            if (AddNewElementToParent(el))
                            {
                                m_current = m_current.ParentNode;
                            }

                            InternalAppendChild(el, !FinishNewElement(el));
                        }
                        break;

                    case State.StartAttribute:
                        m_attribute = CreateAttribute(token);

                        if (m_attributeTarget != null)
                        {
                            m_attributeTarget.Attributes.SetNamedItem(m_attribute);
                        }
                        else
                        {
                            m_current.Attributes.SetNamedItem(m_attribute);
                        }

                        break;

                    case State.StartAttributeValue:
                        m_attribute.Value += token;
                        PostProcessSetAttributeValue(m_attribute);
                        break;

                    case State.None:
                    case State.EndElement:
                    case State.EndComment:
                    case State.EndCDATA:
                        if (newState == State.StartAttributeValue)
                        {
                            m_attribute.Value += token;
                        }
                        else
                        {
                            if (m_isAllWhitespace)
                            {
                                InternalAppendChild(CreateWhitespace(token), false);
                            }
                            else
                            {
                                InternalAppendChild(CreateTextNode(token), false);
                            }
                        }
                        break;

                    case State.InComment:
                        SetCommentData(m_comment, token);
                        PostProcessSetCommentData(m_comment);
                        break;

                    case State.InCDATA:
                        m_cdata.Data = token;
                        PostProcessSetCData(m_cdata);
                        break;

                    default:
                        break;
                }
            }

            if (newState == State.EndElement || newState == State.EndElementImmediate)
            {
                m_attribute = null;
            }

            // now check the NEW state
            switch (newState)
            {
                case State.Finished:
                    if (m_lastElement != null)
                    {
                        PostProcessElement(m_lastElement);
                    }
                    if (DocumentElement == null)
                    {
                        m_current.AppendChild(GetDefaultDocumentNode());
                    }
                    break;
                case State.EndElementImmediate:
                    if (m_lastElement == null || !FinishNewElement(m_lastElement))
                    {
                        m_current = m_current.ParentNode;
                    }
                    break;
                case State.StartAttribute:
                    m_attributeValueMatch = '\0';
                    break;
                case State.StartExclamationPoint:

                    m_comment = CreateComment(null);
                    InternalAppendChild(m_comment, false);

                    break;

                case State.InCDATA:
                    m_cdata = CreateCDataSection(null);
                    InternalAppendChild(m_cdata, false);
                    break;
            }

            ResetAfterContextSwitch();

            m_state = newState;
        }
        /// <summary>
        /// Coauther OneNote file WithoutConflict
        /// </summary>
        /// <param name="filename">The coauthered OneNote file name</param>
        public static void OneNoteCoauthorWithoutConflict(string oneNote)
        {
            string filename = oneNote.Split('\\').Last().Split('.').First();

            // Upload a document
            SharepointClient.UploadFile(oneNote);
            // Refresh web address
            Browser.Goto(Browser.DocumentAddress);
            // Find document on site
            IWebElement document     = Browser.webDriver.FindElement(By.CssSelector("a[href*='" + filename + ".one']"));
            string      curWinHandle = Browser.webDriver.CurrentWindowHandle;

            // Open OneNote document in local Onenote App
            Browser.RClick(document);
            Thread.Sleep(1000);
            Browser.Wait(By.LinkText("Open in OneNote"));
            var elementOpenInOneNote = Browser.webDriver.FindElement(By.LinkText("Open in OneNote"));

            Browser.Click(elementOpenInOneNote);
            Utility.WaitForOneNoteDocumentOpenning(filename, false, true);
            Thread.Sleep(2000);
            SendKeys.SendWait("Local");
            Thread.Sleep(3000);

            // Switch To Web Browser
            Browser.webDriver.SwitchTo().Window(curWinHandle);
            Thread.Sleep(2000);

            // Click OneNote file on Sharepoint Web Server
            Browser.Click(document);
            Thread.Sleep(3000);
            Browser.Wait(By.Id("WebApplicationFrame"));
            Browser.webDriver.SwitchTo().Frame("WebApplicationFrame");
            // Wait for online edit saved
            Thread.Sleep(3000);
            Browser.Wait(By.XPath("//a[@id='lblSyncStatus-Medium']/span[2][text()='Saved']"));
            Thread.Sleep(3000);
            SendKeys.SendWait("Online");
            Thread.Sleep(3000);
            Browser.Wait(By.XPath("//a[@id='lblSyncStatus-Medium']/span[2][text()='Saving...']"));
            Thread.Sleep(10000);
            Browser.Wait(By.XPath("//a[@id='lblSyncStatus-Medium']/span[2][text()='Saved']"));
            Thread.Sleep(5000);


            // Refresh web address
            Browser.Goto(Browser.DocumentAddress);
            Thread.Sleep(2000);
            document = Browser.webDriver.FindElement(By.CssSelector("a[href*='" + filename + ".one']"));
            // Open OneNote document in local Onenote App
            Browser.RClick(document);
            Thread.Sleep(1000);
            Browser.Wait(By.LinkText("Open in OneNote"));
            elementOpenInOneNote = Browser.webDriver.FindElement(By.LinkText("Open in OneNote"));
            Browser.Click(elementOpenInOneNote);
            //Utility.WaitForOneNoteDocumentOpenning(filename, false, true);

            /////////////////////////////////////////////////////////////////////////////////
            // Get the opened OneNote process, and read the page title.
            OneNote.Application oneNoteApp = new OneNote.Application();
            string oneNoteXml;
            var    oneNoteWindow = oneNoteApp.Windows.CurrentWindow;

            oneNoteApp.GetPageContent(oneNoteWindow.CurrentPageId, out oneNoteXml);
            var xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(oneNoteXml);
            var nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);

            nsmgr.AddNamespace("one", "http://schemas.microsoft.com/office/onenote/2013/onenote");
            string titleXpath = "//one:Page/one:Title/one:OE/one:T";

            System.Xml.XmlCDataSection titleNode = xmlDoc.SelectSingleNode(titleXpath, nsmgr).FirstChild as System.Xml.XmlCDataSection;
            // If its title in local Onenote App is not updated and wait.
            while (!titleNode.Value.ToString().Contains("OnlineLocal"))
            {
                Thread.Sleep(5000);
                oneNoteWindow = oneNoteApp.Windows.CurrentWindow;
                oneNoteApp.GetPageContent(oneNoteWindow.CurrentPageId, out oneNoteXml);
                xmlDoc.LoadXml(oneNoteXml);
                titleNode = xmlDoc.SelectSingleNode(titleXpath, nsmgr).FirstChild as System.Xml.XmlCDataSection;
            }
            ///////////////////////////////////////////////////////////////////////////////////
            // Closed OneNote App.


            oneNoteApp.Windows.CurrentWindow.Active = true;
            SendKeys.SendWait("%{F4}");
            // Delete the new upload document
            SharepointClient.DeleteFile(filename + ".one");
        }
 private object[] ExtractMessages(XmlCDataSection data)
 {
     var messages = new XmlDocument();
     messages.LoadXml(data.Data);
     using (var stream = new MemoryStream())
     {
         using (var xmlWriter = new XmlTextWriter(stream, Encoding.UTF8))
         {
             xmlWriter.Formatting = Formatting.None;
             messages.Save(xmlWriter);
             stream.Position = 0;
             return this.messageSerializer.Deserialize(stream);
         }
     }
 }
Exemple #31
0
Fichier : Remove.cs Projet : rh/mix
 protected override void ExecuteCore(XmlCDataSection section)
 {
     section.ParentNode.RemoveChild(section);
 }
Exemple #32
0
        private XmlNode LoadEntityChildren()
        {
            XmlNode node = null;

            // We do not use creator functions on XmlDocument, b/c we do not want to let users extend the nodes that are children of entity nodes (also, if we do
            // this, XmlDataDocument will have a problem, b/c they do not know that those nodes should not be mapped).
            switch (reader.NodeType)
            {
            case XmlNodeType.EndElement:
            case XmlNodeType.EndEntity:
                break;

            case XmlNodeType.Element: {
                bool fEmptyElement = reader.IsEmptyElement;

                XmlElement element = new XmlElement(reader.Prefix, reader.LocalName, reader.NamespaceURI, this.doc);
                element.IsEmpty = fEmptyElement;

                while (reader.MoveToNextAttribute())
                {
                    XmlAttribute attr = (XmlAttribute)LoadEntityChildren();
                    element.Attributes.Append(attr);
                }

                // recursively load all children.
                if (!fEmptyElement)
                {
                    LoadEntityChildren(element);
                }

                node = element;
                break;
            }

            case XmlNodeType.Attribute:
                if (reader.IsDefault)
                {
                    XmlUnspecifiedAttribute attr = new XmlUnspecifiedAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI, this.doc);
                    LoadEntityAttributeChildren(attr);
                    attr.SetSpecified(false);
                    node = attr;
                }
                else
                {
                    XmlAttribute attr = new XmlAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI, this.doc);
                    LoadEntityAttributeChildren(attr);
                    node = attr;
                }
                break;

            case XmlNodeType.SignificantWhitespace:
                node = new XmlSignificantWhitespace(reader.Value, this.doc);
                break;

            case XmlNodeType.Whitespace:
                if (preserveWhitespace)
                {
                    node = new XmlWhitespace(reader.Value, this.doc);
                }
                else
                {
                    // if preserveWhitespace is false skip all subsequent WS nodes and position on the first non-WS node
                    do
                    {
                        if (!reader.Read())
                        {
                            return(null);
                        }
                    } while (reader.NodeType == XmlNodeType.Whitespace);
                    node = LoadEntityChildren();       // Skip WS node if preserveWhitespace is false
                }
                break;

            case XmlNodeType.Text:
                node = new XmlText(reader.Value, this.doc);
                break;

            case XmlNodeType.CDATA:
                node = new XmlCDataSection(reader.Value, this.doc);
                break;

            case XmlNodeType.EntityReference: {
                XmlEntityReference eref = new XmlEntityReference(reader.Name, this.doc);
                if (reader.CanResolveEntity)
                {
                    reader.ResolveEntity();
                    LoadEntityChildren(eref);
                    //what if eref doesn't have children at all? should we just put a Empty String text here?
                    if (eref.ChildNodes.Count == 0)
                    {
                        eref.AppendChild(new XmlText(""));
                    }
                }
                node = eref;
                break;
            }

            case XmlNodeType.ProcessingInstruction:
                node = new XmlProcessingInstruction(reader.Name, reader.Value, this.doc);
                break;

            case XmlNodeType.Comment:
                node = new XmlComment(reader.Value, this.doc);
                break;

            default:
                throw new InvalidOperationException(string.Format(Res.GetString(Res.Xdom_Load_NodeType), reader.NodeType.ToString()));
            }

            return(node);
        }
Exemple #33
0
        // LoadNodeDirect does not use creator functions on XmlDocument. It is used loading nodes that are children of entity nodes,
        // because we do not want to let users extend these (if we would allow this, XmlDataDocument would have a problem, because
        // they do not know that those nodes should not be mapped). It can be also used for an optimized load path when if the
        // XmlDocument is not extended if XmlDocumentType and XmlDeclaration handling is added.
        private XmlNode LoadNodeDirect()
        {
            XmlReader r      = _reader;
            XmlNode   parent = null;

            do
            {
                XmlNode node = null;
                switch (r.NodeType)
                {
                case XmlNodeType.Element:
                    bool       fEmptyElement = _reader.IsEmptyElement;
                    XmlElement element       = new XmlElement(_reader.Prefix, _reader.LocalName, _reader.NamespaceURI, _doc);
                    element.IsEmpty = fEmptyElement;

                    if (_reader.MoveToFirstAttribute())
                    {
                        XmlAttributeCollection attributes = element.Attributes;
                        do
                        {
                            XmlAttribute attr = LoadAttributeNodeDirect();
                            attributes.Append(attr);     // special case for load
                        } while (r.MoveToNextAttribute());
                    }

                    // recursively load all children.
                    if (!fEmptyElement)
                    {
                        parent.AppendChildForLoad(element, _doc);
                        parent = element;
                        continue;
                    }
                    else
                    {
                        node = element;
                        break;
                    }

                case XmlNodeType.EndElement:
                    Debug.Assert(parent.NodeType == XmlNodeType.Element);
                    if (parent.ParentNode == null)
                    {
                        return(parent);
                    }
                    parent = parent.ParentNode;
                    continue;

                case XmlNodeType.EntityReference:
                    node = LoadEntityReferenceNode(true);
                    break;

                case XmlNodeType.EndEntity:
                    continue;

                case XmlNodeType.Attribute:
                    node = LoadAttributeNodeDirect();
                    break;

                case XmlNodeType.SignificantWhitespace:
                    node = new XmlSignificantWhitespace(_reader.Value, _doc);
                    break;

                case XmlNodeType.Whitespace:
                    if (_preserveWhitespace)
                    {
                        node = new XmlWhitespace(_reader.Value, _doc);
                    }
                    else
                    {
                        continue;
                    }
                    break;

                case XmlNodeType.Text:
                    node = new XmlText(_reader.Value, _doc);
                    break;

                case XmlNodeType.CDATA:
                    node = new XmlCDataSection(_reader.Value, _doc);
                    break;

                case XmlNodeType.ProcessingInstruction:
                    node = new XmlProcessingInstruction(_reader.Name, _reader.Value, _doc);
                    break;

                case XmlNodeType.Comment:
                    node = new XmlComment(_reader.Value, _doc);
                    break;

                default:
                    throw UnexpectedNodeType(_reader.NodeType);
                }

                Debug.Assert(node != null);
                if (parent != null)
                {
                    parent.AppendChildForLoad(node, _doc);
                }
                else
                {
                    return(node);
                }
            }while (r.Read());

            return(null);
        }
Exemple #34
0
Fichier : Set.cs Projet : rh/mix
 protected override void ExecuteCore(XmlCDataSection section)
 {
     section.Value = Value;
 }