Ada & XML Similarities & Harmonization Robert C. Leif, Ph.D. Vice President R&D Newport Instruments [email protected] www.newportinstruments.com Newport Instruments copyright © 2002 Introduction to XML • eXtensible Markup Language –

Download Report

Transcript Ada & XML Similarities & Harmonization Robert C. Leif, Ph.D. Vice President R&D Newport Instruments [email protected] www.newportinstruments.com Newport Instruments copyright © 2002 Introduction to XML • eXtensible Markup Language –

Slide 1

Ada & XML
Similarities & Harmonization
Robert C. Leif, Ph.D.
Vice President R&D
Newport Instruments
[email protected]
www.newportinstruments.com
Newport Instruments copyright © 2002


Slide 2

Introduction to XML
• eXtensible Markup Language
– Document (file) that describes data
– Allows sharing of data by providing a
common standard, extensible way to
interpret that data.

Newport Instruments copyright © 2002


Slide 3

W3C Goals (Requirements) for XML
• XML shall be straightforwardly usable over
the Internet.
• XML shall support a wide variety of
applications.
• XML shall be compatible with SGML.
• It shall be easy to write programs which
process XML documents.
• The number of optional features in XML is
to be kept to the absolute, minimum,
ideally zero.
Newport Instruments copyright © 2002


Slide 4

• XML documents should be human-legible
and reasonably clear.
• The XML design should be prepared
quickly.
• The design of XML shall be formal and
concise.
• XML documents shall be easy to create.
• Terseness in XML markup is of minimal
importance.

Newport Instruments copyright © 2002


Slide 5

Schema Element



targetNamespace="file://C:\SIGAda\2002\
XML\Person_Name.xsd"
xmlns="http://www.w3.org/2001/XMLSche
ma"
xmlns:per_nam="file://C:\SIGAda\2001\XM
L\Person_Name.xsd"
elementFormDefault="unqualified"
attributeFormDefault="unqualified">
Newport Instruments copyright © 2002


Slide 6

Person Name






Newport Instruments copyright © 2002


Slide 7

name="Person_Name_Type">

type="per_nam:Given_Name_Type"/>
type="per_nam:Middle_Name_Type"/>
type="per_nam:Family_Name_Type"/>


Newport Instruments copyright © 2002


Slide 8














Newport Instruments copyright © 2002


Slide 9

name="Person_Name_W_Generation_Type">

"per_nam:Person_Name_Type">

type="per_nam_gen:Generation_Type"
minOccurs="0"/>




Newport Instruments copyright © 2002


Slide 10

Money with a range of $5.00 to $2,000.










Newport Instruments copyright © 2002


Slide 11

Harmonization of Data types
• Bounded Strings

• Numbers

Newport Instruments copyright © 2002


Slide 12

Create XML Strings by Addition of fields to
Bounded_String


Encapsulated in generic packages,
Ada.Strings.Bounded. & Wide_Bounded
• Solution:
1. Create a generic that instantiates Ada.Strings.
Bounded with a generic type.
2. Add a Character_Set_Type etc. to a private
tagged type.
3. Add a Modified version of all of the methods in
Ada.Strings.Bounded
Newport Instruments copyright © 2002


Slide 13

How to Create a Character Set
Latin_1_Range : constant
Str_Maps.Character_Range :=
(Low => Latin_1.Null,
High => Latin_1.Lc_Y_Diaeresis);
Latin_1_Char_Set : Character_Set_Type :=
Str_Maps.To_Set (Span => Latin_1_Range);

Newport Instruments copyright © 2002


Slide 14

XML Bounded Strings with Character Sets
with Ada.Strings.Bounded;

with Ada.Strings;
with Character_Sets;

with Pattern_Pkg;
generic
Max_Bd_Length : Positive;
Character_Set :
Character_Sets.Character_Set_Type

:= Character_Sets.Latin_1_Char_Set;
Newport Instruments copyright © 2002


Slide 15

Min_Bd_Length : Positive
:= Min_Bd_Length; ---1
Pattern
: Pattern_Bd_Type
Null_Pattern_Bd;

:=

Newport Instruments copyright © 2002


Slide 16

Generic Instantiation
package Generic_Bd_W_Char_Sets is
……………………………
package Generic_Bd_Strings is new
Ada.Strings.Bounded.Generic_Bounded_Length
(Max => Max_Bd_Length);

Newport Instruments copyright © 2002


Slide 17

private
type Generic_Bd_W_Char_Set_Type is tagged
record
Generic_Bd_Part : Generic_Bd_Type :=
Null_Generic_Bd;
Character_Set_Part : Character_Set_Type :=
Character_Set;
--This permits the Character_Set to be
--specified at instantiation and defaults to
--Latin_1
Min_Bd_Length_Part : Positive
:= 1;
Pattern_Part
: Pattern_Bd_Type :=
Null_Pattern_Bd;
end record;
Newport Instruments copyright © 2002


