Пример #1
0
        protected static string GetTargetXPathRecursive(
            XElement element,
            XmlNamespacePrefixManager nsManager)
        {
            string prefix = nsManager.AddNamespace(element.Name.NamespaceName);

            if (prefix != String.Empty)
            {
                prefix += ":";
            }

            string xpath = "/" + prefix + element.Name.LocalName + Locator.GetLocatorPredicate(element);

            if (element == element.Document.Root)
            {
                return(xpath);
            }
            else
            {
                return(Transform.GetTargetXPathRecursive(element.Parent, nsManager) + xpath);
            }
        }
Пример #2
0
        protected static XPathResult GetTargetXPath(XElement element)
        {
            var locator = Locator.Parse(element);

            if (locator != null && locator.Type == "XPath")
            {
                return(new XPathResult
                {
                    Expression = locator.Arguments,
                    Resolver = new XmlNamespaceManager(new NameTable())
                });
            }
            else
            {
                var    nsManager  = new XmlNamespacePrefixManager(new XmlNamespaceManager(new NameTable()));
                string expression = Transform.GetTargetXPathRecursive(element, nsManager);

                return(new XPathResult
                {
                    Expression = expression,
                    Resolver = nsManager.Manager
                });
            }
        }
Пример #3
0
        protected static string GetTargetXPathRecursive(
            XElement element,
            XmlNamespacePrefixManager nsManager)
        {
            string prefix = nsManager.AddNamespace(element.Name.NamespaceName);

            if (prefix != String.Empty)
                prefix += ":";

            string xpath = "/" + prefix + element.Name.LocalName + Locator.GetLocatorPredicate(element);

            if (element == element.Document.Root)
                return xpath;
            else
                return Transform.GetTargetXPathRecursive(element.Parent, nsManager) + xpath;
        }
Пример #4
0
        protected static XPathResult GetTargetXPath(XElement element)
        {
            var locator = Locator.Parse(element);

            if (locator != null && locator.Type == "XPath")
            {
                return new XPathResult
                {
                    Expression = locator.Arguments,
                    Resolver = new XmlNamespaceManager(new NameTable())
                };
            }
            else
            {
                var nsManager = new XmlNamespacePrefixManager(new XmlNamespaceManager(new NameTable()));
                string expression = Transform.GetTargetXPathRecursive(element, nsManager);

                return new XPathResult
                {
                    Expression = expression,
                    Resolver = nsManager.Manager
                };
            }
        }