This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
OK, I tried to give my co-worker good reasons why something is a parameter of a tag, versus making it an inner tag of that tag. I went into the parameter being more of a configuration of the tag, whereas it would be a tag if the information stored is more data related. In his example he had a <PRINTER> tag. He wanted to store Name, IP, Availability, Status, and Location. I used Location as an example. So I told him that Name, IP, Availability, and Status where better as tags, and Location as a parameter. Since if you were converting this XML to HTML using XSLT, the first four values would be what you wanted displayed in an HTML Table, but Location is used as XSLT If statement conditions. Meaning like so Location can be Local or Network. But where the location of the printer actually is makes no difference to the user of the HTML document, Now the HTML document and XSLT should handle the location of printers differently. Maybe local printers in Green and network printers in Red. SO since this is really just going to be used in an IF statement in the XSLT document, then it is better as a parameter. Does this make sense. Am I smoking crack or something, or does someone else have a better answer for him. I know I had read something somewhere explaining this, but I can't remember where? Thanks Mark
I think it is all personal choice, really. The group I work with has a bunch of XML files, where each element had a whole slew of attributes, and no nested tags. Why? They figured if a value is the property of something, then it is an attribute. So you end up with a tag that has 6 or 7 attributes and looks really messy. Myself, I tend to use tags more liberally and rarely rely on attributes. I don't think there is a hard and fast rule of when to do one or the other. It probably is dependent more on the situation and what you are doing with the XML. In your case, it may make sense. In a different situation, putting location as a tag may be more feasible.