Grouping of elements?

Discussion in 'XML' started by howa, Sep 16, 2007.

  1. howa

    howa Guest

    The following show two examples, which one is better you think?

    <report>
    <minScore></minScore>
    <maxScore></maxScore>

    .... other stuffs
    </report>

    or

    <report>
    <score>
    <maxScore></maxScore>
    <minScore></minScore>
    </score>
    ...
    </report>
     
    howa, Sep 16, 2007
    #1
    1. Advertising

  2. howa

    Peter Flynn Guest

    howa wrote:
    > The following show two examples, which one is better you think?
    >
    > <report>
    > <minScore></minScore>
    > <maxScore></maxScore>
    >
    > ... other stuffs
    > </report>
    >
    > or
    >
    > <report>
    > <score>
    > <maxScore></maxScore>
    > <minScore></minScore>
    > </score>
    > ...
    > </report>


    If the scores are textual, then the redundancy is unnecessary:

    <report>
    <scores>
    <min></min>
    <max></max>
    </scores>
    ....
    </report>

    If the scores are numeric or categorical, attributes are more common:

    <report>
    <score min="34" max="57"/>
    ....
    </report>

    ///Peter
     
    Peter Flynn, Sep 16, 2007
    #2
    1. Advertising

  3. As with other data structures, this depends on how you're going to use
    the data now and in the future. If you will eventually be making "score"
    more complicated, having it be a separate element may make sense. If min
    and max score are really just part of the report, the extra level of
    hierarchy may not make sense.

    Why do you want the <score> element? If you can't explain that (to
    yourself), you probably don't want it.

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
     
    Joe Kesselman, Sep 17, 2007
    #3
  4. howa

    howa Guest

    Hello all,

    One of my concern is: If I parse the XML into DOM, will attribute or
    new element using more memory at runtime?


    On 9 17 , 8 12 , Joe Kesselman <> wrote:
    > As with other data structures, this depends on how you're going to use
    > the data now and in the future. If you will eventually be making "score"
    > more complicated, having it be a separate element may make sense. If min
    > and max score are really just part of the report, the extra level of
    > hierarchy may not make sense.
    >
    > Why do you want the <score> element? If you can't explain that (to
    > yourself), you probably don't want it.
    >
    > --
    > () ASCII Ribbon Campaign | Joe Kesselman
    > /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
     
    howa, Sep 17, 2007
    #4
  5. howa

    George Bina Guest

    Elements will occupy more memory than attributes.

    Best Regards,
    George
    ---------------------------------------------------------------------
    George Cristian Bina - http://aboutxml.blogspot.com/
    <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
    http://www.oxygenxml.com
     
    George Bina, Sep 17, 2007
    #5
  6. George Bina wrote:
    > Elements will occupy more memory than attributes.


    Probably, BUT the proper answer depends on ****EXACTLY**** which
    implementation of the DOM you're using.

    Remember that the DOM is only an interface, and very carefully leaves
    the question of back-end storage open; the actual document storage model
    may not be a DOM and may not even be object-based, which makes
    generalizing about memory usage difficult.

    If this matters to you, you may want to pick your implementation
    specifically by how it manages storage.

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
     
    Joseph Kesselman, Sep 17, 2007
    #6
  7. howa

    howa Guest

    Maybe it will be better if

    <report maxScore="34" maxScore="57">

    ....

    ?

    Personally, I don't like empty element with attributes.

    Or is it the common way to do in this way?

    Thanks.
    >
    > If the scores are numeric or categorical, attributes are more common:
    >
    > <report>
    > <score min="34" max="57"/>
    > ...
    > </report>
    >
    > ///Peter
     
    howa, Sep 17, 2007
    #7
  8. howa wrote:
    > <report maxScore="34" maxScore="57">


    That would be my own inclination.

    > Personally, I don't like empty element with attributes.


    As I said: The question is how much structure you think you might add in
    the future. Attributes can't have XML substructure, so if things
    eventually get more complicated you will have to either add more
    attributes, more children, or a more complicated syntax for your
    attribute values.

    Very much a matter of taste and style. Do whatever makes most sense for
    the markup language you're working with and the applications that will
    manipulate it.

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
     
    Joseph Kesselman, Sep 17, 2007
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kcwolle
    Replies:
    0
    Views:
    376
    kcwolle
    Nov 27, 2003
  2. Dimitre Novatchev

    .Re: Grouping neighboring elements with xsl

    Dimitre Novatchev, Nov 28, 2003, in forum: XML
    Replies:
    0
    Views:
    481
    Dimitre Novatchev
    Nov 28, 2003
  3. Jody Greening
    Replies:
    5
    Views:
    682
    Jody Greening
    Jan 6, 2005
  4. Jody Greening
    Replies:
    0
    Views:
    340
    Jody Greening
    Jan 6, 2005
  5. grouping elements

    , Apr 15, 2008, in forum: XML
    Replies:
    1
    Views:
    376
    Martin Honnen
    Apr 15, 2008
Loading...

Share This Page