private static string extractMessage(string exceptionFile) { System.Text.StringBuilder retVal = new System.Text.StringBuilder(); try { System.Xml.XPath.XPathDocument doc = new System.Xml.XPath.XPathDocument(exceptionFile); System.Xml.XPath.XPathNavigator nav = doc.CreateNavigator(); System.Xml.XPath.XPathNodeIterator iter = nav.Select(@"/*/ServiceException"); while (iter.MoveNext()) { if (retVal.Length > 0) { retVal.Append(System.Environment.NewLine); } System.Xml.XPath.XPathNodeIterator attIter = iter.Current.Select(@"/code|/Code|/CODE"); if (attIter.MoveNext()) { retVal.Append("(" + iter.Current.Value.Trim() + ") "); } retVal.Append(iter.Current.Value.Trim()); } } catch (System.Exception) { retVal.Append("Unable to extract the error description from the information returned by the WMS server."); } return(retVal.ToString()); }
public bool AddPages(System.Xml.XPath.XPathNodeIterator newPages) { bool isAdded = false; foreach (System.Xml.XPath.XPathNavigator pageLink in newPages) { string link = (pageLink.Value.StartsWith("http://") || pageLink.Value.StartsWith("https://") ? pageLink.Value : DomainName_ + pageLink.Value); System.Text.RegularExpressions.Regex rx = new System.Text.RegularExpressions.Regex(Rules_.PaginationPattern + "\\d+"); var matches = rx.Matches(link); bool isGood = true; for (int i = 0; isGood && i < matches.Count; i++) { isGood = Int32.TryParse(matches[i].Groups[0].Value.Replace(Rules_.PaginationPattern, ""), out int j); if (isGood) { isGood = j <= Rules_.MaxPageValue; } } if (isGood && PagesLinks_.IndexOf(link) == -1) { PagesLinks_.Add(link); isAdded = true; } } return(isAdded); }
Digest.Model.WebReferenceUrl[] getWebReferenceUrls(DirectoryInfo folder, string currentPath) { string relPath = Path.Combine(currentPath, folder.Name); string url = string.Empty; List <Digest.Model.WebReferenceUrl> webReferenceUrls = new List <Digest.Model.WebReferenceUrl>(); FileInfo[] fileInfo = folder.GetFiles("*.discomap"); if (fileInfo != null && fileInfo.Length > 0) { System.Xml.XPath.XPathDocument xDoc = new System.Xml.XPath.XPathDocument(fileInfo[0].FullName); System.Xml.XPath.XPathNavigator xNav = xDoc.CreateNavigator(); string xpathExpression = @"DiscoveryClientResultsFile/Results/DiscoveryClientResult[@referenceType='System.Web.Services.Discovery.ContractReference']/@url"; System.Xml.XPath.XPathNodeIterator xIter = xNav.Select(xpathExpression); if (xIter.MoveNext()) { url = xIter.Current.TypedValue.ToString(); } } if (!string.IsNullOrEmpty(url)) { Digest.Model.WebReferenceUrl newWebReferenceUrl = new Digest.Model.WebReferenceUrl(); newWebReferenceUrl.RelPath = relPath; newWebReferenceUrl.UpdateFromURL = url; webReferenceUrls.Add(newWebReferenceUrl); } foreach (DirectoryInfo dirInfo in folder.GetDirectories()) { webReferenceUrls.AddRange(getWebReferenceUrls(dirInfo, relPath)); } return(webReferenceUrls.ToArray()); }
public XPathRangeEnumerator(System.Xml.XPath.XPathNodeIterator all, int start, int count, int step) { this._root = all; this._start = start; this._count = count; this._step = step; this._currindex = -1; }
public string ConnectStrings(System.Xml.XPath.XPathNodeIterator values) { string res = ""; foreach (System.Xml.XPath.XPathNavigator value in values) { res += value.Value.Replace(" ", " "); } return(res); }
internal static string[] GetStringsInstance(System.Xml.XPath.XPathNavigator node, string selectPattern) { System.Xml.XPath.XPathNodeIterator iter = node.Select(ExpandPattern(selectPattern)); string[] retVal = new string[iter.Count]; while (iter.MoveNext()) { retVal[iter.CurrentPosition - 1] = iter.Current.Value; } return(retVal); }
public List <string> ListValue(System.Xml.XPath.XPathNodeIterator values) { List <string> res = new List <string>(); foreach (System.Xml.XPath.XPathNavigator value in values) { res.Add((value.Value.StartsWith("http://") || value.Value.StartsWith("https://") ? value.Value : DomainName_ + value.Value)); } return(res); }
internal static string GetOnlineResourceInstance(System.Xml.XPath.XPathNavigator node, string selectPattern) { string retVal = string.Empty; System.Xml.XPath.XPathNodeIterator iter = node.Select(ExpandPattern(selectPattern)); if (iter.MoveNext()) { retVal = iter.Current.GetAttribute("href", "http://www.w3.org/1999/xlink"); } return(retVal); }
internal static string GetStringInstance(System.Xml.XPath.XPathNavigator node, string selectPattern) { string retVal = string.Empty; System.Xml.XPath.XPathNodeIterator iter = node.Select(ExpandPattern(selectPattern)); if (iter.MoveNext()) { retVal = iter.Current.Value; } return(retVal); }
/// <summary> /// Selects a single node in the XPathNavigator using the specified XPath query. Needed for .NET 1.1 compatibility, /// .NET has this method built-in. /// </summary> /// <param name="navigator">XPathNavigator.</param> /// <param name="expression">A String representing an XPath expression.</param> /// <returns></returns> private System.Xml.XPath.XPathNavigator SelectSingleNode(System.Xml.XPath.XPathNavigator navigator, string expression) { System.Xml.XPath.XPathNodeIterator iterator = navigator.Select(expression); if (iterator.MoveNext() == true) { return(iterator.Current); } else { return(null); } }
static void Main(string[] args) { if (args.Length != 2) { args = new string[] { @"C5.dll", @"C5.xml" }; } { Timer timer = new Timer(); timer.snap(); DocNet doc = new DocNet(args[0], args[1], "C5"); XmlDocument merged = doc.GenerateDoc(); Console.Error.WriteLine("Time merge: {0} ms", timer.snap()); System.Xml.Xsl.XslCompiledTransform overview = new System.Xml.Xsl.XslCompiledTransform(); overview.Load(@"overview.xslt"); overview.Transform(merged, new XmlTextWriter(new StreamWriter(@"docbuild\contents.htm"))); Console.Error.WriteLine("Time, overview: {0} ms", timer.snap()); StringBuilder megaDoc = new StringBuilder(); using (XmlWriter writer = XmlWriter.Create(megaDoc)) { writer.WriteStartElement("hack"); System.Xml.Xsl.XslCompiledTransform trans = new System.Xml.Xsl.XslCompiledTransform(); trans.Load(@"trans.xslt"); trans.Transform(merged, writer); writer.WriteEndElement(); writer.Close(); } Console.Error.WriteLine("Time trans: {0} ms", timer.snap()); System.Xml.XPath.XPathDocument megaXml = new System.Xml.XPath.XPathDocument(XmlReader.Create(new StringReader(megaDoc.ToString()))); System.Xml.XPath.XPathNodeIterator nodes = megaXml.CreateNavigator().Select("/hack/*"); string docfn = null; foreach (System.Xml.XPath.XPathNavigator var in nodes) { if (var.Name == "filestart") { docfn = var.GetAttribute("name", ""); } if (var.Name == "html") { Console.Error.Write("."); XmlWriter w = new XmlTextWriter(new StreamWriter(@"docbuild\types\" + docfn)); var.WriteSubtree(w); w.Close(); } } Console.Error.WriteLine(); Console.Error.WriteLine("Time split: {0} ms", timer.snap()); } Console.Write("? "); Console.Read(); }
// All the following use XPath search strings to find various bits of information in the // server's WMS capabilities description. internal static UriAndFormatType[] GetUriAndFormatInstances(System.Xml.XPath.XPathNavigator node, string pattern) { System.Xml.XPath.XPathNodeIterator iter = node.Select(Capabilities.ExpandPattern(pattern)); UriAndFormatType[] retVal = new UriAndFormatType[iter.Count]; while (iter.MoveNext()) { int i = iter.CurrentPosition - 1; retVal[i] = new UriAndFormatType(); retVal[i].Format = Capabilities.GetStringInstance(iter.Current, @"./Format"); retVal[i].Uri = Capabilities.GetOnlineResourceInstance(iter.Current, @"./OnlineResource"); } return(retVal); }
/// <summary> /// Gets the child count. /// </summary> /// <param name="stdnavi">The navigator.</param> /// <param name="childName">The child tag name, i.e. "Output".</param> /// <param name="selectPath">The select path, i.e. "//CommProt/PhysOutputs".</param> /// <returns></returns> public static int?GetChildCount(this System.Xml.XPath.XPathNavigator stdnavi, string childName, string selectPath) { if (null != stdnavi) { try { System.Xml.XPath.XPathNavigator navi = AdjustNaviIfNeeded(stdnavi, selectPath); System.Xml.XPath.XPathNodeIterator it = navi.SelectChildren(childName, string.Empty); return(it.Count); } catch { } } return(null); }
/// <summary> /// Adjusts the navigator if needed. /// </summary> /// <param name="stdnavi">The navigator.</param> /// <param name="selectPath">The select path, i.e. "//CommProt/CommParameters".</param> /// <returns></returns> public static System.Xml.XPath.XPathNavigator AdjustNaviIfNeeded(this System.Xml.XPath.XPathNavigator stdnavi, string selectPath) { System.Xml.XPath.XPathNavigator navi = stdnavi; if (null != navi && null != selectPath && 0 != selectPath.Length) { System.Xml.XPath.XPathNodeIterator it = stdnavi.Select(selectPath); if (!it.MoveNext()) { return(stdnavi); } navi = it.Current; } return(navi); }
public static DateTimeOffset?Parse([AllowNull] System.Xml.XPath.XPathNodeIterator value) { DateTimeOffset?dateTime = null; if ((value != null) && (value.MoveNext())) { string text = value.Current.ToString(); if (long.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out long epoch)) { dateTime = DateTimeOffset.FromUnixTimeSeconds(epoch).LocalDateTime; } } return(dateTime); }
public bool AddProducts(System.Xml.XPath.XPathNodeIterator newProducts) { bool isAdded = false; foreach (System.Xml.XPath.XPathNavigator pageLink in newProducts) { string link = (pageLink.Value.StartsWith("http://") || pageLink.Value.StartsWith("https://") ? pageLink.Value : DomainName_ + pageLink.Value); if (ProductsLinks_.IndexOf(link) == -1) { ProductsLinks_.Add(link); isAdded = true; } } return(isAdded); }
public override void UpdateDeviceData(IHSApplication HS, DeviceClass device, [AllowNull] System.Xml.XPath.XPathNodeIterator value) { DateTimeOffset?dateTime = Parse(value); double numberValue = 0; string stringValue = null; if (dateTime.HasValue) { numberValue = dateTime.Value.ToUnixTimeSeconds(); stringValue = dateTime.Value.ToString(displayFormat, CultureInfo.CurrentCulture); } UpdateDeviceData(HS, device, numberValue); UpdateDeviceData(HS, device, stringValue); }
/// <summary> /// 根据XPathNavigator文档子结点来取配的属性,并赋值 /// </summary> /// <param name="obj">对象</param> /// <param name="xPath">XPathNavigator</param> /// <returns></returns> public static void SetProperty(object obj, System.Xml.XPath.XPathNavigator xPath) { System.Xml.XPath.XPathNodeIterator xtertor = xPath.SelectChildren(System.Xml.XPath.XPathNodeType.Element); while (xtertor.MoveNext()) { if (!String.IsNullOrEmpty(xtertor.Current.Value)) { BindingFlags bindingAttr = BindingFlags.SetProperty | BindingFlags.Public | BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase; PropertyInfo pro = obj.GetType().GetProperty(xtertor.Current.Name, bindingAttr); if (pro != null && pro.CanWrite) { pro.SetValue(obj, Parse(xtertor.Current.Value, pro.PropertyType), null); } } } }
private static LogoOrLegendUriType GetLogoOrLegendUriInstance(System.Xml.XPath.XPathNavigator node, string pattern) { System.Xml.XPath.XPathNodeIterator iter = node.Select(Capabilities.ExpandPattern(pattern)); LogoOrLegendUriType retVal = new LogoOrLegendUriType(); if (iter.MoveNext()) { UriAndFormatType[] t = GetUriAndFormatInstances(iter.Current, @"."); if (t.Length > 0) { retVal.Uri = t[0]; } retVal.Width = double.Parse(Capabilities.GetStringInstance(iter.Current, @"./@Width")); retVal.Height = double.Parse(Capabilities.GetStringInstance(iter.Current, @"./@Height")); } return(retVal); }
// Write the SMIL files from the Z composite document private void WriteSMILFiles(System.Xml.XPath.XPathDocument z) { System.Xml.Xsl.XslCompiledTransform smilXslt = new System.Xml.Xsl.XslCompiledTransform(true); smilXslt.Load(System.IO.Path.Combine(mAssemblyLocation, SMIL_XSLT), null, mResolver); System.Xml.XPath.XPathNavigator navigator = z.CreateNavigator(); System.Xml.XmlNamespaceManager nsmgr = new System.Xml.XmlNamespaceManager(navigator.NameTable); nsmgr.AddNamespace("smil", "http://www.w3.org/2001/SMIL20/"); System.Xml.XPath.XPathNodeIterator it = navigator.Select("/z/smil:smil/smil:body/smil:seq", nsmgr); while (it.MoveNext()) { System.Xml.Xsl.XsltArgumentList args = new System.Xml.Xsl.XsltArgumentList(); string id = it.Current.GetAttribute("id", ""); args.AddParam("id", "", id); System.Xml.XmlWriter smilFile = System.Xml.XmlWriter.Create(FullPath(".smil", id), smilXslt.OutputSettings); smilXslt.Transform(z, args, smilFile); } }
void Window1_Loaded(object sender, RoutedEventArgs e) { // Arena.instance.VerticalAlignment = VerticalAlignment.Stretch;// .sca .RenderTransform = new ScaleTransform(1.5, 1.5); // Arena.instance.HorizontalAlignment = HorizontalAlignment.Stretch;// .sca .RenderTransform = new ScaleTransform(1.5, 1.5); System.Xml.XPath.XPathDocument GameData = new System.Xml.XPath.XPathDocument(".\\GameData.xml"); System.Xml.XPath.XPathNavigator GameDataNav = GameData.CreateNavigator(); Arena.instance.BankBalance = double.Parse(GameDataNav.SelectSingleNode("/GameData/StartingCash").ToString()); Arena.instance.Lifes = 20; //GameDataNav.MoveToRoot(); //System.Xml.XPath.XPathNodeIterator dx = GameDataNav.Select("/GameData/TowerTypes/RadiatorTowers/RadiatorTower"); System.Xml.XPath.XPathNodeIterator dx = GameDataNav.Select("/GameData/TowerTypes/*/*/@Name"); //"/GameData/TowerTypes/*/*/@Price" while (dx.MoveNext()) { string q = dx.Current.ToString(); ListBoxItem x = new ListBoxItem(); x.Content = q; System.Xml.XPath.XPathNavigator n = GameData.CreateNavigator(); System.Xml.XPath.XPathNavigator o = n.SelectSingleNode("/GameData/TowerTypes/*/*[@Name='" + q + "']"); TowerData PTD; if (o.Name == "ProjectileTower") { PTD = new ProjectileTowerData(o); } else if (o.Name == "RadiatorTower") { PTD = new HeatTowerData(o); } else if (o.Name == "BeamTower") { PTD = new BeamTowerData(o); } else { PTD = new TowerData(o); } x.Tag = PTD; Window1.instance.Towers.Items.Add(x); } }
protected override void DoDataBind(PDFDataContext context, bool includeChildren) { base.DoDataBind(context, includeChildren); if (null != _literal) { this.Contents.Remove(_literal); } object data = GetRequiredData(context); if (null == data) { return; } _literal = new Components.TextLiteral(); if (data is System.Xml.XPath.XPathNavigator) { _literal.Text = ((System.Xml.XPath.XPathNavigator)data).OuterXml; } else if (data is System.Xml.XPath.XPathNodeIterator) { System.Xml.XPath.XPathNodeIterator itter = (System.Xml.XPath.XPathNodeIterator)data; //Clone it so we do not affect anything else itter = itter.Clone(); StringBuilder sb = new StringBuilder(); while (itter.MoveNext()) { sb.AppendLine(itter.Current.OuterXml); } _literal.Text = sb.ToString(); } this.Contents.Add(_literal); }
private Item findItemByXpathXMLQuery(Item item, string query) { try { ItemNavigator navigator = Sitecore.Configuration.Factory.CreateItemNavigator(item); if (navigator != null) { System.Xml.XPath.XPathNodeIterator foundItemNavigator = navigator.Select(query); if (foundItemNavigator != null && foundItemNavigator.MoveNext()) { return(GetItem(foundItemNavigator)); } } } catch (Exception ex) { // return string.Format("<br>Exeption: {0} for query: {1} </br>", ex.ToString(), query); } return(null); }
// Methods // STODO reuse existeed sitecore method public virtual Item GetItem(System.Xml.XPath.XPathNodeIterator iterator) { Sitecore.Data.ID id; Sitecore.Data.Version latest; Sitecore.Diagnostics.Assert.ArgumentNotNull(iterator, "iterator"); if (!Sitecore.Data.ID.TryParse(iterator.Current.GetAttribute("id", string.Empty), out id)) { return(null); } if (!Sitecore.Data.Version.TryParse(iterator.Current.GetAttribute("version", string.Empty), out latest)) { latest = Sitecore.Data.Version.Latest; } Sitecore.Data.Database database = Sitecore.Context.Database; if (database == null) { return(null); } return(Sitecore.Data.Managers.ItemManager.GetItem(id, Sitecore.Globalization.Language.Current, latest, database)); }
public static RecentExperimentList LoadRecentExperimentListFromXML(string pFilepath) { RecentExperimentList list = new RecentExperimentList(); if (System.IO.File.Exists(pFilepath)) { try { System.Xml.XPath.XPathDocument doc = new System.Xml.XPath.XPathDocument(pFilepath); System.Xml.XPath.XPathNavigator nav = doc.CreateNavigator(); System.Xml.XPath.XPathNodeIterator itemIterator = nav.Select("/RecentExperiments/RecentExperimentItem"); int numItems = itemIterator.Count; string fullpath, time; while (itemIterator.MoveNext()) { fullpath = itemIterator.Current.GetAttribute("FullPath", String.Empty); time = itemIterator.Current.GetAttribute("LastAccessTime", String.Empty); RecentExperimentReference item = RecentExperimentReference.CreateRecentExperimentItem(fullpath, time); if (item != null) { list.AddLast(item); } } if (list.Count != numItems) { RecentExperimentsHelper.SaveRecentExperimentListToXML(list, pFilepath); } } catch (XmlException) { System.IO.File.Delete(pFilepath); list.Clear(); } } return(list); }
public override void UpdateDeviceData(IHSApplication HS, DeviceClass device, [AllowNull] System.Xml.XPath.XPathNodeIterator value) { int refId = device.get_Ref(HS); bool valueSet = false; if ((value != null) && (value.MoveNext())) { var data = value == null ? null : value.Current.ToString(); if (!string.IsNullOrWhiteSpace(data)) { HS.SetDeviceValueByRef(refId, FromString(data).ToDouble(CultureInfo.InvariantCulture), true); valueSet = true; } } if (!valueSet) { HS.SetDeviceValueByRef(refId, defaultValue.ToDouble(CultureInfo.InvariantCulture), true); } }
protected override IEnumerator CreateEnumerator(IEnumerable enumerable) { if (enumerable is System.Xml.XPath.XPathNodeIterator) { System.Xml.XPath.XPathNodeIterator itter = (System.Xml.XPath.XPathNodeIterator)enumerable; if (this.StartIndex == 0 && this.MaxCount == int.MaxValue && this.Step == 1) { return(new XPathDefaultEnumerator(itter)); } else { return(new XPathRangeEnumerator(itter, this.StartIndex, this.MaxCount, this.Step)); } } if (this.StartIndex == 0 && this.MaxCount == int.MaxValue && this.Step == 1) { return(base.CreateEnumerator(enumerable)); } else { return(new RangeEnumerator(enumerable.GetEnumerator(), this.StartIndex, this.MaxCount, this.Step)); } }
protected virtual object GetCurrentOrFirstItem(object data) { if (data is System.Xml.XPath.XPathNodeIterator) { System.Xml.XPath.XPathNodeIterator itter = (System.Xml.XPath.XPathNodeIterator)data; if (itter.MoveNext()) { return(itter.Current); } else { return(null); } } else if (data is Array) { Array all = (Array)data; if (all.Length > 0) { return(all.GetValue(0)); } else { return(null); } } else if (data is System.Collections.IList) { System.Collections.IList col = (System.Collections.IList)data; return(col[0]); } else { return(data); } }
public virtual object Evaluate(System.Xml.XPath.XPathExpression expr, System.Xml.XPath.XPathNodeIterator context) { return(default(object)); }
public virtual object Evaluate(System.Xml.XPath.XPathExpression expr, System.Xml.XPath.XPathNodeIterator context) { throw null; }