4 ms·
http://www.flightlab.com/~joe/sgml/faq-not.txt http://www.flightlab.com/~joe/sgml/faq-not.txt Q. I'm designing my first DTD. Should I use elements or attribu
by ubernostrum 8y ago
http://www.flightlab.com/~joe/sgml/faq-not.txt http://www.flightlab.com/~joe/sgml/faq-not.txt
Q. I'm designing my first DTD. Should I use elements or attributes to store data?
A. Of course. What else would you use?
Q. What is the usual way to choose between using attributes and children?
[Update from David Carlisle:]
In England, the normal method is to flip a coin in the air and call heads it's attributes, tails it's children.
Unfortunately I'm not sure what to suggest in other countries where you can't guarantee having the Queen's head on one side of every coin.
- tannhaeuser 8y agoHilarious, but the deeper rule is: when there isn't a concept of rendering a document to the user (where attributes hold rendering properties not directly presented to a user) the concept of a markup language doesn't make sense in the first place. So if you find yourself in a situation where you need to decide on encoding data as elements vs attributes, you probably shouldn't use SGML/XML at all. But then there is the wealth of XML standard data representations for financial/fiscal/e-commerce, medical, etc. data. You're deciding to use them to have your interfaces being implemented once and for all, and be able to switch eg. payment providers by merely specifying new endpoints and credentials. JSON doesn't really compare to XML/XSD in this space.