Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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
                });
            }
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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
                };
            }
        }