当前位置: 首页>>代码示例>>C#>>正文


C# XPath.XPathExpression类代码示例

本文整理汇总了C#中System.Xml.XPath.XPathExpression的典型用法代码示例。如果您正苦于以下问题:C# XPathExpression类的具体用法?C# XPathExpression怎么用?C# XPathExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XPathExpression类属于System.Xml.XPath命名空间,在下文中一共展示了XPathExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LiveExampleComponent

        public LiveExampleComponent(BuildAssembler assembler, XPathNavigator configuration)
            : base(assembler, configuration) {

            XPathNavigator parsnip_node = configuration.SelectSingleNode("parsnip");
            string approvedFile = null;
            if (parsnip_node != null) {
                approvedFile = parsnip_node.GetAttribute("approved-file", String.Empty);

                string omitBadExamplesValue = parsnip_node.GetAttribute("omit-bad-examples", String.Empty);
                if (!string.IsNullOrEmpty(omitBadExamplesValue))
                    omitBadExamples = Boolean.Parse(omitBadExamplesValue);

                //string runBadExamplesValue = parsnip_node.GetAttribute("run-bad-examples", String.Empty);
                //if (!string.IsNullOrEmpty(runBadExamplesValue))
                //    runBadExamples = Boolean.Parse(runBadExamplesValue);
            }

            if (string.IsNullOrEmpty(approvedFile))
                WriteMessage(MessageLevel.Warn, "No approved samples file specified; all available samples will be included.");
            else
                LoadApprovedFile(approvedFile);

            context = new CustomContext();
            context.AddNamespace("ddue", "http://ddue.schemas.microsoft.com/authoring/2003/5");

            selector = XPathExpression.Compile("//ddue:codeReference");
            selector.SetContext(context);
        }
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:28,代码来源:LiveExampleComponent.cs

示例2: XslSortEvaluator

		public XslSortEvaluator (XPathExpression select, Sort [] sorterTemplates)
		{
			this.select = select;
			this.sorterTemplates = sorterTemplates;
			PopulateConstantSorters ();
			sortRunner = new XPathSorters ();
		}
开发者ID:nobled,项目名称:mono,代码行数:7,代码来源:XslSortEvaluator.cs

示例3: Initialize

        //=====================================================================

        /// <inheritdoc />
        public override void Initialize(XPathNavigator configuration)
        {
            // get the condition
            XPathNavigator condition_element = configuration.SelectSingleNode("switch");

            if(condition_element == null)
                throw new ConfigurationErrorsException("You must specify a condition using the <switch> statement with a 'value' attribute.");

            string condition_value = condition_element.GetAttribute("value", String.Empty);

            if(String.IsNullOrEmpty(condition_value))
                throw new ConfigurationErrorsException("The switch statement must have a 'value' attribute, which is an xpath expression.");

            condition = XPathExpression.Compile(condition_value);

            // load the component stacks for each case
            XPathNodeIterator case_elements = configuration.Select("case");

            foreach(XPathNavigator case_element in case_elements)
            {
                string case_value = case_element.GetAttribute("value", String.Empty);

                cases.Add(case_value, BuildAssembler.LoadComponents(case_element));
            }
        }
开发者ID:armin-bauer,项目名称:SHFB,代码行数:28,代码来源:SwitchComponent.cs

示例4: Initialize

        //=====================================================================

        /// <inheritdoc />
        public override void Initialize(XPathNavigator configuration)
        {
            // Get the condition
            XPathNavigator if_node = configuration.SelectSingleNode("if");

            if(if_node == null)
                throw new ConfigurationErrorsException("You must specify a condition using the <if> element.");

            string condition_xpath = if_node.GetAttribute("condition", String.Empty);

            if(String.IsNullOrEmpty(condition_xpath))
                throw new ConfigurationErrorsException("You must define a condition attribute on the <if> element");

            condition = XPathExpression.Compile(condition_xpath);

            // Construct the true branch
            XPathNavigator then_node = configuration.SelectSingleNode("then");

            if(then_node != null)
                true_branch = BuildAssembler.LoadComponents(then_node);

            // Construct the false branch
            XPathNavigator else_node = configuration.SelectSingleNode("else");

            if(else_node != null)
                false_branch = BuildAssembler.LoadComponents(else_node);

            // Keep a pointer to the context for future use
            context = this.BuildAssembler.Context;
        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:33,代码来源:IfThenComponent.cs

示例5: SaveComponent

		public SaveComponent (BuildAssembler assembler, XPathNavigator configuration) : base(assembler, configuration) {

			// load the target path format
			XPathNavigator save_node = configuration.SelectSingleNode("save");
			if (save_node == null) throw new ConfigurationErrorsException("When instantiating a save component, you must specify a the target file using the <save> element.");

			string base_value = save_node.GetAttribute("base", String.Empty);
			if (!String.IsNullOrEmpty(base_value)) {
				basePath = Path.GetFullPath(Environment.ExpandEnvironmentVariables(base_value));
			}

			string path_value = save_node.GetAttribute("path", String.Empty);
			if (String.IsNullOrEmpty(path_value)) WriteMessage(MessageLevel.Error, "Each save element must have a path attribute specifying an XPath that evaluates to the location to save the file.");
			path_expression = XPathExpression.Compile(path_value);

            string select_value = save_node.GetAttribute("select", String.Empty);
            if (!String.IsNullOrEmpty(select_value))
                select_expression = XPathExpression.Compile(select_value);

            settings.Encoding = Encoding.UTF8;

			string indent_value = save_node.GetAttribute("indent", String.Empty);
			if (!String.IsNullOrEmpty(indent_value)) settings.Indent = Convert.ToBoolean(indent_value);

			string omit_value = save_node.GetAttribute("omit-xml-declaration", String.Empty);
			if (!String.IsNullOrEmpty(omit_value)) settings.OmitXmlDeclaration = Convert.ToBoolean(omit_value);

            linkPath = save_node.GetAttribute("link", String.Empty);
            if (String.IsNullOrEmpty(linkPath)) linkPath = "../html";

			// encoding

			settings.CloseOutput = true;

		}
开发者ID:jongalloway,项目名称:dotnetopenid,代码行数:35,代码来源:SaveComponent.cs

示例6: AddTargets

		private void AddTargets (string map, string input, string baseOutputPath, XPathExpression outputXPath, string link, XPathExpression formatXPath, XPathExpression relativeToXPath) {

			XPathDocument document = new XPathDocument(map);

			XPathNodeIterator items = document.CreateNavigator().Select("/*/item");
			foreach (XPathNavigator item in items) {

				string id = (string) item.Evaluate(artIdExpression);
				string file = (string) item.Evaluate(artFileExpression);
				string text = (string) item.Evaluate(artTextExpression);

				id = id.ToLower();
				string name = Path.GetFileName(file);

				ArtTarget target = new ArtTarget();
				target.Id = id;
				target.InputPath = Path.Combine(input, file);
				target.baseOutputPath = baseOutputPath;
                target.OutputXPath = outputXPath;
                
                if (string.IsNullOrEmpty(name)) target.LinkPath = link;
                else target.LinkPath = string.Format("{0}/{1}", link, name);
                
				target.Text = text;
                target.Name = name;
                target.FormatXPath = formatXPath;
                target.RelativeToXPath = relativeToXPath;

				targets[id] = target;
				// targets.Add(id, target);
            }

	    }
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:33,代码来源:ResolveArtLinksComponent.cs

示例7: Select

        public override XPathNodeIterator Select(XPathExpression expr)
        {
            if (Queryables.ContainsKey(expr.Expression))
                return new XPathQueryableIterator(Queryables[expr.Expression]);

            return base.Select(expr);
        }
开发者ID:mcartoixa,项目名称:GeoSIK,代码行数:7,代码来源:XPathQueryableNavigator.cs

示例8: XPathSelectionIterator

 public XPathSelectionIterator(XPathNavigator nav, XPathExpression expr) {
     this.nav = nav.Clone();
     query = ((CompiledXpathExpr) expr).QueryTree;
     if (query.ReturnType() != XPathResultType.NodeSet) {
         throw new XPathException(Res.Xp_NodeSetExpected);
     }
     query.setContext(nav.Clone());
 }
开发者ID:ArildF,项目名称:masters,代码行数:8,代码来源:xpathselectioniterator.cs

示例9: SharedContentElement

        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="path">The path expression</param>
        /// <param name="item">The item name expression</param>
        /// <param name="parameters">The parameters expression</param>
        /// <param name="attribute">The attribute name expression</param>
        /// <param name="context">The context to use for the XPath expressions</param>
        public SharedContentElement(string path, string item, string parameters, string attribute,
          IXmlNamespaceResolver context)
        {
            this.Path = XPathExpression.Compile(path, context);
            this.Item = XPathExpression.Compile(item, context);
            this.Parameters = XPathExpression.Compile(parameters, context);
            this.Attribute = XPathExpression.Compile(attribute, context);
        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:18,代码来源:SharedContentElement.cs

示例10: CfgXmlHelper

        static CfgXmlHelper()
        {
            NameTable nt = new NameTable();
            nsMgr = new XmlNamespaceManager(nt);
            nsMgr.AddNamespace(CfgNamespacePrefix, CfgSchemaXMLNS);

            SearchFactoryExpression = XPathExpression.Compile(RootPrefixPath + ":search-factory", nsMgr);
        }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:8,代码来源:CfgXmlHelper.cs

示例11: XmlHelper

        static XmlHelper()
        {
            NameTable nt = new NameTable();
            XmlNamespaceManager nsMgr = new XmlNamespaceManager(nt);
            nsMgr.AddNamespace(NamespacePrefix, SchemaXmlns);

            PropertiesExpression = XPathExpression.Compile(RootPrefixPath + "properties", nsMgr);
            PropertiesPropertyExpression = XPathExpression.Compile(RootPrefixPath + "properties/" + ChildPrefixPath + "property", nsMgr);
        }
开发者ID:SaintLoong,项目名称:UltraNuke_Library,代码行数:9,代码来源:XmlHelper.cs

示例12: CfgXmlHelper

        static CfgXmlHelper()
        {
            NameTable nt = new NameTable();
            nsMgr = new XmlNamespaceManager(nt);
            nsMgr.AddNamespace(CfgNamespacePrefix, CfgSchemaXMLNS);

            SharedEngineClassExpression = XPathExpression.Compile(RootPrefixPath + Environment.SharedEngineClass, nsMgr);
            PropertiesExpression = XPathExpression.Compile(RootPrefixPath + "property", nsMgr);
            MappingsExpression = XPathExpression.Compile(RootPrefixPath + "mapping", nsMgr);
        }
开发者ID:mpielikis,项目名称:nhibernate-contrib,代码行数:10,代码来源:CfgXmlHelper.cs

示例13: Invoke

 public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext)
 {
     if (this.expr == null)
     {
         XPathExpression expression = docContext.Compile("(/s11:Envelope/s11:Body | /s12:Envelope/s12:Body)[1]");
         expression.SetContext(XPathMessageFunction.Namespaces);
         this.expr = expression;
     }
     return docContext.Evaluate(this.expr);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:XPathMessageFunctionBody.cs

示例14: Invoke

 public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext)
 {
     if (this.expr == null)
     {
         XPathExpression expression = docContext.Compile("(sm:header()/wsa10:FaultTo | sm:header()/wsaAugust2004:FaultTo)[1]");
         expression.SetContext((XmlNamespaceManager) new XPathMessageContext());
         this.expr = expression;
     }
     return docContext.Evaluate(this.expr);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:XPathMessageFunctionFaultTo.cs

示例15: GetXPathQueryManagerInContext

        /// <summary>
        /// This method returns an instance of <see cref="XPathQueryManagerCompiledExpressionsDecorator"/> 
        /// in the context of the first node the XPath expression addresses.
        /// </summary>
        /// <param name="xPath">The compiled XPath expression</param>
        /// <param name="queryParameters">Parameters for the compiled XPath expression</param>
        public override IXPathQueryManager GetXPathQueryManagerInContext(XPathExpression xPath,
                                                                         DictionaryEntry[] queryParameters = null)
        {
            IXPathQueryManager xPathQueryManager = (queryParameters == null)
                                                       ? XPathQueryManager.GetXPathQueryManagerInContext(xPath)
                                                       : XPathQueryManager.GetXPathQueryManagerInContext(xPath,
                                                                                                          queryParameters);

            if (xPathQueryManager == null) return null;
            return new XPathQueryManagerCompiledExpressionsDecorator(xPathQueryManager);
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:17,代码来源:XPathQueryManager_CompiledExpressionsDecorator.cs


注:本文中的System.Xml.XPath.XPathExpression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。