I am trying to think of the XML rules engine which will take a input in the form of the Byte Stream( from socket) and create a logical structure (Java object out of it). I would like to specify the rules in XML as to how to traverse through the byte array and which bytes in the byte array transform to which attributes of the java object. The input us the byte array and output is structured Java object. I need to specify the conversion functions e.g integer stored in the byte array from 0 bit position to 25 bit position will map to string field in the Java object. Does any one know any examples or model which can give me start or idea of how to structure these mapping rules.I appreciate your help.
The byte offset approach is a bit difficult when dealing with variable-length strings. For example, if you specify that from an Email object the "subject", "recipient" and "body" fields need to be serialized to byte offsets 0-199, 200-299 and 300-1299, respectively, and the values for "subject", "recipient" and "body" aren't exactly 200, 100 and 1000 bytes long, you'll have to fill in the blanks somehow. Similarly, what do you do when one email has a subject over 200 bytes long?
Would it be possible to just specify the order in which each field is presented in the stream? E.g. something like this: