condition - conditional logic in xml storage -


i have situation need pull in different statements xml, based on values set of variables. e.g.

if a>10 , b<20 string="ancd" if a>10 , (d+e)<0 string="defg" else string="xyz" 

rather build these conditions in code, possible cleanly have them in xml in structure this, , code parse condition strings , string value?

<conditionalstring> <condition>"a>10 , b<20"</condition> <string>"ancd"</string> </conditionalstring> <conditionalstring> <condition>"a>10 , (d+e)<0"</condition> <string>"defg"</string> </conditionalstring> <conditionalstring> <condition>default</condition> <string>"xyz"</string> </conditionalstring> 

you can store logic xml. question is, how out , evaluate conditions? lot depend here on language , tools you're using. if have expression parser available (e.g. if working in language eval() such perl, python, javascript, , many others), might able leverage that. if you're working in .net, might able use windows workflow rules engine (http://msdn.microsoft.com/en-us/library/dd349785.aspx). otherwise, you'll need borrow other language's parser (e.g. in .net or java find scheme interpreter or python interpreter or something), or you'll have write parser of own. if you've not written parser before, take time, might want consider leveraging existing one.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -