comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <sb463ba@l1-hrz.uni-duisburg.de>
Subject: Re: Microsoft & Ada (and also a remark on DTDs prohibiting
Date: Mon, 13 Sep 2004 19:16:23 +0000 (UTC)
Date: 2004-09-13T19:16:23+00:00	[thread overview]
Message-ID: <ci4rm7$9k2$1@a1-hrz.uni-duisburg.de> (raw)
In-Reply-To: mailman.23.1095082667.390.comp.lang.ada@ada-france.org

Robert C. Leif <rleif@rleif.com> wrote:
:   DTDs have a horrible syntax.

Care to elaborate?

: XML schema can be constructed to have
: essentially a one-to-one correspondence to Ada.

In essence, Schema definitions can be more specific about a mapping of XML
text to a subset of record types, enums, and some string types, if you
neglect Unicode (how many Characters do you need for a 64 character Unicode
String in Ada?).  More advanced XML element types (for example recursive
XML element types) are not that easily mapped to Ada records.

: Readability and strong
: typing are very useful characteristics for software engineering.

Right.  Which is why I prefer a clear Content Model notation, which
in case of DTDs is based on well established ways of writing regular
grammars.  (Using: () for grouping, | for alternatives, * for any,
+ for at least one. Is there any Schema author who doesn't know these?)

Paraphrasing definitions from you Schema files, consider


<!ELEMENT
	 Reactive_Functionality_Name    (#PCDATA) >

<!ATTLIST
	 Reactive_Functionality_Name

   Reactive_Functionality_Num
	(Unfuctionalized | mono | di | tri)       #REQUIRED
>


This DTD definition looses the information given in the Schema that the
element content must be a normalized string (IOW, a normalized attribute
value...) of at least 64 Unicode characters, as per your definition
of Bd_64_Type.  (Is "Unfuctionalized" a typo?)

But are these declarations written in a horrible syntax?
I can see no significant difference of the above enumeration from

  type Reactive_Functionality_Num is
        (Unfuctionalized , mono , di , tri);

On the whole I think what you have tried is to map some internal
data representation 1:1 onto an external XML Schema. Good idea?

:  Most of the data types are NOT numeric.

(OK, let me call them punch card data, as in fact there are also names
and hex numbers separated by ',', and more. Nothing wrong with punch
cards, if they matter.)

: My Ada code employs the same data-types and names as
: the XML schema.

Can this be a mistake? I think there are situations where this is
a mistake. It misses an opportunity to abstract from the bounds
of the machines. Make a "logical" format. For example, one of your
Schema types specifies

  hex-num-of-four-digits COMMA hex-num-of-four-digits .

via

  [0-9a-fA-F]{4},[0-9a-fA-F]{4}.

Doesn't this lend itself well to a definition that names the two
hex numbers? Like in

  <Complex  re="0.0" im="-1.0"/>

These are still Ada names, but it should be obvious what is meant
even if you do not know Ada.

"Pattern matching is not parsing." (SNOBOL4 saying.)


regards,
-- Georg



      reply	other threads:[~2004-09-13 19:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-13 13:37 Microsoft & Ada (and also a remark on DTDs prohibiting Robert C. Leif
2004-09-13 19:16 ` Georg Bauhaus [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox