Is this really xml-standard?

Discussion in 'XML' started by Gert Mellak, Sep 10, 2004.

  1. Gert Mellak

    Gert Mellak Guest

    Hi!

    I'm writing an online-shop that receives data-updates about the
    company's products as xml-files. I'm not sure about the Group-Tags -
    is this really xml-standard?? They should represent the article-groups
    I have to use in my online shop. Here's the file:

    <Data>
    <Article>
    <Number>3746</Number>
    <Description>This is the article description</Description>
    <Group>
    Group 1
    <Group>
    Group 2
    <Group>
    Group 3
    <Group>
    Group 4
    </Group>
    </Group>
    </Group>
    </Group>
    </Article>
    </Data>

    Thank you for your help!

    Greetings,
    Gert.
     
    Gert Mellak, Sep 10, 2004
    #1
    1. Advertising

  2. Gert Mellak wrote:

    > I'm writing an online-shop that receives data-updates about the
    > company's products as xml-files. I'm not sure about the Group-Tags -
    > is this really xml-standard?? They should represent the article-groups
    > I have to use in my online shop. Here's the file:


    xmllint reports no error with your example data.

    I would be interested to know why you use XML files
    for storing your data ? What is the advantage ?
    Or is it just that the word XML sounds so nice ?
     
    =?ISO-8859-1?Q?J=FCrgen_Kahrs?=, Sep 10, 2004
    #2
    1. Advertising

  3. Gert Mellak

    Gert Mellak Guest

    I'm developing an online shop and the agreed strategy is that I get the
    data out of the company's database stored within xml-files. I think it's
    not a bad idea since finally the data-structures will be quite complex
    and there are many hierarchical structures...

    greetings,
    Gert.

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Gert Mellak, Sep 10, 2004
    #3
  4. Gert Mellak

    Gert Mellak Guest

    xml was the suggested method from the company's adminstrator. I take the
    files and import the data into my database.

    We thought about using ini-files or csv at first, but since the data
    will get quite complex with many hierarchical structures we decided to
    transmit it within xml-files.

    What would you have used instead?

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Gert Mellak, Sep 10, 2004
    #4
  5. Gert Mellak

    Marrow Guest

    Hi Gert,

    Not sure what you mean by "is this really xml-standard??" - so long as an
    XML document is well-formed then it meets the 'standard' in that in complies
    with the W3 specs and will be able to be read by a parser.

    As to whether the structure if your XML is the best idea - this depends
    really on what you are doing. But at first glance, the structure you have
    where <Group> elements are nested within each other looks a little odd...
    you have (tidied)...

    <?xml version="1.0"?>
    <Data>
    <Article>
    <Number>3746</Number>
    <Description>This is the article description</Description>
    <Group>Group 1
    <Group>Group 2
    <Group>Group 3
    <Group>Group 4</Group>
    </Group>
    </Group>
    </Group>
    </Article>
    </Data>

    So to get at the list of <Group>'s for a given article may prove a little
    tricky - and probably more difficult than it needs be. By nesting them in
    this way you are also mixing text nodes (i.e. the text "Goup 1") with child
    elements - although this is permissable in XML most people try to avoid
    doing it unless it is neccessary.

    So perhaps you should consider a structure more like...

    <?xml version="1.0"?>
    <Data>
    <Article>
    <Number>3746</Number>
    <Description>This is the article description</Description>
    <Group>Group 1</Group>
    <Group>Group 2</Group>
    <Group>Group 3</Group>
    <Group>Group 4</Group>
    </Article>
    </Data>

    And it is sometimes recommened that repeating elements are nested within a
    holder element (which often makes defining a Schema/DTD a little easier and
    can also have performance advantages when querying the document), e.g.

    <?xml version="1.0"?>
    <Data>
    <Article>
    <Number>3746</Number>
    <Description>This is the article description</Description>
    <Groups>
    <Group>Group 1</Group>
    <Group>Group 2</Group>
    <Group>Group 3</Group>
    <Group>Group 4</Group>
    </Groups>
    </Article>
    </Data>


    HTH
    Marrow
    http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
    http://www.topxml.com/Xselerator


    "Gert Mellak" <> wrote in message
    news:...
    > Hi!
    >
    > I'm writing an online-shop that receives data-updates about the
    > company's products as xml-files. I'm not sure about the Group-Tags -
    > is this really xml-standard?? They should represent the article-groups
    > I have to use in my online shop. Here's the file:
    >
    > <Data>
    > <Article>
    > <Number>3746</Number>
    > <Description>This is the article description</Description>
    > <Group>
    > Group 1
    > <Group>
    > Group 2
    > <Group>
    > Group 3
    > <Group>
    > Group 4
    > </Group>
    > </Group>
    > </Group>
    > </Group>
    > </Article>
    > </Data>
    >
    > Thank you for your help!
    >
    > Greetings,
    > Gert.
     
    Marrow, Sep 10, 2004
    #5
  6. Gert Mellak wrote:

    > xml was the suggested method from the company's adminstrator. I take the
    > files and import the data into my database.


    External needs seem acceptable to me.
    Especially because conventions about content
    are usually established in the form of DTDs
    or Schemata.

    > We thought about using ini-files or csv at first, but since the data
    > will get quite complex with many hierarchical structures we decided to
    > transmit it within xml-files.


    You seem to have the infrastructure for supporting
    conventions like DTDs.

    > What would you have used instead?


    Depends on what one is doing. CSV works in many cases
    if the problem is not too complex. My impression (and
    the reason for asking) is that many people start using
    XML without knowing the consequences of this decision.
    If you work in an environment where the infrastructure
    is established, then XML seems OK.

    I have seen examples where a single developer started
    "inventing" ad hoc structures for simple configuration
    files. Such people ignored to write and support proper
    DTDs and really did not care about other people who
    have to read or write such configuration files. As a
    consequence, handling these configuration files has
    become really painful.
     
    =?ISO-8859-1?Q?J=FCrgen_Kahrs?=, Sep 10, 2004
    #6
  7. Gert Mellak

    Peter Flynn Guest

    Gert Mellak wrote:

    > Hi!
    >
    > I'm writing an online-shop that receives data-updates about the
    > company's products as xml-files. I'm not sure about the Group-Tags -
    > is this really xml-standard?? They should represent the article-groups
    > I have to use in my online shop. Here's the file:
    >
    > <Data>
    > <Article>
    > <Number>3746</Number>
    > <Description>This is the article description</Description>
    > <Group>
    > Group 1
    > <Group>
    > Group 2
    > <Group>
    > Group 3
    > <Group>
    > Group 4
    > </Group>
    > </Group>
    > </Group>
    > </Group>
    > </Article>
    > </Data>


    It's fine, and enclosing all the elements belonging to one article is
    exactly the right way to do it.

    However, I'm not clear what the Group elements achieve all nested like
    that, with character data and further Group elements mixed into them.
    It's normally regarded as very poor design for data-oriented applications.
    I am guessing that the Group data should almost certainly NOT be nested
    unless it really does have some hierarchical meaning.

    If you mean that Article 3746 belongs to Groups 1, 2, 3, and 4, you might
    consider:

    <Article Number="3746">
    <Description>This is the article description</Description>
    <Group N="1"/>
    <Group N="2"/>
    <Group N="3"/>
    <Group N="4"/>
    </Article>

    If the Group data really is hierarchical, then add an element within each
    Group element to hold the text: do NOT intermingle text and elements (keep
    that style for textual applications like books where mixed content has its
    real value):

    <Article Number="3746">
    <Description>This is the article description</Description>
    <Group N="1">
    <Description>Group 1 text</Description>
    <Group N="2">
    <Description>Group 2 text</Description>
    <Group N="3">
    <Description>Group 3 text</Description>
    <Group N="4">
    <Description>Group 1 text</Description>
    </Group>
    </Group>
    </Group>
    </Group>
    </Article>

    That lets you add more elements after the group description before the
    start of a subgroup if that becomes necessary.

    The choice between attributes and elements is the subject of a lot of
    argument, but I recommend using attributes for numeric and categorical
    data, and keeping character data content for text. But others may well
    disagree with this: it's your choice.

    ///Peter
    --
    "The cat in the box is both a wave and a particle"
    -- Terry Pratchett, introducing quantum physics in _The Authentic Cat_
     
    Peter Flynn, Sep 12, 2004
    #7
    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. Amir
    Replies:
    3
    Views:
    621
  2. nc
    Replies:
    1
    Views:
    527
    nice.guy.nige
    Feb 3, 2005
  3. Replies:
    2
    Views:
    365
  4. Jeannie
    Replies:
    15
    Views:
    914
    Jeannie
    Aug 30, 2005
  5. =?Utf-8?B?TFc=?=
    Replies:
    8
    Views:
    442
    =?Utf-8?B?TFc=?=
    Apr 25, 2007
Loading...

Share This Page