Slide 18

Problem
• XML is based on Unicode
– UTF-8,
– UTF-16,
– UTF-32
Solution
Ada.Strings.Unbounded, Ada.Strings.Bounded
Ada.Strings.Maps & Ada.Characters.Handling
need to have added 32 bit versions.
Translation between 8, 16 and 32 bit types
Briot’s XML/Ada does not easily interface with
bounded strings.
Newport Instruments copyright © 2002


Slide 19

Newport Instruments copyright © 2002


Slide 20

ECMA Types
• http://www.ecma.ch/
• Originally, European Computer Manufacturers
Association
• Now, ECMA International - European association
for standardizing information and communication
systems.

Newport Instruments copyright © 2002


Slide 21

Real Types are Primitive
XML
Type
float
double

Source
IEEE singleprecision 32-bit
IEEE double-precision 64bit

ECMA
float32
float64

*decimal W3C
decimal
*Minimum of 18 Digits. Pentium uses
double extended precision floating
point registers. PowerPC uses floating
point registers for fixed-point.
Newport Instruments copyright © 2002


Slide 22

Integer Types are Derived
Type & Derivation
Sequence

ECMA

*integer

MinInclusive

MaxInclusive

-infinity

infinity

nonPositiveInteger

0

negativeInteger

-1

long

Int64

-2**63

(2**63) -1

int

Int32

-2**31

(2**31) -1

short

Int16
SByte
Int8

-2**15

(2**15) -1

-2**7

(2**7)-1

byte

*Derived From decimal;
fractionDigits·=
0
Newport Instruments
copyright © 2002


Slide 23

Integer Types Cont.
Type &
Derivation
Sequence
*nonNegativeInt
eger
unsignedLong
unsignedInt
unsignedShort
unsignedByte

ECMA

UInt64
UInt32
UInt16
Byte
UInt8

positiveInteger

Min
Max
Inclusive Inclusive
0 infinity
0 2**64-1
0 2**32-1
0 2**16-1
0 2**8-1
1 infinity

*Derived from Integer
Newport Instruments copyright © 2002


Slide 24

XML 32 bit Integer Equivalent







Newport Instruments copyright © 2002


Slide 25

Ada Int32 Type & Subtypes

subtype Int32 is Integer;
--or
type Int32 is range -2**31..2**31-1;
for Int32'SIZE use 32;
subtype Natural_32 is Int32
range 0..Int32'Last;
subtype Positive_32 is Int32
range 1..Int32'Last;
Newport Instruments copyright © 2002


Slide 26

XML Time & Date Types
XML
Type

duration

XML Description & Format
is a six-dimensional space
where the coordinates
designate the Gregorian
year, month, day, hour,
minute, and second
components respectively.
These components are
ordered in their significance
by their order of appearance
i.e. as year, month, day,
hour, minute, and second.
Newport Instruments copyright © 2002

Type &
Standard

defined
in §
5.5.3.2
of [ISO
8601],


Slide 27

XML Core Languages

• Extensible Markup Language (XML)
– Schema Definition Language (XSDL)
– Extensible Stylesheet Language (XSL)
– Scalable Vector Graphics (SVG)
– XSL Transformations (XSLT)
– XML Path Language (XPath)
– XML Linking Language (XLink)
– XML Forms (XForms)

Newport Instruments copyright © 2002


Slide 28

XSL Includes:
• Screen objects which scroll
• Page objects, which can be printed;
• Blocks with various formatting properties
including those representing different
levels of titles (some including autonumbering) and paragraphs (including
indented block quote paragraphs);
• External graphics;
• Tables.
Newport Instruments copyright © 2002


Slide 29

• Bulleted and enumerated lists including
nested lists;
• Generated table of contents including
leaders and generated page numbers;
• Running headers and footers including
use of markers;
• Multiple page layouts, folio formats;
• Page master alternation, various in-line
font changes
• Hyphenation and justification and various
combinations of display spacing
Newport Instruments copyright © 2002


Slide 30

XSLT Number Formatting
• Like Ada uses a picture string
• However is described separately from the
data.

Newport Instruments copyright © 2002


Slide 31


type="xsl:char" use="optional"
default="."/>
type="xsl:char" use="optional"
default=","/>
use="optional" default="Infinity"/>
use="optional" default="-"/>
name="NaN" type="string" use="optional"
default="NaN"/>
Newport Instruments copyright © 2002


Slide 32

use="optional" default="%"/>
use="optional" default="‰"/>
use="optional" default="0"/>
use="optional" default="#"/>
type="xsl:char" use="optional" default=";"/>
Newport Instruments copyright © 2002


Slide 33

XForms
• is a means for display, inputting,
submitting and uploading data, without
describing how the data will be presented.

• includes event handlers such as setFocus,
message, and setValue.
• can: associate a schema datatype with a
field, restrict a value from changing by
declaring it read-only, require that a value
exists before the data is submitted.
Newport Instruments copyright © 2002


Slide 34

XForms (Continued)
• can indicate that a field is the result of a
calculation performed on other data and can
describe the conditions required for the data to
be considered valid.

• Includes user Interface controls, such as: text
boxes including multiline content , secret boxes,
buttons, and selection from multiple choices.
• Interacts with a stylesheet for display of radio
buttons, checkboxes, menus, and listboxes.

Newport Instruments copyright © 2002


Slide 35

Form Layouts
A graphical browser might render form control
selectMany as any of the following:

listbox

checkbox

radio

This configuration is
not recommended.

Newport Instruments copyright © 2002

menu


Slide 36

XML & Ada have in common:
• Separation of the declaration of public
data types from their use or display;
• Begins and ends;
• Strong typing including range checking;
• Single inheritance;
• Visibility control by the use of prefixes;
• Maximization of readability over
programmer effort;
• Conformance Test Suites.
Newport Instruments copyright © 2002


Slide 37

XML (Packages)
• Mathematical Markup Language (MathML)

Newport Instruments copyright © 2002


Slide 38

•The maximization of a symbiotic relationship
between XML and Ada requires the establishment
of a formal liaison between SIGAda and the World
Wide Web Consortium.
•Harmonization of XML and Ada

How is Ada to be called from a web page?
Attribute (J code, compiled, or script)

Newport Instruments copyright © 2002


Slide 39

Both Groups Could Learn from Each
other
• XSL, XSLT & SVG would benefit from
the services of an experience Ada
language designer.
• Conversely, Ada presentation and GUI
software should adopt as much of their
formatting and design from XML
technologies.

Newport Instruments copyright © 2002


Slide 40

XML Demolition of Ada Marketing
Fallacies
• Need to minimize the number of reserved
words.
• Verbosity impedes adoption.
• A language needs to be simple.
• C syntax is required for a large market.
• Small companies can not succeed. Altova,
XMLSpy doing well.
• Shelve space is an absolute necessity for
sales. XMLSpy sold over the Internet
Newport Instruments copyright © 2002


Slide 41








The XML Cover Pages,
By Robin Cover (MLs)
Markup Language for Complex
Documents (Bergen MLCD Project)
US Patent and Trademark Office
Electronic Filing System
BSML, schema for NCBI (National Center
for Biotechnology Information) data model.
Microarray Gene Expression Markup
Language (MAGE-ML)
CytometryML
www.newportinstruments.com
Newport Instruments copyright © 2002


Slide 42

Suggested Web Sites & Readings
General Principles of Software Validation; Final Guidance
for Industry and FDA Staff, January 11, 2002,
www.fda.gov/cdrh/comp/guidance/938.html
Guidance for FDA Reviewers and Industry, May 29, 1998,
www.fda.gov/cdrh/ode/software.pdf
N. G. Leveson"Safeware, System Safety and Computers",
Addison-Wesley, Reading, MA pp. 412-413, 1995.
XML and related languages: Worldwide Web Consortium
www.w3.org
P. Walmsley, “Definitive XML Schema”, ISBN 0-13-0655678, Prentice Hall www.phptr.com
Character Model for the World Wide Web 1.0 W3C Working
Draft 30 April 2002
www.w3.org/TR/charmod/
Newport Instruments copyright © 2002


Slide 43

Direct Internet Message Encapsulation (DIME)
http://www.ietf.org/internet-drafts/draft-nielsen-dime02.txt
FormsPlayer from x-port.net http://www.formsplayer.com/
Scalable Vector Graphics (SVG)
http://www.w3.org/Graphics/SVG/Overview.htm8
The Extensible Stylesheet Language (XSL)
http://www.w3.org/Style/XSL/
K. Whistler, M. Davis „Unicode Technical Report #17,
Character Encoding Model”;
http://www.unicode.org/unicode/reports/tr17/
E. Briot XML/Ada: a full XML suite: The Ada95 XML Library,
Version 0.5 Date: 2001/10/30 15:01:17 http://libre.acteurope.fr/xmlada/main.html
R. C. Leif, SIGAda 2001 Workshop, “Creating a Symbiotic
Relationship Between XML and Ada” Ada Letters Vol.
XXII, pp 24-41 (2002).
Newport Instruments copyright © 2002