RE: [xml] Ordering of TAGS and data



Please pardon the libxml list discussion, because I felt that the library
kept things ordered as they were ordered in the file.  This makes sense to
me and from a parsing standpoint.  I wanted to be certain I understood the
underlying design of the library and the XML fundamentals it was designed to
parse.

I see your point of the <second> and <first> tags below as well as Staffan's
comments on the attribute ordering or lack thereof.  I understand this to
mean that the file may come to the libxml interface with sections and
attributes in random order.  When libxml reads the tags and attributes, it
will place them in the tree in the order they occurred in the original XML
data file.  The data within each <first> </first> should remain as placed in
the XML file.

This is good because it means I should be able to validate that a <first>
and <second> sections have been filled with data once the <tuple> has ended
via the </tuple>.  At that point, it does not matter which order the <first>
and <second> sections of data have been entered, only that they have been
parsed correctly and that any data they reference were defined previously in
the file.

This should allow the use of libxml to parse the entire document creating
the tree and then traverse the tree "in order" partially filling out data
structures along the way, close off the libxml library and then finally
traverse the linked list data structures to back fill the links.

What I am hearing is that I do not need to have the "seq" attribute below on
each data element because the second example should be parse in file order
and thus can be added to a linked list in order.  The <data> would always be
listed in first to last order in our examples.

<tuple>
<data seq="1"> xxxxx  xxxxx  xxxxx  xxxxx </data>
<data seq="2"> xxxxx  xxxxx  xxxxx  xxxxx </data>
<data seq="3"> xxxxx  xxxxx  xxxxx  xxxxx </data>
<data seq="4"> xxxxx  xxxxx  xxxxx  xxxxx </data>
</tuple>

<tuple>
<data> xxxxx  xxxxx  xxxxx  xxxxx </data>
<data> xxxxx  xxxxx  xxxxx  xxxxx </data>
<data> xxxxx  xxxxx  xxxxx  xxxxx </data>
<data> xxxxx  xxxxx  xxxxx  xxxxx </data>
</tuple>

On the other hand, if we wanted to allow the <data> elements to be ordered
but randomly entered into the data file, then the "seq" attribute would be
required which could be parsed from libxml as the <data> attribute and then
assigned to the list in the correct order.

Please pardon my confusion, your expertise with XML and libxml has been most
helpful.

Respectfully,

Dr. Paul Robert Hayes
The CEMTACH Group
paulroberthayes earthlink net

-----Original Message-----
From: xml-admin gnome org [mailto:xml-admin gnome org]On Behalf Of Morus
Walter
Sent: Monday, November 24, 2003 10:48 AM
To: xml gnome org
Subject: Re: [xml] Ordering of TAGS and data

Paul Robert Hayes writes:
There has been discussion here of ordering of tags and data within an XML
file.  From what I have seen, the TAGS (beginning and ending <> sections)
appear to be ordered when read through Internet Explorer and Konqueror as
well as libxml.  Several people have noted that there is no guarantee of
the
ordering, though.  To me this does not make sense from a parsing
standpoint
because the data within a <> section was created by the user and shouldn't
be reordered by the viewer.  Does this stir anyone's memory of XML
ordering?

Of course it is ordered.

Wouldn't be helpfull, if an document consisting of a number of p (HTML) or
para (docbook) elements, could be randomly reodered ;-)

OTOH it depends on the definition of an xml application, to what extend
order is meaningfull and defined.
Eg. the xml serialisiation of a set of number tuples might look like
<set>
<tuple><first>1</first><second>1</second></tuple>
<tuple><second>3</second><first>3</first></tuple>
<tuple><first>2</first><second>2</second></tuple>
</set>
where neither the order of the first, second subelement is defined by
the application (that is, you must be able to process any order) nor
the order of the tuples has any meaning.

But for a given xml instance the order is always the same as in the textual
representation.

I don't think that this is related to libxml though.
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]