Пример #1
0
 static XmlDiffPathNodeList SelectAllChildren(XmlDiffViewParentNode parentNode)
 {
     if (parentNode._childNodes == null)
     {
         OnNoMatchingNode("*");
         return(null);
     }
     else if (parentNode._childNodes._nextSibbling == null)
     {
         XmlDiffPathNodeList nodeList = new XmlDiffPathSingleNodeList();
         nodeList.AddNode(parentNode._childNodes);
         return(nodeList);
     }
     else
     {
         XmlDiffPathNodeList nodeList  = new XmlDiffPathMultiNodeList();
         XmlDiffViewNode     childNode = parentNode._childNodes;
         while (childNode != null)
         {
             nodeList.AddNode(childNode);
             childNode = childNode._nextSibbling;
         }
         return(nodeList);
     }
 }
Пример #2
0
 /// <summary>
 /// Gets a list of the attributes for the specifed node
 /// and if applicable, its children.
 /// </summary>
 /// <param name="parentElement">The node which
 /// contains the attributes</param>
 /// <returns>List of attributes</returns>
 private static XmlDiffPathNodeList SelectAllAttributes(
     XmlDiffViewElement parentElement)
 {
     if (parentElement.Attributes == null)
     {
         OnNoMatchingNode("@*");
         return(null);
     }
     else if (parentElement.Attributes.NextSibling == null)
     {
         XmlDiffPathNodeList nodeList = new XmlDiffPathSingleNodeList();
         nodeList.AddNode(parentElement.Attributes);
         return(nodeList);
     }
     else
     {
         XmlDiffPathNodeList  nodeList = new XmlDiffPathMultiNodeList();
         XmlDiffViewAttribute curAttr  = parentElement.Attributes;
         while (curAttr != null)
         {
             nodeList.AddNode(curAttr);
         }
         return(nodeList);
     }
 }
Пример #3
0
        /// <summary>
        /// Gets a list of node objects corresponding to
        /// the proprietary path reference provided.
        /// </summary>
        /// <param name="rootNode">The starting node</param>
        /// <param name="path">Absolute path reference to node of interest</param>
        /// <returns>list of node objects</returns>
        private static XmlDiffPathNodeList SelectAbsoluteNodes(
            XmlDiffViewParentNode rootNode,
            string path)
        {
            Debug.Assert(path[0] == '/');

            int             pos  = 1;
            XmlDiffViewNode node = rootNode;

            for (; ;)
            {
                int startPos = pos;
                int nodePos  = ReadPosition(path, ref pos);

                if (pos == path.Length || path[pos] == '/')
                {
                    if (node.FirstChildNode == null)
                    {
                        OnNoMatchingNode(path);
                    }

                    XmlDiffViewParentNode parentNode = (XmlDiffViewParentNode)node;
                    if (nodePos <= 0 || nodePos > parentNode.
                        SourceChildNodesCount)
                    {
                        OnNoMatchingNode(path);
                    }

                    node = parentNode.GetSourceChildNode(nodePos - 1);

                    if (pos == path.Length)
                    {
                        XmlDiffPathNodeList list = new
                                                   XmlDiffPathSingleNodeList();
                        list.AddNode(node);
                        return(list);
                    }

                    pos++;
                }
                else
                {
                    if (path[pos] == '-' || path[pos] == '|')
                    {
                        if (node.FirstChildNode == null)
                        {
                            OnNoMatchingNode(path);
                        }
                        return(SelectChildNodes(
                                   ((XmlDiffViewParentNode)node),
                                   path,
                                   startPos));
                    }

                    OnInvalidExpression(path);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Gets a list of node objects corresponding to
        /// the proprietary path reference provided. 
        /// </summary>
        /// <param name="rootNode">The starting node</param>
        /// <param name="path">Absolute path reference to node of interest</param>
        /// <returns>list of node objects</returns>
        private static XmlDiffPathNodeList SelectAbsoluteNodes(
            XmlDiffViewParentNode rootNode,
            string path) {
            Debug.Assert(path[0] == '/');

            int pos = 1;
            XmlDiffViewNode node = rootNode;

            for (; ; ) {
                int startPos = pos;
                int nodePos = ReadPosition(path, ref pos);

                if (pos == path.Length || path[pos] == '/') {
                    if (node.FirstChildNode == null) {
                        OnNoMatchingNode(path);
                    }

                    XmlDiffViewParentNode parentNode = (XmlDiffViewParentNode)node;
                    if (nodePos <= 0 || nodePos > parentNode.
                        SourceChildNodesCount) {
                        OnNoMatchingNode(path);
                    }

                    node = parentNode.GetSourceChildNode(nodePos - 1);

                    if (pos == path.Length) {
                        XmlDiffPathNodeList list = new
                            XmlDiffPathSingleNodeList();
                        list.AddNode(node);
                        return list;
                    }

                    pos++;
                } else {
                    if (path[pos] == '-' || path[pos] == '|') {
                        if (node.FirstChildNode == null) {
                            OnNoMatchingNode(path);
                        }
                        return SelectChildNodes(
                            ((XmlDiffViewParentNode)node),
                            path,
                            startPos);
                    }

                    OnInvalidExpression(path);
                }
            }
        }
Пример #5
0
 /// <summary>
 /// Gets a list of all node objects at and below the location
 /// specified.
 /// </summary>
 /// <param name="parentNode">Node at which to start</param>
 /// <returns>list of node objects</returns>
 private static XmlDiffPathNodeList SelectAllChildren(
     XmlDiffViewParentNode parentNode) {
     if (parentNode.ChildNodes == null) {
         OnNoMatchingNode("*");
         return null;
     } else if (parentNode.ChildNodes.NextSibbling == null) {
         XmlDiffPathNodeList nodeList = new XmlDiffPathSingleNodeList();
         nodeList.AddNode(parentNode.ChildNodes);
         return nodeList;
     } else {
         XmlDiffPathNodeList nodeList = new XmlDiffPathMultiNodeList();
         XmlDiffViewNode childNode = parentNode.ChildNodes;
         while (childNode != null) {
             nodeList.AddNode(childNode);
             childNode = childNode.NextSibbling;
         }
         return nodeList;
     }
 }
Пример #6
0
 /// <summary>
 /// Gets a list of the attributes for the specifed node
 /// and if applicable, its children.
 /// </summary>
 /// <param name="parentElement">The node which 
 /// contains the attributes</param>
 /// <returns>List of attributes</returns>
 private static XmlDiffPathNodeList SelectAllAttributes(
     XmlDiffViewElement parentElement) {
     if (parentElement.Attributes == null) {
         OnNoMatchingNode("@*");
         return null;
     } else if (parentElement.Attributes.NextSibbling == null) {
         XmlDiffPathNodeList nodeList = new XmlDiffPathSingleNodeList();
         nodeList.AddNode(parentElement.Attributes);
         return nodeList;
     } else {
         XmlDiffPathNodeList nodeList = new XmlDiffPathMultiNodeList();
         XmlDiffViewAttribute curAttr = parentElement.Attributes;
         while (curAttr != null) {
             nodeList.AddNode(curAttr);
         }
         return nodeList;
     }
 }