public static System.Xml.XPath.XPathNodeIterator GetNodeIt(System.Xml.XPath.XPathNavigator xnav, string xPath, System.Xml.XmlNamespaceManager nsmgr)
 {
     System.Xml.XPath.XPathExpression xpathExpr = xnav.Compile(xPath);
     if (nsmgr != null)
     {
         xpathExpr.SetContext(nsmgr);
     }
     return(xnav.Select(xpathExpr));
 }
Example #2
0
        private bool CanCompileXpathExpression(string xpath)
        {
            bool result = false;

            try
            {
                System.Xml.XPath.XPathExpression oXPathExpression = System.Xml.XPath.XPathExpression.Compile(txtXPath.Text);
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Example #3
0
        /// <summary>
        /// Setup Message Content Query for filtering messages
        /// </summary>
        /// <param name="pContext"></param>
        /// <param name="pInMsg"></param>
        private void SetupMessageContentQuery(IPipelineContext pContext, ref IBaseMessage pInMsg)
        {
            //make sure the stream is seekable, otherwise, wrap it in seekable stream
            System.IO.Stream streamWrapper = pInMsg.BodyPart.GetOriginalDataStream();
            if (!pInMsg.BodyPart.GetOriginalDataStream().CanSeek)
            {
                streamWrapper        = new ReadOnlySeekableStream(pInMsg.BodyPart.GetOriginalDataStream());
                pInMsg.BodyPart.Data = streamWrapper;
                pContext.ResourceTracker.AddResource(streamWrapper);
            }

            //clone the stream to prevent XPathNavigator closing the stream
            System.IO.Stream streamClone = new System.IO.MemoryStream(Encoding.UTF8.GetBytes(new System.IO.StreamReader(streamWrapper).ReadToEnd()));
            streamClone.Seek(0, System.IO.SeekOrigin.Begin);
            System.Xml.XPath.XPathNavigator navigator = new System.Xml.XPath.XPathDocument(streamClone).CreateNavigator();

            //perform the queries
            System.Xml.XPath.XPathExpression query = null;
            if (!string.IsNullOrEmpty(XPathQuery1))
            {
                query = navigator.Compile(XPathQuery1);
                isQuery1FoundAndMatch = Convert.ToBoolean(navigator.Evaluate(query));
            }
            if (!string.IsNullOrEmpty(XPathQuery2))
            {
                query = navigator.Compile(XPathQuery2);
                isQuery2FoundAndMatch = Convert.ToBoolean(navigator.Evaluate(query));
            }
            if (!string.IsNullOrEmpty(XPathQuery3))
            {
                query = navigator.Compile(XPathQuery3);
                isQuery3FoundAndMatch = Convert.ToBoolean(navigator.Evaluate(query));
            }
            if (!string.IsNullOrEmpty(XPathQuery4))
            {
                query = navigator.Compile(XPathQuery4);
                isQuery4FoundAndMatch = Convert.ToBoolean(navigator.Evaluate(query));
            }
            if (!string.IsNullOrEmpty(XPathQuery5))
            {
                query = navigator.Compile(XPathQuery5);
                isQuery5FoundAndMatch = Convert.ToBoolean(navigator.Evaluate(query));
            }

            streamWrapper.Seek(0, System.IO.SeekOrigin.Begin);
            pContext.ResourceTracker.AddResource(streamWrapper);
        }
 public static System.Xml.XPath.XPathNodeIterator GetSortedNodeIt(System.Xml.XPath.XPathNavigator xnav, string xPath, System.Xml.XmlNamespaceManager nsmgr, string sortXpath, bool isAscending, bool isCaseSensitive, bool isNumber)
 {
     System.Xml.XPath.XPathExpression xpathExpr = xnav.Compile(xPath);
     System.Xml.XPath.XmlSortOrder    sortOrder;
     System.Xml.XPath.XmlCaseOrder    caseOrder;
     System.Xml.XPath.XmlDataType     datatype;
     if (isAscending)
     {
         sortOrder = System.Xml.XPath.XmlSortOrder.Ascending;
     }
     else
     {
         sortOrder = System.Xml.XPath.XmlSortOrder.Descending;
     }
     if (isCaseSensitive)
     {
         caseOrder = System.Xml.XPath.XmlCaseOrder.UpperFirst;
     }
     else
     {
         caseOrder = System.Xml.XPath.XmlCaseOrder.None;
     }
     if (isNumber)
     {
         datatype = System.Xml.XPath.XmlDataType.Number;
     }
     else
     {
         datatype = System.Xml.XPath.XmlDataType.Text;
     }
     xpathExpr.AddSort(sortXpath, sortOrder, caseOrder, "", datatype);
     if (nsmgr != null)
     {
         xpathExpr.SetContext(nsmgr);
     }
     return(xnav.Select(xpathExpr));
 }
Example #5
0
 public virtual bool Matches(System.Xml.XPath.XPathExpression expr)
 {
     return(default(bool));
 }
Example #6
0
 public virtual object Evaluate(System.Xml.XPath.XPathExpression expr, System.Xml.XPath.XPathNodeIterator context)
 {
     return(default(object));
 }
Example #7
0
 public virtual object Evaluate(System.Xml.XPath.XPathExpression expr)
 {
     return(default(object));
 }
 public virtual System.Xml.XPath.XPathNavigator SelectSingleNode(System.Xml.XPath.XPathExpression expression)
 {
     throw null;
 }
 public virtual System.Xml.XPath.XPathNodeIterator Select(System.Xml.XPath.XPathExpression expr)
 {
     throw null;
 }
 public virtual bool Matches(System.Xml.XPath.XPathExpression expr)
 {
     throw null;
 }
 public virtual object Evaluate(System.Xml.XPath.XPathExpression expr)
 {
     throw null;
 }
Example #12
0
 public override IEnumerable <IPublishedContent> GetByXPath(bool preview, System.Xml.XPath.XPathExpression xpath, XPathVariable[] vars) => throw new NotImplementedException();
 public IEnumerable <IPublishedContent> GetByXPath(UmbracoContext umbracoContext, bool preview, System.Xml.XPath.XPathExpression xpath, Core.Xml.XPathVariable[] vars)
 {
     throw new NotImplementedException();
 }
 public override IPublishedContent GetSingleByXPath(bool preview, System.Xml.XPath.XPathExpression xpath, Core.Xml.XPathVariable[] vars)
 {
     throw new NotImplementedException();
 }
Example #15
0
 public virtual System.Xml.XPath.XPathNodeIterator Select(System.Xml.XPath.XPathExpression expr)
 {
     return(default(System.Xml.XPath.XPathNodeIterator));
 }
Example #16
0
 public virtual System.Xml.XPath.XPathNavigator SelectSingleNode(System.Xml.XPath.XPathExpression expression)
 {
     return(default(System.Xml.XPath.XPathNavigator));
 }
 public virtual object Evaluate(System.Xml.XPath.XPathExpression expr, System.Xml.XPath.XPathNodeIterator context)
 {
     throw null;
 }