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);
     }
 }
Exemple #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);
     }
 }
Exemple #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);
                }
            }
        }
        static XmlDiffPathNodeList SelectAttributes(XmlDiffViewElement parentElement, string path)
        {
            Debug.Assert(path[0] == '@');

            int pos = 1;
            XmlDiffPathNodeList nodeList = null;

            for (;;)
            {
                string name = ReadAttrName(path, ref pos);

                if (nodeList == null)
                {
                    if (pos == path.Length)
                    {
                        nodeList = new XmlDiffPathSingleNodeList();
                    }
                    else
                    {
                        nodeList = new XmlDiffPathMultiNodeList();
                    }
                }

                XmlDiffViewAttribute attr = parentElement.GetAttribute(name);
                if (attr == null)
                {
                    OnNoMatchingNode(path);
                }

                nodeList.AddNode(attr);

                if (pos == path.Length)
                {
                    break;
                }
                else if (path[pos] == '|')
                {
                    pos++;
                    if (path[pos] != '@')
                    {
                        OnInvalidExpression(path);
                    }
                    pos++;
                }
                else
                {
                    OnInvalidExpression(path);
                }
            }

            return(nodeList);
        }
Exemple #5
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);
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Gets the list of child nodes below the position indicated
        /// </summary>
        /// <param name="parentNode">The current node</param>
        /// <param name="path">Proprietary path statement</param>
        /// <param name="startPos">Position in the path statement 
        /// at which to start collecting node objects.</param>
        /// <returns>list of child nodes</returns>
        /// <returns>List of nodes or attributes</returns>
        private static XmlDiffPathNodeList SelectChildNodes(
            XmlDiffViewParentNode parentNode,
            string path,
            int startPos) {
            int pos = startPos;
            XmlDiffPathNodeList nodeList = null;

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

                if (pos == path.Length) {
                    nodeList = new XmlDiffPathSingleNodeList();
                } else {
                    nodeList = new XmlDiffPathMultiNodeList();
                }
                if (nodePos <= 0 || nodePos > parentNode.SourceChildNodesCount) {
                    OnNoMatchingNode(path);
                }
                nodeList.AddNode(parentNode.GetSourceChildNode(nodePos - 1));

                if (pos == path.Length) {
                    break;
                } else if (path[pos] == '|') {
                    pos++;
                } else if (path[pos] == '-') {
                    pos++;
                    int endNodePos = ReadPosition(path, ref pos);
                    if (endNodePos <= 0 || endNodePos > parentNode.SourceChildNodesCount) {
                        OnNoMatchingNode(path);
                    }
                    while (nodePos < endNodePos) {
                        nodePos++;
                        nodeList.AddNode(parentNode.GetSourceChildNode(nodePos - 1));
                    }

                    if (pos == path.Length) {
                        break;
                    } else if (path[pos] == '|') {
                        pos++;
                    } else {
                        OnInvalidExpression(path);
                    }
                }
            }
            return nodeList;
        }
Exemple #7
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;
     }
 }
Exemple #8
0
        /// <summary>
        /// Gets a list of attribute objects based on the location
        /// specified.
        /// </summary>
        /// <param name="parentElement">Node at which to start the path search</param>
        /// <param name="path">Proprietary alphanumeric path statement</param>
        /// <returns>list of attribute objects</returns>
        private static XmlDiffPathNodeList SelectAttributes(
            XmlDiffViewElement parentElement,
            string path) {
            Debug.Assert(path[0] == '@');

            int pos = 1;
            XmlDiffPathNodeList nodeList = null;
            for (; ; ) {
                string name = ReadAttrName(path, ref pos);

                if (nodeList == null) {
                    if (pos == path.Length) {
                        nodeList = new XmlDiffPathSingleNodeList();
                    } else {
                        nodeList = new XmlDiffPathMultiNodeList();
                    }
                }

                XmlDiffViewAttribute attr = parentElement.GetAttribute(name);
                if (attr == null) {
                    OnNoMatchingNode(path);
                }
                nodeList.AddNode(attr);

                if (pos == path.Length) {
                    break;
                } else if (path[pos] == '|') {
                    pos++;
                    if (path[pos] != '@') {
                        OnInvalidExpression(path);
                    }
                    pos++;
                } else {
                    OnInvalidExpression(path);
                }
            }
            return nodeList;
        }
Exemple #9
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;
     }
 }
        static XmlDiffPathNodeList SelectChildNodes(XmlDiffViewParentNode parentNode, string path, int startPos)
        {
            int pos = startPos;
            XmlDiffPathNodeList nodeList = null;

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

                if (pos == path.Length)
                {
                    nodeList = new XmlDiffPathSingleNodeList();
                }
                else
                {
                    nodeList = new XmlDiffPathMultiNodeList();
                }

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

                nodeList.AddNode(parentNode.GetSourceChildNode(nodePos - 1));

                if (pos == path.Length)
                {
                    break;
                }
                else if (path[pos] == '|')
                {
                    pos++;
                }
                else if (path[pos] == '-')
                {
                    pos++;
                    int endNodePos = ReadPosition(path, ref pos);
                    if (endNodePos <= 0 || endNodePos > parentNode._sourceChildNodesCount)
                    {
                        OnNoMatchingNode(path);
                    }

                    while (nodePos < endNodePos)
                    {
                        nodePos++;
                        nodeList.AddNode(parentNode.GetSourceChildNode(nodePos - 1));
                    }

                    if (pos == path.Length)
                    {
                        break;
                    }
                    else if (path[pos] == '|')
                    {
                        pos++;
                    }
                    else
                    {
                        OnInvalidExpression(path);
                    }
                }
            }
            return(nodeList);
        }