/// <summary> /// Vraća string sa NodeValue vrednostima za svaki XmlNode iz liste /// </summary> /// <param name="source">Izvor</param> /// <param name="dataSource">Koji podatak se koristi</param> /// <param name="nodeSufix">Opcioni dodatak na kraju svakog nodea</param> /// <returns>String sa svim vrednostima</returns> public static String getNodeValues(this IEnumerable <XmlNode> source, imbNodeValueSource dataSource, String nodeSufix = "") { String output = ""; foreach (XmlNode ss in source) { output += getNodeDataSourceValue(ss, dataSource) + nodeSufix + Environment.NewLine; } return(output); }
/// <summary> /// Izvršava MultiMap modul /// </summary> /// <param name="rootCell">Polje u koje je root za upisivanje vrednosti</param> /// <param name="contextForModules"></param> /// <param name="xPathPrefix"></param> /// <param name="source"></param> public static Dictionary <String, String> executeMultiMap(String rootPath, XmlNamespaceManager nsm, String xPathPrefix, XmlNode source, ObservableCollection <imbxPathMultiMapPair> map, imbNodeValueSource vsource) { Dictionary <String, String> output = new Dictionary <string, string>(); String path = ""; String xPath = ""; foreach (imbxPathMultiMapPair pair in map) { path = rootPath; xPath = xPathPrefix; if (!String.IsNullOrEmpty(pair.cellPath)) { path = (path + "/" + pair.cellPath).Replace("//", "/"); } if (!String.IsNullOrEmpty(pair.xPath)) { xPath = pair.xPath.Replace(xPathPrefix, ""); } xPath = xPath.getPathVersion(1); // imbStringPathTools.getRelativePathVersion(xPath); if (xPath.Contains("#text")) { xPath = imbStringPathTools.getPathVersion(xPath, 1); } List <XmlNode> response = imbXmlXPathTools.queryXPathObj(xPath, nsm, source, false) as List <XmlNode>; String value = response.getNodeValues(vsource, ""); output.Add(path, value); // output.Add(path, imbXmlXPathTools.queryXPathStr(xPath, nsm, source, true,vsource )); } return(output); }
public Object getStringValue(imbNodeValueSource _source) { List <XmlNode> nds = new List <XmlNode>(); foreach (imbXPathQuery qi in this) { if (qi.xmlNode is XmlNode) { nds.Add(qi.xmlNode); } } return(nds.getNodeValues(_source, "")); //imbXPathQuery q = this.imbFirstSafe(); //if (q is imbXPathQuery) //{ // if (q.xmlNode is XmlNode) // { // return q.xmlNode.getNodeDataSourceValue(_source, false); // } //} }
//public static Object queryXPathObj(this webDocument source, String xPath) //List<XmlNode> //{ // XPathExpression xExp = XPathExpression.Compile(xPath, source.nsManager); // XPathNavigator xNav = source.getDocumentNavigator(); // return xNav.Select(xExp); //} /// <summary> /// Vraca podatak a ne node /// </summary> /// <param name="xPath"></param> /// <param name="nsManager"></param> /// <param name="source"></param> /// <param name="trimPathWithSource"></param> /// <param name="valueSource"></param> /// <returns></returns> public static String queryXPathStr(String xPath, XmlNamespaceManager nsManager, XmlNode source, Boolean trimPathWithSource = true, imbNodeValueSource valueSource = imbNodeValueSource.allInnerText) //List<XmlNode> { List <XmlNode> output = new List <XmlNode>(); Object response = queryXPathObj(xPath, nsManager, source, trimPathWithSource); if (response.GetType() == typeof(string)) { return(response.ToString()); } else { String str = ""; output = response as List <XmlNode>; foreach (XmlNode nd in output) { str += imbXmlCommonTools.getNodeDataSourceValue(nd, valueSource); } return(str); } }
/// <summary> /// Izvlaci String value iz xmlNode-a prema zadatom dataSource-u. Ako nije pronadjen dataSource, onda pretpostavlja da je rec o atributu /// </summary> /// <param name="source">Node iz kojeg vadi podatak</param> /// <param name="dataSource">Koji podatak vadi</param> /// <param name="leaveDataSourceMark">Da li ispisuje odakle je uzeta vrednost</param> /// <returns></returns> public static String getNodeDataSourceValue(this IXPathNavigable source, imbNodeValueSource dataSource, Boolean leaveDataSourceMark = true) { return(getNodeDataSourceValue(source, dataSource.ToString(), leaveDataSourceMark)); }