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);
        }
Esempio n. 2
0
        private static XmlDiffPathNodeList SelectAttributes(
            XmlDiffViewElement parentElement,
            string path)
        {
            Debug.Assert(path[0] == '@');
            var pos = 1;
            var diffPathNodeList = (XmlDiffPathNodeList)null;

            while (true)
            {
                var name = XmlDiffPath.ReadAttrName(path, ref pos);
                if (diffPathNodeList == null)
                {
                    diffPathNodeList = pos != path.Length ? (XmlDiffPathNodeList) new XmlDiffPathMultiNodeList() : (XmlDiffPathNodeList) new XmlDiffPathSingleNodeList();
                }
                var attribute = parentElement.GetAttribute(name);
                if (attribute == null)
                {
                    XmlDiffPath.OnNoMatchingNode(path);
                }
                diffPathNodeList.AddNode((XmlDiffViewNode)attribute);
                if (pos != path.Length)
                {
                    if (path[pos] == '|')
                    {
                        var index = pos + 1;
                        if (path[index] != '@')
                        {
                            XmlDiffPath.OnInvalidExpression(path);
                        }
                        pos = index + 1;
                    }
                    else
                    {
                        XmlDiffPath.OnInvalidExpression(path);
                    }
                }
                else
                {
                    break;
                }
            }
            return(diffPathNodeList);
        }
Esempio n. 3
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;
        }