So at work we have an XML-based system where we need to serialize a list of arguments between a server and a client. The list is defined on the server, serialized to the client for processing and sent back to the server by the client. This list consists of an arbitrary set of properties each with their own type.
For now just ignore why we aren't using XSD or some other standard system for doing this. We have two choices:
1) set XML item name to property name, add a type attribute to specify type e.g.
<Age type="int">10</Age>
<FirstName type="string">John</FirstName>
<LastName type="string">Doe</LastName>
2) set XML item name to type, specify name in attribute:
<Int name="age">10</Int>
<String name="FirstName">John</String>
<String name="LastName">Doe</String>
Now both of these accomplish the same thing so there is a bit of a debate on which is better. Personally I favor 1 because this seems more inline with how XML is typically used, and the client could send just the property names and values provided the server knows the schema (which it does - the client cannot modify the types) e.g. <Age>10</Age>. Also a more specialized client coded against a specific instance of such a list wouldn't even need the type information itself. However the counter-argument for using 2) is that it more naturally reflects how the generic client parser might process the data.
What do you guys think? I don't think there's any right or wrong here, but just want to see what people generally think.
For now just ignore why we aren't using XSD or some other standard system for doing this. We have two choices:
1) set XML item name to property name, add a type attribute to specify type e.g.
<Age type="int">10</Age>
<FirstName type="string">John</FirstName>
<LastName type="string">Doe</LastName>
2) set XML item name to type, specify name in attribute:
<Int name="age">10</Int>
<String name="FirstName">John</String>
<String name="LastName">Doe</String>
Now both of these accomplish the same thing so there is a bit of a debate on which is better. Personally I favor 1 because this seems more inline with how XML is typically used, and the client could send just the property names and values provided the server knows the schema (which it does - the client cannot modify the types) e.g. <Age>10</Age>. Also a more specialized client coded against a specific instance of such a list wouldn't even need the type information itself. However the counter-argument for using 2) is that it more naturally reflects how the generic client parser might process the data.
What do you guys think? I don't think there's any right or wrong here, but just want to see what people generally think.
Last edited: