aspose file tools*
The moose likes XML and Related Technologies and the fly likes Parameter vs Tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Parameter vs Tag" Watch "Parameter vs Tag" New topic
Author

Parameter vs Tag

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parameter vs Tag