public void Test_All_Items_For_Correct_Return_Paths_Abbreviated_Syntax() { var values = new List<KeyValuePair<string, string>>() { new KeyValuePair<string,string>("/" , "root::node()"), new KeyValuePair<string,string>("/doc/chapter[position()=5]/section[position()=2]" , "root::node()/child::doc/(child::chapter)[position()=5]/(child::section)[position()=2]"), new KeyValuePair<string,string>("@*" , "attribute::*"), new KeyValuePair<string,string>("@name" , "attribute::name"), new KeyValuePair<string,string>("*" , "child::*"), new KeyValuePair<string,string>("*/child::para" , "child::*/child::para"), new KeyValuePair<string,string>("*[self::chapter or self::appendix]" , "(child::*)[self::chapter or self::appendix]"), new KeyValuePair<string,string>("*[self::chapter or self::appendix][position()=last()]" , "((child::*)[self::chapter or self::appendix])[position()=last()]"), new KeyValuePair<string,string>("chapter/descendant::para" , "child::chapter/descendant::para"), new KeyValuePair<string,string>("chapter[title='Introduction']" , "(child::chapter)[child::title='Introduction']"), new KeyValuePair<string,string>("chapter[title]" , "(child::chapter)[child::title]"), new KeyValuePair<string,string>("node()" , "child::node()"), new KeyValuePair<string,string>("para" , "child::para"), new KeyValuePair<string,string>("para[@type='warning']" , "(child::para)[attribute::type='warning']"), new KeyValuePair<string,string>("para[@type='warning'][position()=5]" , "((child::para)[attribute::type='warning'])[position()=5]"), new KeyValuePair<string,string>("para[1]" , "(child::para)[1]"), new KeyValuePair<string,string>("para[position()=5][@type='warning']" , "((child::para)[position()=5])[attribute::type='warning']"), new KeyValuePair<string,string>("para[position()=last()-1]" , "(child::para)[position()=last()-1]"), new KeyValuePair<string,string>("para[position()=last()]" , "(child::para)[position()=last()]"), new KeyValuePair<string,string>("para[position()>1]" , "(child::para)[position()>1]"), new KeyValuePair<string,string>("text()" , "child::text()"), }; foreach (var item in values) { var result = new XPathParser<string>().Parse(item.Key, new XPathStringBuilder()); Assert.AreEqual<string>(item.Value, result); } }
private static void TestXPathParser() { var parser = new XPathParser <string>(); var builder = new XPathStringBuilder(); Queue <IXPathPart> queue; parser.Parse("/Person[@FirstName]", builder); queue = builder.PartQueue; foreach (var part in queue) { var debugInfo = part.ToString(); } parser = new XPathParser <string>(); builder = new XPathStringBuilder(); parser.Parse("$ABCCompany/Person[@FirstName]", builder); queue = builder.PartQueue; foreach (var part in queue) { var debugInfo = part.ToString(); } }
private void VerifyXPath() { string Xpath = mAction.ElementLocateValue; try { XPathParser <XElement> xpp = new XPathParser <XElement>(); XElement xe1 = xpp.Parse(Xpath, new XPathTreeBuilder()); xpp.GetOKPath(); XElement xe = new XPathParser <XElement>().Parse(Xpath, new XPathTreeBuilder()); XmlWriterSettings ws = new XmlWriterSettings(); { ws.Indent = true; ws.OmitXmlDeclaration = true; } StringBuilder sb = new StringBuilder(); using (XmlWriter w = XmlWriter.Create(sb, ws)) { xe.WriteTo(w); } ResultLabel.Content = sb.ToString(); } catch (Exception e) { ResultLabel.Content = e.Message; } }
public static AstNode ParseXPathPattern(string xpathPattern) { XPathScanner scanner = new XPathScanner(xpathPattern); XPathParser parser = new XPathParser(scanner); AstNode result = parser.ParsePattern(null); if (scanner.Kind != XPathScanner.LexKind.Eof) { throw new XPathException(string.Format("'{0}' has an invalid token.", scanner.SourceText)); } return result; }
public static AstNode ParseXPathPattern(string xpathPattern) { XPathScanner scanner = new XPathScanner(xpathPattern); XPathParser parser = new XPathParser(scanner); AstNode result = parser.ParsePattern(null); if (scanner.Kind != XPathScanner.LexKind.Eof) { throw XPathException.Create(Res.Xp_InvalidToken, scanner.SourceText); } return result; }
/* * LocationPathPattern ::= '/' RelativePathPattern? | '//'? RelativePathPattern | IdKeyPattern (('/' | '//') RelativePathPattern)? */ private QilNode ParseLocationPathPattern() { QilNode opnd; switch (_scanner.Kind) { case LexKind.Slash: _scanner.NextLex(); opnd = _ptrnBuilder.Axis(XPathAxis.Root, XPathNodeType.All, null, null); if (XPathParser.IsStep(_scanner.Kind)) { opnd = _ptrnBuilder.JoinStep(opnd, ParseRelativePathPattern()); } return(opnd); case LexKind.SlashSlash: _scanner.NextLex(); return(_ptrnBuilder.JoinStep( _ptrnBuilder.Axis(XPathAxis.Root, XPathNodeType.All, null, null), _ptrnBuilder.JoinStep( _ptrnBuilder.Axis(XPathAxis.DescendantOrSelf, XPathNodeType.All, null, null), ParseRelativePathPattern() ) )); case LexKind.Name: if (_scanner.CanBeFunction && _scanner.Prefix.Length == 0 && (_scanner.Name == "id" || _scanner.Name == "key")) { opnd = ParseIdKeyPattern(); switch (_scanner.Kind) { case LexKind.Slash: _scanner.NextLex(); opnd = _ptrnBuilder.JoinStep(opnd, ParseRelativePathPattern()); break; case LexKind.SlashSlash: _scanner.NextLex(); opnd = _ptrnBuilder.JoinStep(opnd, _ptrnBuilder.JoinStep( _ptrnBuilder.Axis(XPathAxis.DescendantOrSelf, XPathNodeType.All, null, null), ParseRelativePathPattern() ) ); break; } return(opnd); } break; } opnd = ParseRelativePathPattern(); return(opnd); }
static void RunTestString(string xpathExpr) { Console.WriteLine("Original XPath: {0}", xpathExpr); try { var x = new XPathParser <string>().Parse(xpathExpr, new XPathStringBuilder()); Console.WriteLine("Translated one: {0}", x); } catch (XPathParserException e) { Console.WriteLine(e.ToString()); } Console.WriteLine(); }
public bool advance() { currToken = GetNext(); #if XPATH_DEBUG Debug.Write(XPathParser.yyname(currToken) + " "); if (currToken == Token.EOF) { Debug.Write("\n"); } #endif return(currToken != Token.EOF); }
public static UIElement FromWPath(WPathStructure wpath) { object xe = new XPathParser <object>().Parse(wpath.Value, new XPathUIElementBuilder(RootElement?.automationElement)); if (xe is AutomationElement element) { return(new UIElement() { automationElement = element }); } throw new NullReferenceException($"Cannot find UI element described by \"{wpath.Value}\"."); }
public void TestXPath010() { AdkXPathStep[] steps = XPathParser.Parse("Foo"); Assert.AreEqual(1, steps.Length); Assert.AreEqual("Foo", ((AdkNodeNameTest)steps[0].NodeTest).NodeName); steps = XPathParser.Parse("/Foo"); Assert.AreEqual(1, steps.Length); Assert.AreEqual("Foo", ((AdkNodeNameTest)steps[0].NodeTest).NodeName); Console.WriteLine(steps[0]); }
int ProcessResultsCollection(IDSFDataObject dataObject, int update, XPathParser parser, ErrorResultTO allErrors, string c) { int i; for (i = 0; i < ResultsCollection.Count; i++) { if (!string.IsNullOrEmpty(ResultsCollection[i].OutputVariable)) { IterateOverXPath(dataObject, update, parser, allErrors, c, i); } } return(i); }
public QueryPathAttribute(string xpathExpression, QueryKind kind = QueryKind.None) { var parser = new XPathParser <string>(); var builder = new XPathStringBuilder(); var id = string.Empty; var path = xpathExpression; this.XPathExpression = xpathExpression; this.QueryPathKind = kind; parser.Parse(path, builder); this.PartQueue = builder.PartQueue; }
public void TestXPath020() { AdkXPathStep[] steps = XPathParser.Parse("Foo/Bar/Win"); Assert.AreEqual(3, steps.Length); Assert.AreEqual("Foo", ((AdkNodeNameTest)steps[0].NodeTest).NodeName); Assert.AreEqual("Bar", ((AdkNodeNameTest)steps[1].NodeTest).NodeName); Assert.AreEqual("Win", ((AdkNodeNameTest)steps[2].NodeTest).NodeName); steps = XPathParser.Parse("/Foo/Bar/Win"); Assert.AreEqual(3, steps.Length); Assert.AreEqual("Foo", ((AdkNodeNameTest)steps[0].NodeTest).NodeName); Assert.AreEqual("Bar", ((AdkNodeNameTest)steps[1].NodeTest).NodeName); Assert.AreEqual("Win", ((AdkNodeNameTest)steps[2].NodeTest).NodeName); }
int Process(IDSFDataObject dataObject, int update, int i, XPathParser parser, ErrorResultTO allErrors, ErrorResultTO errors) { if (!string.IsNullOrEmpty(SourceString)) { var itr = new WarewolfListIterator(); var sourceIterator = new WarewolfIterator(dataObject.Environment.Eval(SourceString, update)); itr.AddVariableToIterateOn(sourceIterator); while (itr.HasMoreData()) { var c = itr.FetchNextValue(sourceIterator); i = ProcessResultsCollection(dataObject, update, parser, allErrors, c); allErrors.MergeErrors(errors); } } return(i); }
public void TestXPath040() { String path = "Foo[@Win='2']/Bar"; AdkXPathStep[] steps = XPathParser.Parse(path); Assert.AreEqual(2, steps.Length); AssertStep(steps[0], "Foo", "Win", "2"); Assert.AreEqual("Bar", ((AdkNodeNameTest)steps[1].NodeTest).NodeName); steps = XPathParser.Parse("/" + path); Assert.AreEqual(2, steps.Length); AssertStep(steps[0], "Foo", "Win", "2"); Assert.AreEqual("Bar", ((AdkNodeNameTest)steps[1].NodeTest).NodeName); }
/* * StepPattern ::= ChildOrAttributeAxisSpecifier NodeTest Predicate* * ChildOrAttributeAxisSpecifier ::= @ ? | ('child' | 'attribute') '::' */ private QilNode ParseStepPattern() { QilNode opnd; XPathAxis axis; switch (scanner.Kind) { case LexKind.Dot: case LexKind.DotDot: throw scanner.CreateException(Res.XPath_InvalidAxisInPattern); case LexKind.At: //>> '@' axis = XPathAxis.Attribute; scanner.NextLex(); break; case LexKind.Axis: //>> AxisName '::' axis = XPathParser.GetAxis(scanner.Name, scanner); if (axis != XPathAxis.Child && axis != XPathAxis.Attribute) { throw scanner.CreateException(Res.XPath_InvalidAxisInPattern); } scanner.NextLex(); break; case LexKind.Name: case LexKind.Star: // NodeTest must start with Name or '*' axis = XPathAxis.Child; break; default: throw scanner.CreateException(Res.XPath_UnexpectedToken, scanner.RawValue); } XPathNodeType nodeType; string nodePrefix, nodeName; XPathParser.InternalParseNodeTest(scanner, axis, out nodeType, out nodePrefix, out nodeName); opnd = ptrnBuilder.Axis(axis, nodeType, nodePrefix, nodeName); while (scanner.Kind == LexKind.LBracket) { opnd = ptrnBuilder.Predicate(opnd, ParsePredicate(opnd), /*reverseStep:*/ false); } return(opnd); }
static void RunTestTree(string xpathExpr) { Console.WriteLine("Original XPath: {0}", xpathExpr); try { XElement xe = new XPathParser <XElement>().Parse(xpathExpr, new XPathTreeBuilder()); XmlWriterSettings ws = new XmlWriterSettings(); { ws.Indent = true; ws.OmitXmlDeclaration = true; } using (XmlWriter w = XmlWriter.Create(Console.Out, ws)) { xe.WriteTo(w); } } catch (XPathParserException e) { Console.WriteLine(e.ToString()); } Console.WriteLine(); Console.WriteLine(); }
public CompiledStylesheet Compile(XPathNavigator nav, XmlResolver res, Evidence evidence) { this.xpathParser = new XPathParser(this); this.patternParser = new XsltPatternParser(this); this.res = res; if (res == null) { this.res = new XmlUrlResolver(); } this.evidence = evidence; if (nav.NodeType == XPathNodeType.Root && !nav.MoveToFirstChild()) { throw new XsltCompileException("Stylesheet root element must be either \"stylesheet\" or \"transform\" or any literal element", null, nav); } while (nav.NodeType != XPathNodeType.Element) { nav.MoveToNext(); } this.stylesheetVersion = nav.GetAttribute("version", (!(nav.NamespaceURI != "http://www.w3.org/1999/XSL/Transform")) ? string.Empty : "http://www.w3.org/1999/XSL/Transform"); this.outputs[string.Empty] = new XslOutput(string.Empty, this.stylesheetVersion); this.PushInputDocument(nav); if (nav.MoveToFirstNamespace(XPathNamespaceScope.ExcludeXml)) { do { this.nsMgr.AddNamespace(nav.LocalName, nav.Value); }while (nav.MoveToNextNamespace(XPathNamespaceScope.ExcludeXml)); nav.MoveToParent(); } try { this.rootStyle = new XslStylesheet(); this.rootStyle.Compile(this); } catch (XsltCompileException) { throw; } catch (Exception ex) { throw new XsltCompileException("XSLT compile error. " + ex.Message, ex, this.Input); } return(new CompiledStylesheet(this.rootStyle, this.globalVariables, this.attrSets, this.nsMgr, this.keys, this.outputs, this.decimalFormats, this.msScripts)); }
public void test_expr2() { var syntax = new Syntax2(); syntax.Load(Xpathfile); var sx = new XPathParser(syntax); var x = new List <Expression>(); x.Add(sx.GetExpression("if ($a ne 0) then (iaf:numeric-equal($b, iaf:sum(($c, $d, $e, iaf:numeric-unary-minus($a))))) else true()")); x.Add(sx.GetExpression("string-length(string(xfi:fact-typed-dimension-value($a,QName(\"http://www.boi.org.il/xbrl/dict/dim\",\"TDR\")))) <= 20")); x.Add(sx.GetExpression("iaf:numeric-greater-equal-than((for $i in $a return iaf:abs($i)), (for $i in $b return iaf:abs($i)))")); x.Add(sx.GetExpression("matches($a, \"[\\d\\w]+(([_|\\.|\\-])?[\\d\\w]+)*@[\\d\\w]+(([_|\\.|\\-])?[\\d\\w]+)*\")")); x.Add(sx.GetExpression("concat(month-from-date($a), \"-\", day-from-date($a)) = (\"3-31\" cast as xs:string) or concat(month-from-date($a), \"-\", day-from-date($a)) = (\"6-30\" cast as xs:string) or concat(month-from-date($a), \"-\", day-from-date($a)) = (\"9-30\" cast as xs:string) or concat(month-from-date($a), \"-\", day-from-date($a)) = (\"12-31\" cast as xs:string)")); x.Add(sx.GetExpression("if (string-length(string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\")))) = 9) then ((substring(string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))),1,1) != \"8\") and (substring(string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))),1,3) != \"999\") and (string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) != \"111111111\")) else (true())")); x.Add(sx.GetExpression("$a = $b + $c")); x.Add(sx.GetExpression("not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700009848 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520041690 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700003825 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520031931 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700010085 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 513890368 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700013329 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520036658 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 644035024 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520000472 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700000862 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520013954 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700003817 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520014143 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700003957 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 510216054 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700003809 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 511076572 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700011612 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520022732 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700011620 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 570000745 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700016082 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520044322 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700016090 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520028283 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700016108 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520005067 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700016116 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520004078 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700016124 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520027830 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700016132 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520017070 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700016140 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520024647 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700016181 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 33260971 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700016157 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520033093 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700016165 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 513767079 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700016173 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520003781 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700016470 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 510313778 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700016934 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520037565 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700017080 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520032285 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700017122 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 511984213 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700017130 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 511780793 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700017833 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 511325870 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700017957 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520033234 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700018096 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 513326439 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700007891 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 512480971 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700018955 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 511888356 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700019151 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 550212021 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700019714 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 550225510 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700020183 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 520004896 cast as xs:string)) and not((string(xfi:fact-typed-dimension-value($a, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 700020357 cast as xs:string) and (string(xfi:fact-typed-dimension-value($b, QName(\"http://www.boi.org.il/xbrl/dict/dim\", \"TDD\"))) = 510947153 cast as xs:string))")); x.Add(sx.GetExpression("(month-from-dateTime(xfi:period-instant(xfi:period($a))) = 4 and day-from-dateTime(xfi:period-instant(xfi:period($a))) = 1) or (month-from-dateTime(xfi:period-instant(xfi:period($a))) = 7 and day-from-dateTime(xfi:period-instant(xfi:period($a))) = 1) or (month-from-dateTime(xfi:period-instant(xfi:period($a))) = 10 and day-from-dateTime(xfi:period-instant(xfi:period($a))) = 1) or (month-from-dateTime(xfi:period-instant(xfi:period($a))) = 1 and day-from-dateTime(xfi:period-instant(xfi:period($a))) = 1)")); x.Add(sx.GetExpression("((floor($a div 100) = 1 or floor($a div 100) = 4 or floor($a div 100) = 7 or floor($a div 100) = 9)) and ((floor(($a - floor($a div 100) * 100) div 10) = 0) or (floor(($a - floor($a div 100) * 100) div 10) = 1) or (floor(($a - floor($a div 100) * 100) div 10) = 2))")); }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { _debugOutputs.Clear(); _isDebugMode = dataObject.IsDebugMode(); var errors = new ErrorResultTO(); var allErrors = new ErrorResultTO(); var parser = new XPathParser(); var i = 0; InitializeDebug(dataObject); try { if (!string.IsNullOrEmpty(SourceString)) { if (_isDebugMode) { AddSourceStringDebugInputItem(SourceString, dataObject.Environment, update); AddResultDebugInputs(ResultsCollection, out errors); allErrors.MergeErrors(errors); } if (!allErrors.HasErrors()) { i = Process(dataObject, update, i, parser, allErrors, errors); } DoDebug(dataObject, update, allErrors); } } catch (Exception ex) { allErrors.AddError(ex.Message); } finally { var actualIndex = i - 1; var hasErrors = allErrors.HasErrors(); ProcessErrors(dataObject, update, hasErrors, allErrors, actualIndex); DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } }
public static string GetID(this IBase baseObject) { if (CodeInterfaceExtensions.DebugInfoShowOptions.HasFlag(DebugInfoShowOptions.ShowCondensedID)) { var parser = new XPathParser <string>(); var builder = new XPathStringBuilder(); var id = string.Empty; parser.Parse(baseObject.ID, builder); id = string.Join("../", builder.AxisElementQueue.Select(e => e.Element)); id += "[" + builder.AxisElementQueue.Last().Predicates.First().ToString() + "]"; return(id); } else { return(baseObject.ID); } }
public void TestXPath030() { String path = "Foo[@Win='2']/Bar[Type=5]/Win[Zone=\"yada\"]"; AdkXPathStep[] steps = XPathParser.Parse(path); Assert.AreEqual(3, steps.Length); AssertStep(steps[0], "Foo", "Win", "2"); AssertStep(steps[1], "Bar", "Type", 5); AssertStep(steps[2], "Win", "Zone", "yada"); Console.WriteLine(steps[0] + "/" + steps[1] + "/" + steps[2]); steps = XPathParser.Parse("/" + path); Assert.AreEqual(3, steps.Length); AssertStep(steps[0], "Foo", "Win", "2"); AssertStep(steps[1], "Bar", "Type", 5); AssertStep(steps[2], "Win", "Zone", "yada"); }
public static string GetID(this IBase baseObject) { if (AbstraXExtensions.DebugInfoShowOptions.HasFlag(DebugInfoShowOptions.ShowCondensedID)) { var parser = new XPathParser<string>(); var builder = new XPathStringBuilder(); var id = string.Empty; parser.Parse(baseObject.ID, builder); id = string.Join("../", builder.PartQueue.OfType<XPathElement>().Select(e => e.Text)); id += "[" + builder.PartQueue.OfType<XPathElement>().Last().Predicates.First().ToString() + "]"; return id; } else { return baseObject.ID; } }
public static IQueryable <T> GenerateByID <T>(this IProviderService service, string id) { var queue = new Queue <string>(); var parser = new XPathParser <string>(); var builder = new XPathStringBuilder(); parser.Parse(id, builder); var axisElement = builder.AxisElementQueue.Last(); var method = service.GetType().GetMethods().Single(m => m.ReturnType.Name == "IQueryable`1" && m.GetParameters().Length == 0 && m.ReturnType.GetGenericArguments().Any(a => a.Name == axisElement.Element)); service.LogGenerateByID(id, method); var results = (IQueryable <IBase>)method.Invoke(service, null); service.PostLogGenerateByID(); return(results.Where(b => b.ID == id).Cast <T>()); }
public void Test_All_Items_For_Correct_Return_Paths() { var values = new List<KeyValuePair<string, string>>() { new KeyValuePair<string,string>("/" , "root::node()"), new KeyValuePair<string,string>("/child::doc/child::chapter[position()=5]/child::section[position()=2]" , "root::node()/child::doc/(child::chapter)[position()=5]/(child::section)[position()=2]"), new KeyValuePair<string,string>("/descendant::figure[position()=42]" , "root::node()/(descendant::figure)[position()=42]"), new KeyValuePair<string,string>("/descendant::olist/child::item" , "root::node()/descendant::olist/child::item"), new KeyValuePair<string,string>("/descendant::para" , "root::node()/descendant::para"), new KeyValuePair<string,string>("ancestor-or-self::div" , "ancestor-or-self::div"), new KeyValuePair<string,string>("ancestor::div" , "ancestor::div"), new KeyValuePair<string,string>("attribute::*" , "attribute::*"), new KeyValuePair<string,string>("attribute::name" , "attribute::name"), new KeyValuePair<string,string>("child::*" , "child::*"), new KeyValuePair<string,string>("child::*/child::para" , "child::*/child::para"), new KeyValuePair<string,string>("child::*[self::chapter or self::appendix]" , "(child::*)[self::chapter or self::appendix]"), new KeyValuePair<string,string>("child::*[self::chapter or self::appendix][position()=last()]" , "((child::*)[self::chapter or self::appendix])[position()=last()]"), new KeyValuePair<string,string>("child::chapter/descendant::para" , "child::chapter/descendant::para"), new KeyValuePair<string,string>("child::chapter[child::title='Introduction']" , "(child::chapter)[child::title='Introduction']"), new KeyValuePair<string,string>("child::chapter[child::title]" , "(child::chapter)[child::title]"), new KeyValuePair<string,string>("child::node()" , "child::node()"), new KeyValuePair<string,string>("child::para" , "child::para"), new KeyValuePair<string,string>("child::para[attribute::type='warning']" , "(child::para)[attribute::type='warning']"), new KeyValuePair<string,string>("child::para[attribute::type='warning'][position()=5]" , "((child::para)[attribute::type='warning'])[position()=5]"), new KeyValuePair<string,string>("child::para[position()=1]" , "(child::para)[position()=1]"), new KeyValuePair<string,string>("child::para[position()=5][attribute::type='warning']" , "((child::para)[position()=5])[attribute::type='warning']"), new KeyValuePair<string,string>("child::para[position()=last()-1]" , "(child::para)[position()=last()-1]"), new KeyValuePair<string,string>("child::para[position()=last()]" , "(child::para)[position()=last()]"), new KeyValuePair<string,string>("child::para[position()>1]" , "(child::para)[position()>1]"), new KeyValuePair<string,string>("child::text()" , "child::text()"), new KeyValuePair<string,string>("descendant-or-self::para" , "descendant-or-self::para"), new KeyValuePair<string,string>("descendant::para" , "descendant::para"), new KeyValuePair<string,string>("following-sibling::chapter[position()=1]" , "(following-sibling::chapter)[position()=1]"), new KeyValuePair<string,string>("preceding-sibling::chapter[position()=1]" , "preceding-sibling::chapter[position()=1]"), new KeyValuePair<string,string>("self::para" , "self::para") }; foreach (var item in values) { var result = new XPathParser<string>().Parse(item.Key, new XPathStringBuilder()); Assert.AreEqual<string>(item.Value, result); } }
void IterateOverXPath(IDSFDataObject dataObject, int update, XPathParser parser, ErrorResultTO allErrors, string c, int i) { var xpathEntry = dataObject.Environment.Eval(ResultsCollection[i].XPath, update); var xpathIterator = new WarewolfIterator(xpathEntry); while (xpathIterator.HasMoreData()) { var xpathCol = xpathIterator.GetNextValue(); try { var eval = parser.ExecuteXPath(c, xpathCol).ToList(); var variable = ResultsCollection[i].OutputVariable; AssignResult(variable, dataObject, eval, update); } catch (Exception e) { allErrors.AddError(e.Message); dataObject.Environment.Assign(ResultsCollection[i].OutputVariable, null, update); } } }
private int Process(IDSFDataObject dataObject, int update, int i, XPathParser parser, ErrorResultTO allErrors, ErrorResultTO errors) { if (!string.IsNullOrEmpty(SourceString)) { var itr = new WarewolfListIterator(); var sourceIterator = new WarewolfIterator(dataObject.Environment.Eval(SourceString, update)); itr.AddVariableToIterateOn(sourceIterator); while (itr.HasMoreData()) { var c = itr.FetchNextValue(sourceIterator); for (i = 0; i < ResultsCollection.Count; i++) { if (!string.IsNullOrEmpty(ResultsCollection[i].OutputVariable)) { var xpathEntry = dataObject.Environment.Eval(ResultsCollection[i].XPath, update); var xpathIterator = new WarewolfIterator(xpathEntry); while (xpathIterator.HasMoreData()) { var xpathCol = xpathIterator.GetNextValue(); try { List <string> eval = parser.ExecuteXPath(c, xpathCol).ToList(); var variable = ResultsCollection[i].OutputVariable; AssignResult(variable, dataObject, eval, update); } catch (Exception e) { allErrors.AddError(e.Message); dataObject.Environment.Assign(ResultsCollection[i].OutputVariable, null, update); } } } } allErrors.MergeErrors(errors); } } return(i); }
public static IBase GenerateByID(this IAbstraXProviderService service, string id) { var queue = new Queue<string>(); var parser = new XPathParser<string>(); var builder = new XPathStringBuilder(); parser.Parse(id, builder); if (builder.PartQueue.Count == 1) { var axisElement = builder.PartQueue.OfType<XPathElement>().Single(); var method = service.GetType().GetMethods().Single(m => m.ReturnType.Name == axisElement.Text && m.GetParameters().Length == 0); service.LogGenerateByID(id, method); var rootObject = (IBase)method.Invoke(service, null); service.PostLogGenerateByID(); return rootObject; } else { var axisElement = builder.PartQueue.OfType<XPathElement>().Last(); var method = service.GetType().GetMethods().Single(m => m.ReturnType.Name == "IQueryable`1" && m.GetParameters().Length == 0 && m.ReturnType.GetGenericArguments().Any(a => a.Name == axisElement.Text)); service.LogGenerateByID(id, method); var results = (IQueryable<IBase>)method.Invoke(service, null); service.PostLogGenerateByID(); return results.Where(b => b.ID == id).Single(); } }
/* * StepPattern ::= ChildOrAttributeAxisSpecifier NodeTest Predicate* * ChildOrAttributeAxisSpecifier ::= @ ? | ('child' | 'attribute') '::' */ private QilNode ParseStepPattern() { QilNode opnd; XPathAxis axis; switch (_scanner.Kind) { case LexKind.Dot: case LexKind.DotDot: throw _scanner.CreateException(SR.XPath_InvalidAxisInPattern); case LexKind.At: axis = XPathAxis.Attribute; _scanner.NextLex(); break; case LexKind.Axis: axis = _scanner.Axis; if (axis != XPathAxis.Child && axis != XPathAxis.Attribute) { throw _scanner.CreateException(SR.XPath_InvalidAxisInPattern); } _scanner.NextLex(); // Skip '::' _scanner.NextLex(); break; case LexKind.Name: case LexKind.Star: // NodeTest must start with Name or '*' axis = XPathAxis.Child; break; default: throw _scanner.CreateException(SR.XPath_UnexpectedToken, _scanner.RawValue); } XPathNodeType nodeType; string nodePrefix, nodeName; XPathParser.InternalParseNodeTest(_scanner, axis, out nodeType, out nodePrefix, out nodeName); opnd = _ptrnBuilder.Axis(axis, nodeType, nodePrefix, nodeName); XPathPatternBuilder xpathPatternBuilder = _ptrnBuilder as XPathPatternBuilder; if (xpathPatternBuilder != null) { //for XPathPatternBuilder, get all predicates and then build them List <QilNode> predicates = new List <QilNode>(); while (_scanner.Kind == LexKind.LBracket) { predicates.Add(ParsePredicate(opnd)); } if (predicates.Count > 0) { opnd = xpathPatternBuilder.BuildPredicates(opnd, predicates); } } else { while (_scanner.Kind == LexKind.LBracket) { opnd = _ptrnBuilder.Predicate(opnd, ParsePredicate(opnd), /*reverseStep:*/ false); } } return(opnd); }
/// <include file='doc\XPathReader.uex' path='docs/doc[@for="XPathReader.XPathReader"]/*' /> public XPathReader(XmlReader reader, String xpathexpr) { _Reader = reader; _IfQuery = QueryBuildRecord.ProcessNode(XPathParser.ParseXPathExpresion(xpathexpr)); // this will throw if xpathexpr is invalid }
protected override void ExecuteTool(IDSFDataObject dataObject) { _debugOutputs.Clear(); _isDebugMode = dataObject.IsDebugMode(); ErrorResultTO errors = new ErrorResultTO(); ErrorResultTO allErrors = new ErrorResultTO(); XPathParser parser = new XPathParser(); int i = 0; InitializeDebug(dataObject); try { if (!errors.HasErrors()) { if (_isDebugMode) { AddSourceStringDebugInputItem(SourceString, dataObject.Environment); AddResultDebugInputs(ResultsCollection, out errors); allErrors.MergeErrors(errors); } if (!allErrors.HasErrors()) { var itr = new WarewolfListIterator(); var sourceIterator = new WarewolfIterator(dataObject.Environment.Eval(SourceString)); itr.AddVariableToIterateOn(sourceIterator); while (itr.HasMoreData()) { var c = itr.FetchNextValue(sourceIterator); //foreach(IBinaryDataListItem c in cols) { for (i = 0; i < ResultsCollection.Count; i++) { if (!string.IsNullOrEmpty(ResultsCollection[i].OutputVariable)) { var xpathEntry = dataObject.Environment.Eval(ResultsCollection[i].XPath); var xpathIterator = new WarewolfIterator(xpathEntry); while (xpathIterator.HasMoreData()) { var xpathCol = xpathIterator.GetNextValue(); //foreach(IBinaryDataListItem xPathCol in xpathCols) { try { List <string> eval = parser.ExecuteXPath(c, xpathCol).ToList(); //2013.06.03: Ashley Lewis for bug 9498 - handle line breaks in multi assign string[] openParts = Regex.Split(ResultsCollection[i].OutputVariable, @"\[\["); string[] closeParts = Regex.Split(ResultsCollection[i].OutputVariable, @"\]\]"); if (openParts.Count() == closeParts.Count() && openParts.Count() > 2 && closeParts.Count() > 2) { foreach (var newFieldName in openParts) { if (!string.IsNullOrEmpty(newFieldName)) { string cleanFieldName; if (newFieldName.IndexOf("]]", StringComparison.Ordinal) + 2 < newFieldName.Length) { cleanFieldName = "[[" + newFieldName.Remove(newFieldName.IndexOf("]]", StringComparison.Ordinal) + 2); } else { cleanFieldName = "[[" + newFieldName; } AssignResult(cleanFieldName, dataObject, eval); } } } else { var variable = ResultsCollection[i].OutputVariable; AssignResult(variable, dataObject, eval); } } catch (Exception e) { allErrors.AddError(e.Message); dataObject.Environment.Assign(ResultsCollection[i].OutputVariable, null); } } } } } } allErrors.MergeErrors(errors); } } if (_isDebugMode && !allErrors.HasErrors()) { var innerCount = 1; foreach (var debugOutputTo in ResultsCollection) { var itemToAdd = new DebugItem(); AddDebugItem(new DebugItemStaticDataParams("", innerCount.ToString(CultureInfo.InvariantCulture)), itemToAdd); AddDebugItem(new DebugEvalResult(DataListUtil.ReplaceRecordsetBlankWithStar(debugOutputTo.OutputVariable), "", dataObject.Environment), itemToAdd); _debugOutputs.Add(itemToAdd); innerCount++; } } } } catch (Exception ex) { allErrors.AddError(ex.Message); } finally { // Handle Errors var actualIndex = i - 1; var hasErrors = allErrors.HasErrors(); if (hasErrors) { DisplayAndWriteError("DsfXPathActivity", allErrors); var errorString = allErrors.MakeDataListReady(); dataObject.Environment.AddError(errorString); if (actualIndex > -1) { dataObject.Environment.Assign(ResultsCollection[actualIndex].OutputVariable, null); } } if (_isDebugMode) { if (hasErrors) { if (_isDebugMode) { var itemToAdd = new DebugItem(); if (actualIndex < 0) { actualIndex = 0; } AddDebugItem(new DebugItemStaticDataParams("", (actualIndex + 1).ToString(CultureInfo.InvariantCulture)), itemToAdd); AddDebugItem(new DebugEvalResult(ResultsCollection[actualIndex].OutputVariable, "", dataObject.Environment), itemToAdd); _debugOutputs.Add(itemToAdd); } } DispatchDebugState(dataObject, StateType.Before); DispatchDebugState(dataObject, StateType.After); } } }
public static AstNode ParseXPathPattern(string xpathPattern) { XPathScanner scanner = new XPathScanner(xpathPattern); AstNode node = new XPathParser(scanner).ParsePattern(null); if (scanner.Kind != XPathScanner.LexKind.Eof) { throw XPathException.Create("Xp_InvalidToken", scanner.SourceText); } return node; }
// don't return true or false, if it's invalid path, just throw exception during the process // for whitespace thing, i will directly trim the tree built here... public void CompileXPath(string xPath, bool isField, XmlNamespaceManager nsmgr) { if ((xPath == null) || (xPath.Length == 0)) { throw new XmlSchemaException(SR.Sch_EmptyXPath, string.Empty); } // firstly i still need to have an ArrayList to store tree only... // can't new ForwardAxis right away string[] xpath = xPath.Split('|'); ArrayList AstArray = new ArrayList(xpath.Length); _fAxisArray = new ArrayList(xpath.Length); // throw compile exceptions // can i only new one builder here then run compile several times?? try { for (int i = 0; i < xpath.Length; ++i) { // default ! isdesorself (no .//) Axis ast = (Axis)(XPathParser.ParseXPathExpression(xpath[i])); AstArray.Add(ast); } } catch { throw new XmlSchemaException(SR.Sch_ICXpathError, xPath); } Axis?stepAst; for (int i = 0; i < AstArray.Count; ++i) { Axis ast = (Axis)AstArray[i] !; // Restricted form // field can have an attribute: // throw exceptions during casting if ((stepAst = ast) == null) { throw new XmlSchemaException(SR.Sch_ICXpathError, xPath); } Axis top = stepAst; // attribute will have namespace too // field can have top attribute if (IsAttribute(stepAst)) { if (!isField) { throw new XmlSchemaException(SR.Sch_SelectorAttr, xPath); } else { SetURN(stepAst, nsmgr); try { stepAst = (Axis?)(stepAst.Input); } catch { throw new XmlSchemaException(SR.Sch_ICXpathError, xPath); } } } // field or selector while ((stepAst != null) && (IsNameTest(stepAst) || IsSelf(stepAst))) { // trim tree "." node, if it's not the top one if (IsSelf(stepAst) && (ast != stepAst)) { top.Input = stepAst.Input; } else { top = stepAst; // set the URN if (IsNameTest(stepAst)) { SetURN(stepAst, nsmgr); } } try { stepAst = (Axis?)(stepAst.Input); } catch { throw new XmlSchemaException(SR.Sch_ICXpathError, xPath); } } // the rest part can only be .// or null // trim the rest part, but need compile the rest part first top.Input = null; if (stepAst == null) { // top "." and has other element beneath, trim this "." node too if (IsSelf(ast) && (ast.Input != null)) { _fAxisArray.Add(new ForwardAxis(DoubleLinkAxis.ConvertTree((Axis)(ast.Input)), false)); } else { _fAxisArray.Add(new ForwardAxis(DoubleLinkAxis.ConvertTree(ast), false)); } continue; } if (!IsDescendantOrSelf(stepAst)) { throw new XmlSchemaException(SR.Sch_ICXpathError, xPath); } try { stepAst = (Axis?)(stepAst.Input); } catch { throw new XmlSchemaException(SR.Sch_ICXpathError, xPath); } if ((stepAst == null) || (!IsSelf(stepAst)) || (stepAst.Input != null)) { throw new XmlSchemaException(SR.Sch_ICXpathError, xPath); } // trim top "." if it's not the only node if (IsSelf(ast) && (ast.Input != null)) { _fAxisArray.Add(new ForwardAxis(DoubleLinkAxis.ConvertTree((Axis)(ast.Input)), true)); } else { _fAxisArray.Add(new ForwardAxis(DoubleLinkAxis.ConvertTree(ast), true)); } } }
private QilGenerator(bool debug) { _scope = new CompilerScopeManager<QilIterator>(); _outputScope = new OutputScopeManager(); _prefixesInUse = new HybridDictionary(); _f = new XsltQilFactory(new QilFactory(), debug); _xpathBuilder = new XPathBuilder((IXPathEnvironment)this); _xpathParser = new XPathParser<QilNode>(); _ptrnBuilder = new XPathPatternBuilder((IXPathEnvironment)this); _ptrnParser = new XPathPatternParser(); _refReplacer = new ReferenceReplacer(_f.BaseFactory); _invkGen = new InvokeGenerator(_f, debug); _matcherBuilder = new MatcherBuilder(_f, _refReplacer, _invkGen); _singlFocus = new SingletonFocus(_f); _funcFocus = new FunctionFocus(); _curLoop = new LoopFocus(_f); _strConcat = new QilStrConcatenator(_f); _varHelper = new VariableHelper(_f); _elementOrDocumentType = T.DocumentOrElement; _textOrAttributeType = T.NodeChoice(XmlNodeKindFlags.Text | XmlNodeKindFlags.Attribute); _nameCurrent = _f.QName("current", XmlReservedNs.NsXslDebug); _namePosition = _f.QName("position", XmlReservedNs.NsXslDebug); _nameLast = _f.QName("last", XmlReservedNs.NsXslDebug); _nameNamespaces = _f.QName("namespaces", XmlReservedNs.NsXslDebug); _nameInit = _f.QName("init", XmlReservedNs.NsXslDebug); _formatterCnt = 0; }
protected override void OnExecute(NativeActivityContext context) { _debugOutputs.Clear(); IDSFDataObject dataObject = context.GetExtension <IDSFDataObject>(); IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); IDev2DataListUpsertPayloadBuilder <List <string> > toUpsert = Dev2DataListBuilderFactory.CreateStringListDataListUpsertBuilder(); _isDebugMode = dataObject.IsDebugMode(); toUpsert.IsDebug = _isDebugMode; toUpsert.ResourceID = dataObject.ResourceID; ErrorResultTO errors = new ErrorResultTO(); ErrorResultTO allErrors = new ErrorResultTO(); Guid executionId = DataListExecutionID.Get(context); XPathParser parser = new XPathParser(); int i = 0; InitializeDebug(dataObject); try { if (!errors.HasErrors()) { IBinaryDataListEntry expressionsEntry = compiler.Evaluate(executionId, enActionType.User, SourceString, false, out errors); if (_isDebugMode) { AddSourceStringDebugInputItem(SourceString, expressionsEntry, executionId); AddResultDebugInputs(ResultsCollection, executionId, compiler, out errors); allErrors.MergeErrors(errors); } if (!allErrors.HasErrors()) { IDev2DataListEvaluateIterator itr = Dev2ValueObjectFactory.CreateEvaluateIterator(expressionsEntry); while (itr.HasMoreRecords()) { IList <IBinaryDataListItem> cols = itr.FetchNextRowData(); foreach (IBinaryDataListItem c in cols) { for (i = 0; i < ResultsCollection.Count; i++) { if (!string.IsNullOrEmpty(ResultsCollection[i].OutputVariable)) { IBinaryDataListEntry xpathEntry = compiler.Evaluate(executionId, enActionType.User, ResultsCollection[i].XPath, false, out errors); IDev2DataListEvaluateIterator xpathItr = Dev2ValueObjectFactory.CreateEvaluateIterator(xpathEntry); while (xpathItr.HasMoreRecords()) { IList <IBinaryDataListItem> xpathCols = xpathItr.FetchNextRowData(); foreach (IBinaryDataListItem xPathCol in xpathCols) { try { List <string> eval = parser.ExecuteXPath(c.TheValue, xPathCol.TheValue).ToList(); //2013.06.03: Ashley Lewis for bug 9498 - handle line breaks in multi assign string[] openParts = Regex.Split(ResultsCollection[i].OutputVariable, @"\[\["); string[] closeParts = Regex.Split(ResultsCollection[i].OutputVariable, @"\]\]"); if (openParts.Count() == closeParts.Count() && openParts.Count() > 2 && closeParts.Count() > 2) { foreach (var newFieldName in openParts) { if (!string.IsNullOrEmpty(newFieldName)) { string cleanFieldName; if (newFieldName.IndexOf("]]", StringComparison.Ordinal) + 2 < newFieldName.Length) { cleanFieldName = "[[" + newFieldName.Remove(newFieldName.IndexOf("]]", StringComparison.Ordinal) + 2); } else { cleanFieldName = "[[" + newFieldName; } toUpsert.Add(cleanFieldName, eval); } } } else { toUpsert.Add(ResultsCollection[i].OutputVariable, eval); } } catch (Exception) { toUpsert.Add(ResultsCollection[i].OutputVariable, null); } } } } } compiler.Upsert(executionId, toUpsert, out errors); } allErrors.MergeErrors(errors); } } if (_isDebugMode && !allErrors.HasErrors()) { var innerCount = 1; foreach (var debugOutputTo in toUpsert.DebugOutputs) { var itemToAdd = new DebugItem(); AddDebugItem(new DebugItemStaticDataParams("", innerCount.ToString(CultureInfo.InvariantCulture)), itemToAdd); AddDebugItem(new DebugItemVariableParams(debugOutputTo), itemToAdd); _debugOutputs.Add(itemToAdd); innerCount++; } toUpsert.DebugOutputs.Clear(); } } } catch (Exception ex) { allErrors.AddError(ex.Message); } finally { // Handle Errors var actualIndex = i - 1; var hasErrors = allErrors.HasErrors(); if (hasErrors) { DisplayAndWriteError("DsfXPathActivity", allErrors); compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors); compiler.Upsert(executionId, ResultsCollection[actualIndex].OutputVariable, (string)null, out errors); } if (_isDebugMode) { if (hasErrors) { if (_isDebugMode) { ResultsCollection[actualIndex].XPath = ""; var itemToAdd = new DebugItem(); AddDebugItem(new DebugItemStaticDataParams("", (actualIndex + 1).ToString(CultureInfo.InvariantCulture)), itemToAdd); AddDebugItem(new DebugOutputParams(ResultsCollection[actualIndex].OutputVariable, "", executionId, actualIndex + 1), itemToAdd); _debugOutputs.Add(itemToAdd); } } DispatchDebugState(context, StateType.Before); DispatchDebugState(context, StateType.After); } } }
public static AutomationElement AutomationElementFromWPath(string wPath) { var xe = new XPathParser <object>().Parse(wPath, new XPathUIElementBuilder(RootElement?.AutomationElement)); return(xe as AutomationElement); }