[XML-SIG] A bit off topic: XML advice needed...

Betty Harvey betty@eccnet.eccnet.com
Wed, 3 Mar 1999 08:34:25 -0500 (EST)

Hi Stuart:

	Your question touches on a very important question in
XML about when you use element and when to you attributes.
As you are experiencing, it is not always a 'cut and dry'

	My rule of thumb which usually works out to be 90%
reliable is if the information is going to be displayed use
an element.  However, there are nuances and exceptions which
you have found.

	I can't solve the question you have below but maybe
I can give you some practical advice and have you answer
some questions about the application:

1.  Will people be creating the start-date and end-date?

    If the answer is yes, you may want to think about
    creating the elements <start-date> and <end-date>.
    You can control the input from the user better by
    creating explicit elements.

    An exception to the above though is if you are going
    to be supplying a static form-based application for
    the end-user to complete.  If this is the case, the
    form can supply the input rules and the application
    can perform the mark-up.

2.  Will the application create the dates?

    If dates are going to be created by the application
    without 'the person in-the-loop', I would tend to
    make the 'start' and 'end' as attributes of the
    element.  The application itself can ensure that
    the required information is available to provide
    proper tagging.

When you are creating your DTD, every situation tends to be
a little different and it requires some analysis of the
processes that will be involved in the final application.

Hope this helps.


Betty Harvey                           | Phone: 301-540-8251 FAX: 4268
Electronic Commerce Connection, Inc.   | 
13017 Wisteria Drive, P.O. Box 333     | 
Germantown, Md.  20874                 |
harvey@eccnet.eccnet.com               | Washington,DC SGML/XML Users Grp
URL:  http://www.eccnet.com            | http://www.eccnet.com/sgmlug/

On Wed, 3 Mar 1999, Stuart Hungerford wrote:

> Hi all,
> This is the text of a message I posted earlier to 
> comp.text.xml.  Since the people on this list are 
> such nice folks, I thought I'd ask your opinions
> too.
> I apologize in advance for an off-topic posting,
> but good from-the-trenches XML advice is hard 
> to find.
> -------------------------------------------------------------
> I have a question about designing XML DTD's that I suspect 
> shows me trying to think of XML too much like a programming
> language, and not enough like a markup language.
> Anyways, suppose I have a DTD that describes elements for
> dates, and in particular the <date> element. Now suppose I 
> want to re-use my <date> element definition in a DTD for
> marking up "events".  Each event has a start date and end
> date. (Please forgive any terminology errors here).
> My first mental reaction (in a sort of pseudocode is):
>      class date
>      {
>          ...
>      };
>      class event
>      {
>          start_date : date;
>          end_date : date;
>      };
> But how to express the XML equivalent?  One way would be:
>     Use an external ENTITY to textually include the date.dtd in
>     events.dtd and define
>             <!ELEMENT event (start-date, end-date)>
>             <!ELEMENT start-date (date)>
>             <!ELEMENT end-date (date)>
>     That way I get self-documenting names for the date elements, 
>     but at the cost of another level of markup needed for each date 
>     in all my XML documents that use events.dtd.
> I could also:
>     Use an external ENTITY to textually include the date.dtd in
>     events.dtd and define:
>             <!ELEMENT event (date, date)>
>             <!ATTLIST date role (start | end) #REQUIRED>
>     That way I can create markup like:
>           <event> <date role="start">...</date> ... </event>
>      But now I have to check in an application whether there's
>      exactly one start and end etc--I seem to have given up some
>      validity checking benefits for a level of markup tags.
> There's probably lots of other ways to do this--the question is,
> which are the "good" ways, where "good" in my case means 
> I can re-use existing definitions and still come out with a 
> DTD and documents that are not too hard to understand.
> I guess I'm looking for the gang-of-four patterns book for
> XML, but in the meantime can anyone share their wisdom 
> and experiences on this issue?
> _______________________________________________
> XML-SIG maillist  -  XML-SIG@python.org
> http://www.python.org/mailman/listinfo/xml-sig