52
SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy Manual and W3C documents. Ada_Med, a Division of Newport Instruments 5648 Toyon Road, San Diego, CA 92115- 1022, USA E-mail [email protected] www.newportinstruments.com www.Ada-Med.com +1 (619)582-0437

SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

Embed Size (px)

Citation preview

Page 1: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada”

30 September, 2001

Robert C. Leif with unsolicited help from the XML Spy Manual and W3C documents.

Ada_Med, a Division of Newport Instruments

5648 Toyon Road, San Diego, CA 92115-1022, USA

E-mail [email protected]

www.newportinstruments.com

www.Ada-Med.com

+1 (619)582-0437

Page 2: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

Workshop Purpose

• To organize the Ada community to take advantage of this opportunity.

• This requires creating applications in Ada that use and support XML;

• and using XML to create Ada environments including XML based tools.

Page 3: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

PC Software Development Eras:

• DOS (IBM => Microsoft) Text

• Windows (Microsoft) Graphics including GUI

• XML (World Wide Web Consortium and perhaps Microsoft) Internet

• SGML (Standard Generalized Markup Language)--Too much & too early

• HTML (Hypertext Markup Language--Too little

• XML (Extensible Markup Language) --Just right

Page 4: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

• XML is driven by the exploding use of the Internet and the economic advantage of having the same software operate on both the client and server.

• The historic Ada was a gambler. Her namesake, the computer language, has just had her luck change very much for the better.

• The commercial use of the Internet is the driving force behind XML. Fortunately, the programming language that has the best fit with XML is Ada.

Page 5: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

W3C Goals for XML

• 1. XML shall be straightforwardly usable over the Internet.

• 2. XML shall support a wide variety of applications.

• 3. XML shall be compatible with SGML.

• 4. It shall be easy to write programs which process XML documents.

• 5. The number of optional features in XML is to be kept to the absolute, minimum, ideally zero.

Page 6: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

W3C Goals for XML Continued.

• 6. XML documents should be human-legible and reasonably clear.

• 7. The XML design should be prepared quickly.

• 8. The design of XML shall be formal and concise.

• 9. XML documents shall be easy to create.

• 10. Terseness in XML markup is of minimal importance.

Page 7: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

The XML Standards Puzzle

• DTDThe "Document Type Definition" is a part of the

original XML 1.0 specification that allows a developer, or standards body, to specify what elements and attributes may be used in a particular type of XML document and what their structure and nesting may be. This is also called the content model or schema of an XML document.

If an XML document conforms with the content model defined by a DTD, it is said to be valid with respect to that DTD.

Page 8: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

• XML SchemaThe "XML Schema" is an ongoing effort by the

W3C to supplant DTDs with a more flexible and powerful system to describe the structure of conforming XML documents, including provisions for defining data types including ranges and inheritance.

Page 9: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

XML Schema Part 2: Datatypes, Section 2 Type System

[Definition:] In this specification, a datatype is a 3-tuple, consisting of

a) a set of distinct values, called its ·valuespace,

• Integers, strings, enumerated, boolean, etc.b) a set of lexical representations, called its

·lexical space·, and c) a set of ·facets that characterize properties of

the ·value space·, individual values or lexical items.

• Ranges, Formatting, Default values

Page 10: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

Facets

• A fundamental facet is an abstract property which serves to semantically characterize the values in a ·value space·.

• 4.2.1 equal

• 4.2.2 ordered {false, partial, total}.

• 4.2.3 bounded

• 4.2.4 cardinality

• 4.2.5 numeric

Page 11: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

Ordered

Partial

• for no a in the ·value space·, a < a (irreflexivity)

• for all a and b in the ·value space·, a < b implies not(b < a) (asymmetry)

• for all a, b and c in the ·value space·, a < b and b < c implies a < c (transitivity)

Total =Partial +

• for all a and b in the ·value space·, either a < b or b < a or a = b

Page 12: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

Derived by restriction(Subtypes or NewNew Types)

• ·derived· by restriction from another datatype when values for zero or more ·constraining facets are specified that serve to constrain its ·value space· and/or its ·lexical space· to a subset of those of its ·base type·.

Page 13: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

Bounded String

<simpleType name="Title_Type"><restriction base="string">

<minLength value="1"/><maxLength value="100"/>

</restriction></simpleType>

<element name="Title" type="Title_Type"/>

Page 14: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

Integer Type with Range

<simpleType name="Day_of_Year_Num_Type"><restriction base="integer">

<minInclusive value="1"/><maxInclusive value="366"/>

</restriction></simpleType>

<element name="Day_of_Year_Num" type="Day_of_Year_Num_Type"/>

Page 15: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

OO in XMLv1.xsd:

<complexType name="personName">

<sequence>

<element name="title" minOccurs="0"/>

<element name="forename" minOccurs="0"

maxOccurs="unbounded"/> </sequence>

</complexType>

<element name="addressee" type="personName"/>

Page 16: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

v2.xsd:

<redefine schemaLocation="v1.xsd">

<complexType name="personName">

