[Foomatic] DTDs: first try

Johannes Meixner jsmeix at suse.de
Fri Jan 16 08:23:14 PST 2004


Hello,

first of all I would like to point out that introducing
DTDs does not mean any change for any existing software.

For example when a XML file is invalid according to the DTD
this does not mean that it is invalid for the existing
Foomatic parsers (*).

But introducing DTDs means that we can agree on a syntax
which we would like to have for a perfect XML file.

For example we may agree that a perfect XML file should
have a particular ordering of the elements or that
all existing elements must always be present (but can
contain no data).

Then I could make the approriate DTD and by using
XSL transformations I could transform the existing
XML files to become perfect XML files.

Also third party software developers can use the DTD
and if they like they can change their software to
produce perfect XML files.
Because of (*) they are not forced to do it.


On Jan 15 17:47 Grant Taylor wrote (shortened):
> Johannes Meixner <jsmeix at suse.de> writes:
> 
> > I added the following stand-alone DTDs to the CVS:
> 
> Interesting to see a schema definition for our goofy ad-hoc
> xml ;)

Please have in mind that there exist also "XML Schema"
which is different from DTD - see for example
http://www.w3.org/2001/XMLSchema


> Curious, other parsers typically have this mechanism.  There is not
> {foo|bar}+, for example?

Unfortunately no.

> > As far as I know it is not possible (with reasonable effort)
> > to specify in the DTD that there can be several different elements
> > in arbitrary order but each element can exist at most once.
> 
> I guess the DTD syntax is a holdover from when it was only a document
> class description for SGML.  With XML SGMLish text streams are now
> used to represent arbitrary bundles of data, and the DTD syntax is not
> so nice a fit.

Yes.
 
> Is there an XML-specific schema declaration language?  Perhaps it
> doesn't have this problem.

I could investigate in "XML Schema" but I think we schould
not use them.

Reason:
At the momnet XML Schema is not such a worldwide well known
standard as DTD.
With a DTD everybody on the world would know how to use them
(regardless of the operating system and so on).
This way any software developer and/or any printer manufacturer
would know how to use the DTD and how to create XML file which
are valid according to the DTD.


> > Multiple usage of the same element name with different meaning:
> 
> That's probably fine.  Calling one "left" and another "left" different
> lefts allows the parser to distinguish between them despite the fact
> that the distinguishing is not useful.  It's just a bit that
> applications will throw away...

I am sorry but I don't understand what you mean.

It is a real problem that at the moment there are elements
which are used with different syntax depending on the context.

As far as I understand the XML stuff it is in contradiction
to the XML design ideas and therefore it should be corrected.



> However, we
> shouldn't run around changing things just to make the DTD easier; for
> all I know the world is full of third party foomatic-data reading
> implementations.

Of course not.
My intention was not to make the DTD easier.
The DTD can be as complicated as we like.
My intention was only to inform you about possible enhancements.

The third party foomatic-data dependent stuff is the main
reason for a good DTD.

When we have a good DTD the third party software developer
can use it to make sure their software is in compliance to
the foomatic-data specification.



I would like to replace in printer.dtd the loose definition:

<!ELEMENT printer (make,model,
  (mechanism|url|lang|autodetect|functionality|driver
   |unverified|contrib_url|buyit|comments)+)>

with a strict definition like:

<!ELEMENT printer (make,model,
   mechanism?,url?,lang?,autodetect?,functionality?,driver?,
   unverified?,contrib_url?,buyit?,comments?)>

to make sure that each sub-element can appear at most once.

With the list there are many printer XML files which are
no longer valid because the elements are in different order.

But this is no real problem because I can use XSL transformation
to rearrange the existing elements so that they are in
the right order according to the DTD.


But I guess that I cannot solve the problem that elements
are used with different syntax in different context by
automated XSL transformations.



Regards
Johannes Meixner
-- 
SUSE LINUX AG, Maxfeldstrasse 5                 Mail: jsmeix at suse.de
90409 Nuernberg, Germany                    WWW: http://www.suse.de/




More information about the Printing-foomatic mailing list