views:

32

answers:

1

I am going to work with some XML files containing logic sentences like these:

<condition>
     <or>
        <not>
           <eq>
               <variable>
                   <name>X</name>
                   <variabletype>Test</variabletype>
                   <datatype>String</datatype>
                </variable>
                <constant>
                   <value>finished</value>
                   <datatype>String</datatype>
                 </constant>
            <eq>
         </not>
         <gt>
           <variable>
                <name>X</name>
                <variabletype>Result</variabletype>
                <datatype>int</datatype>
           </variable>
           <constant>
                <value>50</value>
                <datatype>int</datatype>
           </constant>
         </gt> 
   </or>

My questions: 1- Is there any standard XML schema for displaying logic sentences in XML files? I am looking for something like RFC (Request for comments).

2- What is the best way to translate and evaluate these sentences in XML files with help of Java? 3- I want to write code for autogenerating a GUI which with help of it users can change the value of variables in logic sentences? Is there any special technique to generate GUI (Swing or Jface) from XML files?

Appreciating your advise and help

A: 

1- Not as far as I know. This looks a bit like MathML, but specific to logic sentences, and added types. You seem to have a specific idea already, so I doubt a standard would fit what you're looking for.

2- You need some intermediate classes, such as Sentence, Function, Variable and Constant, and implement a method like evaluate(). There are various ways to create the matching objects. A simple way in Java (without an additional library) would be to parse the XML as a DOM tree, and go through it to create a corresponding tree with your classes.

3- You could use an XML editor like Jaxe, with a config file to customize the GUI. However, in this case, I would also consider defining a text syntax for your logic sentences and a related parser. You could let users enter a text like "!(X="finished") | (Y>50)" and use more GUI to define the type for X and Y. As with MathML, if you ask the user for XML, even with a nice GUI, you end up with something rather verbose.

Damien
1- Thanks. I will check MathML. 2- I thought about intermediate classes too. It will be interesting if it is possible to generate the code with help of XSL transformation. But I think it is impossible or too hard and I have to choose parsing. 3- It will be XML-parsing for GUI generating. Thanks again
Govan