Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Is this really xml-standard?

Reply
Thread Tools

Is this really xml-standard?

 
 
Gert Mellak
Guest
Posts: n/a
 
      09-10-2004
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.
 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?J=FCrgen_Kahrs?=
Guest
Posts: n/a
 
      09-10-2004
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 ?
 
Reply With Quote
 
 
 
 
Gert Mellak
Guest
Posts: n/a
 
      09-10-2004
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!
 
Reply With Quote
 
Gert Mellak
Guest
Posts: n/a
 
      09-10-2004
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!
 
Reply With Quote
 
Marrow
Guest
Posts: n/a
 
      09-10-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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.



 
Reply With Quote
 
=?ISO-8859-1?Q?J=FCrgen_Kahrs?=
Guest
Posts: n/a
 
      09-10-2004
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.
 
Reply With Quote
 
Peter Flynn
Guest
Posts: n/a
 
      09-11-2004
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_
 
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
really interesting... or really dull. (depends on your attitude) TrevorBoydSmith@gmail.com Java 2 09-01-2006 04:38 PM
OT : But help really really needed re: Domain Name selling, hosting etc. problem nc HTML 1 02-03-2005 07:24 PM
REALLY REALLY WERID PROBLEM!!!!pls take a look Amir ASP .Net 3 01-23-2004 06:01 PM
really really mysterious IE6 problem--secure site ultraviolet353 Computer Support 7 11-22-2003 07:56 PM
MR. ED REALLY, REALLY LOVES THE D60 !!! Annika1980 Digital Photography 9 10-28-2003 04:53 PM



Advertisments