3 ms·
I haven't used XML is a long while, but there was a trick I had when I designed schemas, back when I did use XML all the time. Use an attribute if the data is a
by Communitivity 3y ago
I haven't used XML is a long while, but there was a trick I had when I designed schemas, back when I did use XML all the time. Use an attribute if the data is a primitive String, number, or boolean. Break into multiple attributes if the data is structured but has only one level and has few children. Otherwise use an element. The three rules are simple, but produce schemas easy to read, easy to maintain, and easy to implement against. One code smell is if you start winding up with tons of attributes on one element. That may mean you should break the logical concept that element represents into multiple concepts, have those concepts be nested elements, each with its related attributes.