473,396 Members | 1,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

container elements for repeating elements ('element farms') needed?

my question is: do we need container elements for
repeating elements in data-centric xml documents? or is
it for some reason very advisable to introduce
containers in xml documents even where not strictly
needed? how can a recommendation on this in the light of
existing tools like w3c xml schema and relaxng as well
es established practice be answered? i would greatly
appreciate any words, pointers, and links.

the exposition of the problem has become a rather long
one, done partly to make the matter clear to myself, and
most people will probably not have to read all of it.

to ease the discussion, let me introduce a very simple
data schema, one that describes library with books,
employees, and readers. it looks like this:

#================================================= ====
library
address
*book
*employee
*reader

book
*author
title
isbn

author extends person

employee extends person

reader extends person
card-id

person
name
last
first
#================================================= ====

the star is to be read in the usual way as 'zero or more
instances of'. i believe the above structure, where
repeating elements are introduced without explicit
container elements, to be sufficient and extensible: in
case i plan to describe individual employees in more
detail, i can always amend the schema of <employee>
(which presently only holds first and last name) and
leave the schema of the <library> element untouched. (i
also believe that mixed content and order between
elements should be eschewed in most data-centric xml, so
i do not make an effort to express mixed content or
order between sibling elements in the above.)

now, there are people who do not agree with this kind of
schema (let's call it the implicit model) and insist on
container elements for repeatables. this means we have
to explicitly introduce <books>, <employees>, and
<readers>, so the library schema will look like this:

#================================================= ====
library
books
employees
readers

books
*book

employees
*employee

readers
*reader

book
authors
title
isbn

authors
*author

author extends person

employee extends person

reader extends person
card-id

person
name
last
first
#================================================= ====

the argument, if i understand correctly, goes that in
case i want to change the structure of a cointained
element, then only in the explicit model i can do so by
redefining e.g. <employee> (and perhaps <employees>),
but not the <library> element. it is also claimed that i
will only then be able to use typing and have employees
as an entity that i can change later on, and have it
changed in all the places it appears. third, it is
claimed that for reasons of object-oriented mapping,
container elements are desirable.

i would like to dub explicit container elements 'element
farms' (think of server farms -- many of the same
bundled) for short, and call the above set of claims the
'element farm constraint', which in essence says that
you should introduce a container element (a farm)
whenever you allow the repetition of elements in data-
centric xml.

now, the second argument is obviously correct in so far
as i can *only* in the explicit model modify an element
<employees> and have that change propagate everywhere,
for the simple reason there is no such element in the
implicit model. the question is, why should i want to do
such a thing? i think it is a design decision whether or
not a given entity or set of entities is modelled
explicitly or not. i do not have <books>, <readers>, or
<employees> in the implicit model since i have nothing
to say about these groups in general, only about each
individual. this could be different: for example, at
some point we discover that all readers are subject to a
same fee, and have a maximum of books to take out of the
library. then, the set of readers becomes more tangible,
and i will have to change the implicit model like this:

#================================================= ====
library
address
*book
*employee
readers

readers
fee
maximum-number-of-books
*reader

reader extends person
card-id
#================================================= ====

this is in fact a change in the model that did not so
automatically percolate through all tiers -- i had to
modify my definition of <library>. so what? new facts
are in town, and we make space for them. we did not
build a complete, all-embracing, all-extensible data
model with the first shot, but who ever will? sure the
explicit model would have made it easier, but it is also
somewhat bulkier. second, what do you do when you find
you have something new to say about the library itself?
you will have to change the <library> element, in both
models. but third and devastatingly, we are faced, in
both models, with the situation that not all repeated
elements are covered by container elements -- the
readers element, above, has two more children. that's
allright for the implicit model, but in order to satisfy
the element farm constraint, we must introduce one more
container <xxx>, like so:

#================================================= ====
readers
fee
maximum-number-of-books
xxx

xxx
*reader
#================================================= ====

at this juncture, it becomes clear that

* explicit containers for repeated elements will under
* the element farm constraint never be true useful
* entities in the sense of data modelling, since they
* are never allowed to hold any data pertaining to
* them per se.

by the way, i do not see a very strict reason why not to
add an element <readers> but not necessarily make it the
container for the <reader> elements -- sounds strange?
well:

#================================================= ====
library
address
*book
*employee
*reader
readers

readers
fee
maximum-number-of-books

reader extends person
card-id

#================================================= ====

this structure allows you to query for a collective
'readers' and to scan for individual instances of
'reader' -- in a way the collective is independent of
its members, since we can still say that there is a fee
to pay and a maximum number of books to take home even
with zero readers.

lastly, it is possible to model employees and readers
alike as sets of generic persons. in that case, we must
have both collective elements:

#================================================= ====
library
...
employees
readers

employees
*person

readers
*person

#================================================= ====

however, since it is easy to subclass and quite
foreseeable that employees and readers do differ from
generic persons in the eyes of a library's data
administration, this approach is perhaps not very much
to be recommended.

sorry again for the longish mail,

_wolfgang lipp
w.lipp at bgbm dot org
Jul 20 '05 #1
1 2195
In article <f1**************************@posting.google.com >,
Wolfgang Lipp <w.****@bgbm.org> wrote:

% my question is: do we need container elements for
% repeating elements in data-centric xml documents?

You can often get away with it, but you may find it limits you in
unexpected ways. For instance, if you wanted to move the lists of
employees and readers from your example to external documents, then you
must have a containing element for each of them. If you wanted to
include those documents as external parsed entities, then your library
schema must allow for the containing element.

There are certainly cases where people have elected to leave off
containers and it's made it more difficult to process the data. If your
book element didn't exist, and you just had a list of titles, authors,
and isbns, the data could still be unambiguous, but more complicated.
I'm inclined to think that it's not worth spending the effort to decide
whether any given container is an example of one that might not be
useful, and to put it in if it represents some identifiable entity
(the library's collection and its subscriber base can each be thought
of as distinct entities).
--

Patrick TJ McPhee
East York Canada
pt**@interlog.com
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: kazio | last post by:
Hello, So, I need to have double linked, circular list (last element point to the first one and first one points to the last one). I thought maybe I could use list container from STL, but...
0
by: Wolfgang Lipp | last post by:
my question is: do we need container elements for repeating elements in data-centric xml documents? or is it for some reason very advisable to introduce containers in xml documents even where not...
8
by: Wolfgang Lipp | last post by:
<annotation> the first eleven contributions in this thread started as an off-list email discussion; i have posted them here with the consent of their authors. -- _w.lipp </annotation> From:...
2
by: Ney André de Mello Zunino | last post by:
Hello. The issue is quite known: you have a block-level container holding a set of floated elements and you need that the container's content height take the floated elements' dimensions into...
32
by: Severin Ecker | last post by:
hi! normally i would simply do the following: std::vector<Element> vec; void somefunc() { Element e; vec.push_back(e); }
19
by: Nafai | last post by:
Hi I want to write a function which erases al the repeated elements in a range. How should be the prototype? template <class Iterator> void eraseRepeated(Iterator begin, Iterator end); ...
2
by: nickheppleston | last post by:
I'm trying to iterate through repeating elements to extract data using libxml2 but I'm having zero luck - any help would be appreciated. My XML source is similar to the following - I'm trying to...
4
by: Daniel Marques | last post by:
I would like to know how to get the address of a container of the STL without using iterators. I have a class with three STL lists and a index which points to an element of any ot the other lists,...
18
by: Goran | last post by:
Hi @ all! Again one small question due to my shakiness of what to use... What is better / smarter? private: vector<MyClass_t* itsVector; OR...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.