Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using attributes or elements???

 
Yell Srik
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i have a doubt in XML. using HTML/Java script forms, i have created a graphical interface using which the user is allowed to choose jpeg images(maps), text files etc; ie from a set of jpeg images, text files etc, the user can choose any one. i am planning to use XML for data exchange. i plan to develop a XML file that contains the user's choices. a JSP page on the server end interprets this XML file and extracts the data.
how can i represent the files in as XML tags:
is this representation right:
(1) <userselection id1="D:\mydocuments\us.jpg"> USA </userselection>
(or)
(2) <userselection>
<map id="1">D:\Webmapping\kerala\keralabw.jpg</map>
</userselection>
in (1), i plan to include all the images and text files as attributes whereas in (2), these are stored as elements.
can u suggest which of the two representations is better or is there a better way of using XML?
thanks in advance.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd go for (2)
 
Kartik Shah
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any specific reason to go for option 2 in this case ?
This seems to part of bigger debate that is going on...
When is an attribute attribute ?
Elements or attributes ?

XML Syntax Recommendation for Serializing Graphs of Data
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using "id1" as the attribute name implies that there will be id2, id3, id4, etc. which would be horrible for the obvious reasons -- one of them being that it's practically impossible to describe this with DTD or XSD.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic