Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Which one is better...

Reply
Thread Tools

Which one is better...

 
 
mathieu
Guest
Posts: n/a
 
      12-12-2007
'lo there !

I am a complete newbie in XML and I am pretty sure my question does
not make a lot of sense but here it goes anwyay.

Are there any real differences in between:

<entry group="0000" element="0850" vr="US" vm="1" retired="true"
version="2">
<name>Number of Matches</name>
</entry>

and

<entry group="0000" element="0850" vr="US" vm="1" retired="true"
version="2" name="Number of Matches"/>


I picked the first solution since 'name' could potentially contains
non-ASCII characters, double quotes or single quote. It is garantee
that there is at most one 'name' per 'entry'. name can sometimes be
unknown. name is typically a very short string, so does this still
make sense to put it in the character data ?

Thanks for comments
-Mathieu
 
Reply With Quote
 
 
 
 
Philippe Poulard
Guest
Posts: n/a
 
      12-12-2007
mathieu a écrit :
> 'lo there !
>
> I am a complete newbie in XML and I am pretty sure my question does
> not make a lot of sense but here it goes anwyay.
>
> Are there any real differences in between:
>
> <entry group="0000" element="0850" vr="US" vm="1" retired="true"
> version="2">
> <name>Number of Matches</name>
> </entry>
>
> and
>
> <entry group="0000" element="0850" vr="US" vm="1" retired="true"
> version="2" name="Number of Matches"/>
>
>
> I picked the first solution since 'name' could potentially contains
> non-ASCII characters,


this is irrelevant since XML relies on Unicode

double quotes or single quote.

quotes can be escaped ; the more often, strings that contains single
quotes are double-quoted, and strings that contains double quotes are
single-quoted ; strings that contain both must escape those used as
delimiter ; however if the content of your attribute is created by a
tool (XML editor, database extraction or whatever) this is a syntax
consideration that should be transparent

It is garantee
> that there is at most one 'name' per 'entry'. name can sometimes be
> unknown. name is typically a very short string, so does this still
> make sense to put it in the character data ?


yes, if you decide it ; but IMHO, an attribute is suitable to your case

you could also consider this one :
<entry group="0000" element="0850" vr="US" vm="1" retired="true"
version="2">Number of Matches</entry>

>
> Thanks for comments
> -Mathieu



--
Cordialement,

///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
-----------------------------
http://reflex.gforge.inria.fr/
Have the RefleX !
 
Reply With Quote
 
 
 
 
Joseph Kesselman
Guest
Posts: n/a
 
      12-12-2007
If you websearch for "elements versus attributes", you'll find a lot of
discussion of this.

Attributes have some characteristics that may surprise you, such as
whitespace normalization. They also (obviously) don't allow the value to
contain further XML structure, which may be an issue in the future
depending on how your XML design evolves. Obviously, only one instance
of an attribute can appear on a single element. Attribute order is
explicitly not meaningful (and may not be preserved) in XML, which may
matter to you in some cases.

The general rule of thumb is to use attributes for simple values which
describe how the element is to be interpreted, and use elements for
anything else. But this is very much a judgement call, and a matter of
taste. So the right answer may be to ask other people who are familiar
with your data structures which way of thinking about the value makes
more sense to them, and/or to look at how others have constructed
similar XML data structures, until you develop a sense of style.


--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Microcontrollers: which one ? which language ? which compiler ? The Jesus of Suburbia NZ Computing 2 02-11-2006 06:53 PM
Which one is the correct one.... ? Jonathan Smith ASP .Net 3 12-11-2004 01:36 AM
Samsung SCD6040 - Anyone have one, used one, or have reviews on one? g wills Digital Photography 0 09-08-2004 08:06 PM
CSS aligning two things on one line with one left and one right news.frontiernet.net HTML 6 04-16-2004 02:44 AM
Using One XSLT and multiple XML Problem (One is XML and another one is XBRL) loveNUNO XML 2 11-20-2003 06:47 AM



Advertisments