本文整理汇总了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);
}
示例2: XslSortEvaluator
public XslSortEvaluator (XPathExpression select, Sort [] sorterTemplates)
{
this.select = select;
this.sorterTemplates = sorterTemplates;
PopulateConstantSorters ();
sortRunner = new XPathSorters ();
}
示例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));
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例7: Select
public override XPathNodeIterator Select(XPathExpression expr)
{
if (Queryables.ContainsKey(expr.Expression))
return new XPathQueryableIterator(Queryables[expr.Expression]);
return base.Select(expr);
}
示例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());
}
示例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);
}
示例10: CfgXmlHelper
static CfgXmlHelper()
{
NameTable nt = new NameTable();
nsMgr = new XmlNamespaceManager(nt);
nsMgr.AddNamespace(CfgNamespacePrefix, CfgSchemaXMLNS);
SearchFactoryExpression = XPathExpression.Compile(RootPrefixPath + ":search-factory", nsMgr);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}