<complexContent>

<extension base="personName">

<sequence>

<element name="generation" minOccurs="0"/>

</sequence>

</extension>

</complexContent>

</complexType>

</redefine>

Page 17: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

<element name="author" type="personName"/>

v2.xsd has everything specified by v1.xsd, with the personName type extended by the addition of the generation element.

Equivalent of a tagged type in Ada

Page 18: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy
Page 19: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

XML Types

Page 20: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy
Page 21: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

A Schema describes what one or more XML documents can contain by defining:

–The elements and types the document contains, and the order in which they appear

–The element content (type), and element attributes if any

The purpose of a schema is to allow machine validation of document structure. Instead of using the syntax of XML 1.0 DTD declarations, schema definitions use XML element syntax.

A correct XML schema definition is, therefore, a well-formed XML document.

Page 22: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

• XSL & XSLTThe "eXtensible Stylesheet Language

Transformation" is a very powerful programming language that allows XML documents to be displayed, transformed from one schema to another or into entirely different forms, such as HTML pages, WML cards, or PDF files.

• CSSCascading Style Sheets are a popular way to

control the appearance of HTML documents and can be used with XML.

Page 23: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

• XPathThe "XML Path Language" is a language for

addressing and querying the content of XML documents.

• XLinkThe "XML Linking Language" describes

hyperlinking in XML documents and extends the hyperlinking concepts of HTML.

• XPointerThe "XML Pointer Language" is a companion

standard to Xlink and describes mechanisms for addressing particular parts of a document.

Page 24: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

• SVGScalable Vector Graphics. SVG is an XML

application used to describe 2D vector graphics, text and raster images. This enables vector graphics to be defined solely in XML. SVG is well designed, complete, and powerful. Unfortunately, it is based on a DTD.

• VMLVector Markup Language is a Microsoft creation,

which is well designed and based on a schema.

Page 25: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

DTD’s

• DTDs (Document Type Definitions) have their own arcane syntax (inherited from SGML).– DTDs should be made obsolete– Do not appear to have strong typing– Should use Schemas instead– DTDs can be incomplete and not permit

translation into a schema.

Page 26: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

XML

Specification Formating

Schema DTD XSL CSS

XML Choices

Page 27: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

XML, Schema, & XSL Roles

• XML is the data

• Schemas are the specifications of types and objects

• XSL describes how the output of the data should look and how (XSLT) it should be translated; it is some what equivalent to any Ada body..

Page 28: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

Similarity of Schemas to Ada Specifications

• Schemas are XML documents.– {Ada’s specifications & bodies have the same

syntax.}

• XML has visibility and scoping rules

• XML has strong typing and subtyping

• XML has single inheritance similar to Ada

Page 29: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

XML Schema Style Issues

<?xml version="1.0" encoding="UTF-8"?>

<!-- edited with XML Spy v4.0 beta 3.1 build Aug 27 2001 (http://www.xmlspy.com) by Robert Cary Leif (Newport Instruments, all rights reserved) -->

• UTF-8 or ISO-8859-1?

Page 30: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

Visibility in XML

• XML documents include schemas.

• Including a schema makes it visible and does the equivalent of an Ada with and an Ada renames.– Starting with the root schema

<schema xmlns:xs=“http://www.w3.org/1999/XMLSchema”

– This is the equivalent of With Ada;

Page 31: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

With & Use

Xmls:A=“http://www.ada-xml.org/namespace”

targetNamespace=“http://www.ada-xml.org/namespace”

ElementFormDefault=qualified”

attributeFormDefault=qualified”>

Page 32: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

<schema targetNamespace="http://NewportInstruments.com/Name_And_Address" xmlns:nam_add="http://NewportInstruments.com/Name_And_Address"

xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" attributeFormDefault="unqualified">

<element name="Name_and_Address">

<annotation>

<documentation>Person name and Address to be used as part of other schemas and to be mirrored by an equivalent Ada package(s) 2001 Sep 18

</documentation>

</annotation>

</element>

</schema>

Page 33: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

<?xml version="1.0" encoding="UTF-8"?><xs:schema

targetNamespace="http://NewportInstruments.com/Name_And_Address" xmlns="http://NewportInstruments.com/Name_And_Address" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" attributeFormDefault="unqualified"><xs:element name="Name_And_Address">

<xs:annotation><xs:documentation>Person name and Address to be

used as part of other schemas and to be mirrored by an equivalent Ada package(s) 2001 Sep 18

</xs:documentation></xs:annotation>

</xs:element></xs:schema>

Page 34: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

Prefixes

xmlns:nam_add="http://NewportInstruments.com/Name_And_Address"

xmlns=http://www.w3.org/2001/XMLSchema

xmlns=http://NewportInstruments.com/Name_And_Address

xmlns:xs=http://www.w3.org/2001/XMLSchema

• Only one name-space can have a null string as a prefix.

• Root schema for XML or the one under design?

Page 35: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

XSL

• Candidate Recommendation

• Extremely Powerful Together with SVG could build Microsoft

Office

• Needs true “What you see is what you get.”

• Needs to be defined by a schema

Page 36: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

Tables & XSL

• Procedural like HTML

• Object Oriented.

Page 37: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

Procedural

<TD>

<CENTER><B>On/Before<BR>4&nbsp;Sep</B>

<CENTER></CENTER></CENTER>

</TD>

<TD>

<CENTER><B>After<BR>4&nbsp;Sep</B></CENTER>

</TD>

<TD>

<CENTER><B>On/Before<BR>4&nbsp;Sep</B>

<CENTER></CENTER></CENTER>

</TD>

Page 38: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

<TD>

<CENTER><B>After<BR>4&nbsp;Sep</B>

</CENTER>

</TD>

<TD>

<CENTER><B>On/Before<BR>4&nbsp;Sep</B>

<CENTER></CENTER></CENTER>

</TD>

Page 39: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

From Extensible Stylesheet Language (XSL)Version 1.0, 6.7. Formatting Objects for Tables

Page 40: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

Object Oriented<?xml version="1.0" encoding="UTF-8"?><Schema …/><doc>

<fo:table width="12cm" table-layout="fixed"> <fo:table-column column-number="1“

column-width="proportional-column-width(1)">

</fo:table-column> <fo:table-column column-number="2“

column-width="proportional-column-width(2)+2pc">

</fo:table-column> <fo:table-column column-number="3“

column-width="72pt"> </fo:table-column>

Page 41: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

<fo:table-body>

<fo:table-row>

<fo:table-cell column-number="1"

display-align="top">

<fo:block>Cell 1</fo:block>

</fo:table-cell>

<fo:table-cell column-number="2"

display-align="center" text-align="center">

<fo:block>Cell 2</fo:block>

</fo:table-cell>

Page 42: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

<fo:table-cell column-number="3“

text-align="center">

<fo:block>Cell 3</fo:block>

</fo:table-cell>

</fo:table-row>

</fo:table-body>

</fo:table>

</doc>

Page 43: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

9.1 Conditional Processing with xsl:if

The following colors every other table row yellow:

<xsl:template match="item"><tr>

<xsl:if test="position() mod 2 = 0"> <xsl:attribute name="bgcolor“

>yellow</xsl:attribute> </xsl:if> <xsl:apply-templates/>

</tr> </xsl:template>

Page 44: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

9.2 Conditional Processing with xsl:choose

The following example enumerates items in an ordered list using arabic numerals, letters, or roman numerals depending on the depth to which the ordered lists are nested.

<xsl:template match="orderedlist/listitem"> <fo:list-item indent-start='2pi'>

<fo:list-item-label>

<xsl:variable name="level" select="count(ancestor::orderedlist)

mod 3"/>

Page 45: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

<xsl:choose>

<xsl:when test='$level=1'>

<xsl:number format="i"/> </xsl:when>

<xsl:when test='$level=2'>

<xsl:number format="a"/> </xsl:when>

<xsl:otherwise>

<xsl:number format="1"/>

</xsl:otherwise>

</xsl:choose>

Page 46: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

<xsl:text>. </xsl:text>

</fo:list-item-label>

<fo:list-item-body>

<xsl:apply-templates/>

</fo:list-item-body>

</fo:list-item>

</xsl:template>

Page 47: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

In order to create the necessary applications in Ada that use and support XML:

• The present existing Ada software for XML should be described.

• A higher level design should be developed for the future packages required for the symbiosis (mutually beneficial relationship) of Ada and XML.

• This could initially include following packages: XML.Schema.Datatypes, XML.MathML (mathematics markup), and XML.SVG (Scalable Vector Graphics).

Page 48: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

• Automated translation of the Ada data types & objects in a specification to an XML Schema.– ASIS application

• Automated translation of the data types & elements in a XML Schema to an Ada specification.

Page 49: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

•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.

-How is Ada to be called from a web page?

-Attribute (J code, compiled, or script)

•XSL & XSLT 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.

Page 50: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

XML Demolition of Ada Marketing Fallacies

• Need to minimize the number of reserved words

• Verbosity impedes sales

• A language needs to be simple

• C syntax is required for a large market.

• Small companies can not succeed.

• Shelve space is an absolute necessity for sales.

Page 51: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

Postscript on Operating Systems

• XML, Schemas, XSL(T), etc can be used in a document centric system.

• OLE, COM, etc. can to a large part be replaced by withing schemas for use in one XML document which could contain:

• Text, Intelligent Tables (Spreadsheets), Images, and Graphs.

• The XSLT processor could inherit from the Scalable Vector Graphics.

• An Ada XML equivalent of a MHT (Web archive single) file needs to be created.

Page 52: SIGAda 2001 Workshop, “Creating a Symbiotic Relationship Between XML and Ada” 30 September, 2001 Robert C. Leif with unsolicited help from the XML Spy

• The database that controls the files should also be suitable for the creation of these files.

One of the first steps in development is the elimination of unnecessary requirements.

Less is often better.

Compared with Microsoft et al., it should be much better and cheaper.