Ejemplo n.º 1
0
        /// <summary>
        /// Initialize the internal namespace/xpath managers.
        /// </summary>
        /// <param name="navigator"></param>
        protected virtual void InitializeManagers(XPathNavigator navigator)
        {
            Navigator           = navigator;
            XmlNamespaceManager = new XmlNamespaceManager(Navigator.NameTable);

            // TODO: Any easy way of inject this one??
            NamespaceManager = new BaseNamespaceManager(XmlNamespaceManager);
            if (XPathManager == null)
            {
                XPathManager = new XPathManager(NamespaceManager);
            }
        }
        /// <inheritdoc />
        protected override string QualifyXPath(string xpath, string prefix, string uri = null, int index = -1, bool isAttribute = false)
        {
            // Determine namespace if not provided.
            var ns = uri ?? CurrentNamespace;

            if (isAttribute && string.IsNullOrEmpty(prefix))
            {
                // Don't qualify the default namespace for attributes
                ns = string.Empty;
            }

            return(XPathManager.QualifyXPath(xpath, prefix, ns, index, isAttribute));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Construct the qualified XPath for the supplied path.
        /// </summary>
        /// <param name="xpath">Base XPath to qualify.</param>
        /// <param name="prefix">Prefix to use, must provide to evaluate qualified attributes</param>
        /// <param name="xmlNamespace">XML namespace to apply.</param>
        /// <param name="index">Index if part of a node collection.</param>
        /// <param name="isAttribute">Whether we are accessing a element or attribute.</param>
        /// <returns>The qualified path.</returns>
        protected virtual string QualifyXPath(string xpath, string prefix, string xmlNamespace = null, int index = -1, bool isAttribute = false)
        {
            // Determine namespace if not provided.
            var ns = xmlNamespace ?? CurrentNamespace;

            if (isAttribute && string.IsNullOrEmpty(prefix))
            {
                // Don't qualify the default namespace for attributes
                // TODO: How to inject this, might need schema-qualfied for some apps
                ns = string.Empty;
            }

            return(XPathManager.QualifyXPath(xpath, prefix, ns, index, isAttribute));
        }
        protected virtual IXPathManager CreateXPathManager()
        {
            var xp = new XPathManager(this.NamespaceManager);

            return xp;
        }