mvdXML
mvdXML copied to clipboard
string parsing
use something else than strings for rules
Yes, this topic is open for discussion. Please add you opinion to this issue!
This question already came up for mvdXML 1.1, but we then decided to keep the string-based solution because of compatibility reasons and to add a grammar to support rule-parsing. I am not sure how far we can go with this solution. So, please comment on this issue and describe your prefered solution (maybe as an implementer or an mvdXML developer).
Here's an approach consistent with most execution environments -- indicate each operation underneath the Constraint tag using something like:
{Operation operator="or"} {Operation operator="equals"} {Operation operator="loadfield" operand="PredefinedType"/} {Operation operator="loadstring" operand="NOTDEFINED"/} {/Operation} {Operation operator="notequals"} {Operation operator="loadfield" operand="ObjectType"/} {Operation operator="loadnull"} {/Operation} {/Operation}
This approach would be extensible and correspond directly to virtual machines (e.g. Java runtime, .NET runtime) executing op codes, where the "operator" corresponds to a specific op code and stack behavior (i.e. types of values pushed or popped from stack). The "operand" would depend on the particular operation.
List of operators (could be expanded later): and -- pops two values, pushes true if either is true or xor equals -- pops two values, pushes true if equal notequals greaterthan lessthan greaterthanorequal lessthanorequal loadfield -- pushes a value by reference (identifies a particular EntityRule by ID) loadlen -- pushes length of array/collection loadstring -- pushes a string constant loadinteger -- pushes an integer constant loadnull -- pushes NULL onto the stack isinst -- checks if object is an instance of type
This structure is now used internally with IfcDoc, where it makes it easy to compile this into executable functions and transform it into different representations (e.g. EXPRESS, C#, Excel formula notation).
We could keep the existing string-based solution which could be used as backup/informational for easily viewing and retaining compatibility.