• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using attributes or elements???

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd go for (2)
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Everyone is a villain in someone else's story. Especially this devious tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic