public void RepeatExtensionWithComplexIfOption() { var x = new BxlParser().Parse(@" e was-excluded ${mycode} xi-repeat=data xi-where=!include xi-expand not-complete ${mycode} ${myname} xi-repeat=data xi-where='!(mycode & myname)' xi-expand more-than-2 ${mycode} ${myname} xi-repeat=data xi-where='mycode > 2' xi-expand ", options: BxlParserOptions.NoLexData | BxlParserOptions.ExtractSingle); _xi = new XmlInterpolation { UseExtensions = true }; var ctx = new { data = new object[] { new { mycode = 2, myname = "Two", include = true }, new { mycode = 3, myname = "Three", include = false }, new { mycode = 0, myname = "Four", include = true }, new { mycode = 5, myname = "", include = false } } }; var cfg = new Scope(ctx.ToDict()); x = _xi.Interpolate(x, cfg); Console.WriteLine(x.ToString().Replace("\"", "'")); Assert.AreEqual(@"<e> <was-excluded code='3' id='3' /> <was-excluded code='5' id='5' /> <not-complete code='0' id='0' name='Four' /> <not-complete code='5' id='5' name='' /> <more-than-2 code='3' id='3' name='Three' /> <more-than-2 code='5' id='5' name='' /> </e>".Simplify(SimplifyOptions.Full), x.ToString().Simplify(SimplifyOptions.Full)); }
public void RepeatExtensionWithIfOption() { var x = new BxlParser().Parse(@" e b=true x xi-repeat=data xi-body xi-where=include xi-if=!b xi-expand x-code ${mycode} x=1 xi-if=mycode x-name ${myname} x=1 xi-if=myname x xi-repeat=data xi-body xi-where=include xi-if=b xi-expand x-code ${mycode} x=2 xi-if=mycode x-name ${myname} x=2 xi-if=myname ", options: BxlParserOptions.NoLexData | BxlParserOptions.ExtractSingle); _xi = new XmlInterpolation { UseExtensions = true }; var ctx = new { data = new object[] { new { mycode = 2, myname = "Two", include = true }, new { mycode = 3, myname = "Three", include = false }, new { mycode = 0, myname = "Four", include = true }, new { mycode = 5, myname = "", include = true } } }; var cfg = new Scope(ctx.ToDict()); x = _xi.Interpolate(x, cfg); Console.WriteLine(x.ToString().Replace("\"", "'")); Assert.AreEqual(@"<e b='true'> <x-code code='2' id='2' x='2' /> <x-name code='Two' id='Two' x='2' /> <x-name code='Four' id='Four' x='2' /> <x-code code='5' id='5' x='2' /> </e>".Simplify(SimplifyOptions.Full), x.ToString().Simplify(SimplifyOptions.Full)); }
public void PreventNameAnonymAfterAnyNamed(){ var code = @" e c x=1 n "; var b = new BxlParser().Parse(code,"",BxlParserOptions.NoLexData); Console.WriteLine(b.ToString().Replace("\"", "'")); Assert.AreEqual(@"<root> <e code='c' id='c' x='1' n='1' /> </root>", b.ToString().Replace("\"", "'")); }
public void UsesNamespacesInAttributeNames() { var res = new BxlParser().Parse(@" ns = 'http://myns' ns::test ns::attr=2"); Console.WriteLine(res.ToString()); Assert.AreEqual(@"<root xmlns:ns=""http://myns"" _file=""code.bxl""> <ns:test _file=""code.bxl"" _line=""3"" ns:attr=""2"" /> </root>".LfOnly(), res.ToString().LfOnly()); }
public void GeneratesNamespaceDeclarations() { var res = new BxlParser().Parse(@" ns = 'http://myns' test"); Console.WriteLine(res.ToString()); Assert.AreEqual(@"<root xmlns:ns=""http://myns"" _file=""code.bxl""> <test _file=""code.bxl"" _line=""3"" /> </root>".LfOnly(), res.ToString().LfOnly()); }
public void PreventNameAnonymAfterAnyNamedWithoutCode() { var code = @" e x=1 n "; var b = new BxlParser().Parse(code, "", BxlParserOptions.NoLexData); Console.WriteLine(b.ToString().Replace("\"", "'")); Assert.AreEqual(@"<root> <e x='1' n='1' /> </root>", b.ToString().Replace("\"", "'")); }
public void Implicit_Namespace_Generation() { var res = new BxlParser().Parse(@" a::e1 b::e1", "myfile", BxlParserOptions.NoLexData); Console.WriteLine(res.ToString()); Assert.AreEqual(@"<root xmlns:a=""namespace::myfile_X"" xmlns:b=""namespace::myfile_XX""> <a:e1 /> <b:e1 /> </root>".LfOnly(), res.ToString().LfOnly()); }
public void NotOverrideId() { var code = @" e id=1 c n x=1 "; var b = new BxlParser().Parse(code, "", BxlParserOptions.NoLexData); Console.WriteLine(b.ToString().Replace("\"", "'")); Assert.AreEqual(@"<root> <e id='1' code='c' name='n' x='1' /> </root>", b.ToString().Replace("\"", "'")); }
public void NameAnonymAfterNoAnyNamed() { var code = @" e c n x=1 "; var b = new BxlParser().Parse(code, "", BxlParserOptions.NoLexData); Console.WriteLine(b.ToString().Replace("\"", "'")); Assert.AreEqual(@"<root> <e code='c' id='c' name='n' x='1' /> </root>", b.ToString().Replace("\"", "'")); }
public void CanInterpolateDuringParse() { var res = new BxlParser().Parse(@" test x='1' y=3 test2 x='${.x}${y}2' test3 y='${x}${.y}' " , "", BxlParserOptions.PerformInterpolation); Console.WriteLine(res.ToString()); Assert.AreEqual(@"<root _file=""code.bxl""> <test _file=""code.bxl"" _line=""2"" x=""1"" y=""3""> <test2 _file=""code.bxl"" _line=""3"" x=""132""> <test3 _file=""code.bxl"" _line=""4"" y=""1323"" /> </test2> </test> </root>", res.ToString()); }
public void RepeatExtensionWithBodyOption() { var x = new BxlParser().Parse(@" e x xi-repeat=data xi-body xi-expand x-code ${mycode} x-name ${myname} ", options: BxlParserOptions.NoLexData | BxlParserOptions.ExtractSingle); var ctx = new { data = new object[] { new { mycode = 2, myname = "Two" }, new { mycode = 3, myname = "Three" } } }; x = x.Interpolate(ctx); Console.WriteLine(x.ToString().Replace("\"", "'")); Assert.AreEqual(@"<e> <x-code code='2' id='2' /> <x-name code='Two' id='Two' /> <x-code code='3' id='3' /> <x-name code='Three' id='Three' /> </e>".Simplify(SimplifyOptions.Full), x.ToString().Simplify(SimplifyOptions.Full)); }
public void CanParseAttribuesAfterElements() { var res = new BxlParser().Parse(@" test test2 y=3 test3 x=2" ); Console.WriteLine(res.ToString()); }
public void RepeatWithScopeExtension() { var x = new BxlParser().Parse(@" e mycode=1 myname=2 x ${x.mycode} ${x.myname} mc=${mycode} mn=${myname} xi-repeat=data xi-scope=x ", options: BxlParserOptions.NoLexData | BxlParserOptions.ExtractSingle); _xi = new XmlInterpolation { UseExtensions = true }; var ctx = new { data = new object[] { new { mycode = 2, myname = "Two" }, new { mycode = 3, myname = "Three" } } }; var cfg = new Scope(ctx.ToDict()); x = _xi.Interpolate(x, cfg); Console.WriteLine(x.ToString().Replace("\"", "'")); Assert.AreEqual(@"<e mycode='1' myname='2'> <x code='2' id='2' name='Two' mc='1' mn='2' /> <x code='3' id='3' name='Three' mc='1' mn='2' /> </e>".Simplify(SimplifyOptions.Full), x.ToString().Simplify(SimplifyOptions.Full)); }
public void RepeatLocalSetExtension() { var x = new BxlParser().Parse(@" xi-dataset x x x=${mycode} y=${myname} xi-repeat=data xi-expand e u=33 i ${x}${x} ${y}${y} z=${u} xi-repeat=$x xi-expand ", options: BxlParserOptions.NoLexData | BxlParserOptions.ExtractSingle); var ctx = new { data = new object[] { new { mycode = 2, myname = "Two" }, new { mycode = 3, myname = "Three" } } }; x = x.Interpolate(ctx); Console.WriteLine(x.ToString().Replace("\"", "'")); Assert.AreEqual(@"<root> <xi-dataset code='x' id='x'> <x x='2' y='Two' /> <x x='3' y='Three' /> </xi-dataset> <e u='33'> <i code='22' id='22' name='TwoTwo' z='33' /> <i code='33' id='33' name='ThreeThree' z='33' /> </e> </root>".Simplify(SimplifyOptions.Full), x.ToString().Simplify(SimplifyOptions.Full)); }
public void ValidlyParsesEmptyStrings() { var code = @" x x='' y="""" z="""""""""""" : """" a = """" y a=1 "; var b = new BxlParser().Parse(code, "", BxlParserOptions.NoLexData); Console.WriteLine(b.ToString().Replace("\"", "'")); Assert.AreEqual(@"<root> <x x='' y='' z='' a=''></x> <y a='1' /> </root>", b.ToSqlString().Replace("\"", "'")); }
public void ValidlyParsesEmptyStringsBasis() { var code = @" n g f s ""X"" i c a=b p = """" i c a=b p = """" "; var b = new BxlParser().Parse(code, "", BxlParserOptions.NoLexData); Console.WriteLine(b.ToString().Replace("\"", "'")); Assert.AreEqual(@"<root> <n code='g' id='g'> <f code='s' id='s' name='X'> <i code='c' id='c' a='b' p='' /> <i code='c' id='c' a='b' p='' /> </f> </n> </root>", b.ToSqlString().Replace("\"", "'")); }
public void RepeatExtensionWithComplexIfOption() { var x = new BxlParser().Parse(@" e was-excluded ${mycode} xi-repeat=data xi-where=!include xi-expand not-complete ${mycode} ${myname} xi-repeat=data xi-where='!(mycode & myname)' xi-expand more-than-2 ${mycode} ${myname} xi-repeat=data xi-where='mycode > 2' xi-expand ", options: BxlParserOptions.NoLexData | BxlParserOptions.ExtractSingle); _xi = new XmlInterpolation { UseExtensions = true }; var ctx = new { data = new object[] { new { mycode = 2, myname = "Two", include=true }, new { mycode = 3, myname = "Three", include=false }, new { mycode = 0, myname = "Four", include=true }, new { mycode = 5, myname = "", include=false } } }; var cfg = new Scope(ctx.ToDict()); x = _xi.Interpolate(x, cfg); Console.WriteLine(x.ToString().Replace("\"", "'")); Assert.AreEqual(@"<e> <was-excluded code='3' id='3' /> <was-excluded code='5' id='5' /> <not-complete code='0' id='0' name='Four' /> <not-complete code='5' id='5' name='' /> <more-than-2 code='3' id='3' name='Three' /> <more-than-2 code='5' id='5' name='' /> </e>".Simplify(SimplifyOptions.Full), x.ToString().Simplify(SimplifyOptions.Full)); }
public void RepeatExtensionWithIfOption() { var x = new BxlParser().Parse(@" e b=true x xi-repeat=data xi-body xi-where=include xi-if=!b xi-expand x-code ${mycode} x=1 xi-if=mycode x-name ${myname} x=1 xi-if=myname x xi-repeat=data xi-body xi-where=include xi-if=b xi-expand x-code ${mycode} x=2 xi-if=mycode x-name ${myname} x=2 xi-if=myname ", options: BxlParserOptions.NoLexData | BxlParserOptions.ExtractSingle); _xi = new XmlInterpolation { UseExtensions = true }; var ctx = new { data = new object[] { new { mycode = 2, myname = "Two", include=true }, new { mycode = 3, myname = "Three", include=false }, new { mycode = 0, myname = "Four", include=true }, new { mycode = 5, myname = "", include=true } } }; var cfg = new Scope(ctx.ToDict()); x = _xi.Interpolate(x, cfg); Console.WriteLine(x.ToString().Replace("\"", "'")); Assert.AreEqual(@"<e b='true'> <x-code code='2' id='2' x='2' /> <x-name code='Two' id='Two' x='2' /> <x-name code='Four' id='Four' x='2' /> <x-code code='5' id='5' x='2' /> </e>".Simplify(SimplifyOptions.Full), x.ToString().Simplify(SimplifyOptions.Full)); }
public void RepeatWithScopeExtensionAndFunctionCall() { var x = new BxlParser().Parse(@" e mycode=1 myname=aa x ${x.mycode} ${x.myname} mf=${upper(myname)} mc=${mycode} mn=${myname} xi-repeat=data xi-scope=x ", options: BxlParserOptions.NoLexData | BxlParserOptions.ExtractSingle); _xi = new XmlInterpolation { UseExtensions = true }; var ctx = new { data = new object[] { new { mycode = 2, myname = "Two" }, new { mycode = 3, myname = "Three" } } }; var cfg = new Scope(ctx.ToDict()); cfg["upper"] = (Func<string, string>) (s => s.ToUpper()); x = _xi.Interpolate(x, cfg); Console.WriteLine(x.ToString().Replace("\"", "'")); Assert.AreEqual(@"<e mycode='1' myname='aa'> <x code='2' id='2' name='Two' mf='AA' mc='1' mn='aa' /> <x code='3' id='3' name='Three' mf='AA' mc='1' mn='aa' /> </e>".Simplify(SimplifyOptions.Full), x.ToString().Simplify(SimplifyOptions.Full)); }
public void RepeatExtension() { var x = new BxlParser().Parse(@" e u=33 x ${mycode} ${myname} z=${u} xi-repeat=data xi-expand ",options:BxlParserOptions.NoLexData|BxlParserOptions.ExtractSingle); _xi = new XmlInterpolation {UseExtensions = true}; var ctx = new {data = new object[] {new {mycode = 2, myname = "Two"}, new {mycode = 3, myname = "Three"}}}; var cfg = new Scope(ctx.ToDict()); x = _xi.Interpolate(x, cfg); Console.WriteLine(x.ToString().Replace("\"","'")); Assert.AreEqual(@"<e u='33'> <x code='2' id='2' name='Two' z='33' /> <x code='3' id='3' name='Three' z='33' /> </e>".Simplify(SimplifyOptions.Full), x.ToString().Simplify(SimplifyOptions.Full)); }
public void SupportBracesInLiteral() { var res = new BxlParser().Parse("test val(1)"); Console.WriteLine(res.ToString()); }
public void ValidlyParsesEmptyStrings(){ var code = @" x x='' y="""" z="""""""""""" : """" a = """" y a=1 "; var b = new BxlParser().Parse(code, "", BxlParserOptions.NoLexData); Console.WriteLine(b.ToString().Replace("\"", "'")); Assert.AreEqual(@"<root> <x x='' y='' z='' a=''></x> <y a='1' /> </root>",b.ToSqlString().Replace("\"","'")); }