Presentation is loading. Please wait.

Presentation is loading. Please wait.

Feb 2001C.Watters1 Grammars, SGML, & XML Agreeing on the rules.

Similar presentations


Presentation on theme: "Feb 2001C.Watters1 Grammars, SGML, & XML Agreeing on the rules."— Presentation transcript:

1

2 Feb 2001C.Watters1 Grammars, SGML, & XML Agreeing on the rules

3 Feb 2001C.Watters2 Overview What is a grammar BNF notation Regular expressions Context free grammars (remember Chomsky) SGML HTML XML (finally) and the DTD

4 Feb 2001C.Watters3 What is a Grammar? A grammar is a set of rules which can generate a construct from a list of terminals determine if a construct obeys the rules (i.e. is well formed) Example - English construct is a sentence terminals are words

5 Feb 2001C.Watters4 Simple Grammar Sentence::= Subject Verb Subject::=(Pnoun | (def noun)) Pnoun::=(Joe | Mary) Verb::=(runs | sits) def::=(the | a | an) noun::=(boy | girl)

6 Feb 2001C.Watters5 Syntax not Semantics Let’s expand definition of noun terminals Noun::=(car | hat | TV) no problem with syntax! Hat running a little vague. They are flying planes. No problem with syntax. Semantics not so clear

7 Feb 2001C.Watters6 What is a grammar for anyway? 1. Parse Input Examines input and determines if it satisfies the rules of a given grammar  Joe Mary.  If(a<3){jump}  my page 2. Generate output Use the rules to generate well-formed entities  Joe runs.  If(a < 3){b=a}  my page

8 Feb 2001C.Watters7 BNF Backus Naur (or Normal) Form Notation for describing syntax of a language John Backus and Peter Naur, 1960’s for ALGOL Meta-symbols used ::= LHS is defined by RHS | or category name (defined somewhere else) Example ::= begin end;

9 Feb 2001C.Watters8 Useful extensions to BNF Optional [else ] repetitive items { | } recursion is allowed ::= | brackets for grouping ( | )

10 Feb 2001C.Watters9 Regular Expressions Simple way to express languages or strings eg. One ‘a’ followed by (one ‘n’ followed by one ‘d’) or by one ‘t’ a((n d) | t) note: may use + instead of |

11 Feb 2001C.Watters10 Regular Expressions include Concatenation\sequence A B Selection A|B Kleene Closure (0 or more) A* Positive Closure(1 or more) A + Bounded Repetition(1 to i) A i eg. A(n*| t) = {A, An, Ann, …, At}

12 Feb 2001C.Watters11 Context-Free Grammars CFG is a set of recursive productions used to generate patterns of strings satisfying the construct of the language SGML and its subsets, HTML and XML are context-free grammars! CFG are more powerful than Regular Expressions

13 Feb 2001C.Watters12 SGML Standardized General Markup Language Developed by a committee! Led by Charles Goldfarb, 1978-1986 a grammar to define the structure of documents rules define the construct or structure terminals are and strings

14 Feb 2001C.Watters13 XML  DTDs  How to use it  Examples

15 Feb 2001C.Watters14 DTD - grammar definition for a document type Defines: element types (structure) attributes (terminals) constraints on combinations of these

16 Feb 2001C.Watters15 Element Type Declaration <!DOCTYPE GarageSale [ ]> today myhouse Rain or shine

17 Feb 2001C.Watters16 Sub-Elements  ? Means optional 1 or more 0 or more where Graphic etc are also defined as ELEMENTS

18 Feb 2001C.Watters17 Attributes Let you add extra information to elements CDATA=> character data

19 Feb 2001C.Watters18 Validating Parser A DTD (document type definition) defines the grammar of a type of document  memo  web page  book Validating Parser uses a DTD to check if a given document satisfies the rules of that grammar

20 Feb 2001C.Watters19 HTML & XML  HTML is a subset of SGML with a shared DTD  HTMLDOC::=( HEAD BODY )  XML is a subset of SGML with many DTD’s allowed “XML is like HTML with the training wheels off” -Dan Connolly, leader of XML activity at W3C

21 Feb 2001C.Watters20 XML Uses tags to identify semantics of data looks like HTML, but isn’t Introduction Carolyn Watters XML this and that is license free, platform-independent and well-supported

22 Feb 2001C.Watters21 HTML Hypertext Markup Language Hypertext Markup Language Presents documents via WWW browsers Document layout and hyperlink specifications Predefined set of tags (ie. Common DTD)

23 Feb 2001C.Watters22 Statistics Canada Welcome to Stats Canada Statistics Canada …….. We like numbers….. What we do Census Special surveys a href=“online.html”>Online data

24 Feb 2001C.Watters23 HTML HTML - Advantages Simple - fixed set of tags Portable - used with all browsers Linking - within and to external documents HTML - Disadvantages Limited tag set Can’t separate the definition from content Can’t define structure of contents

25 Feb 2001C.Watters24 XML XML allows anyone to define a document structure separate from its display structure Explicit Definition - DTD

26 Feb 2001C.Watters25 Some Code Schema Entity Passport Details SubEntities Last Name First Name Address Entity Address SubEntities Street City Town State Province ……..

27 Feb 2001C.Watters26 DTD

28 Feb 2001C.Watters27 Internal DTD and Instance <!DOCTYPE passport_details [ <!ELEMENT address (street,(city|town),(state|province),(ZIP|postal_code),country,contact_no?,email* )> ]> Smith Jo Stephen 1 Great Street GreatCity GreatState 1234 GreatLand jo@theworldaccordingtojo.com

29 Feb 2001C.Watters28 Shared DTD XML Document specifies the DTD Smith Jo Stephen 1 Great Street GreatCity GreatState 1234 GreatLand jo@theworldaccordingtojo.com

30 Feb 2001C.Watters29 Coordinating Heterogenous Databases Separation of Structure / Content / Display Document Validity Checking Potential Use in Standards Importance of XML

31 Feb 2001C.Watters30 Example Boeing Boeing places a DTD on its site part purchasers use this DTD Boeing can use multiple XSL stylesheets

32 Feb 2001C.Watters31 Boeing (cont’d) customer creates an order document, they can verify the validity of that document against the DTD. this ensures they are transmitting only type- valid orders. in turn, Boeing can ensure they are receiving only type-valid documents.

33 Feb 2001C.Watters32 2. Using XML: DOM & SAX  DOM: Document Object Model  The DOM is a standard object application programming interface that gives developers programmatic control of XML document content, structure, formats, and more.  DOM defines a programmatic API for accessing XML documents.

34 Feb 2001C.Watters33 3. Using XML: presenting data  Need to convert XML tags into appropriate HTML tags for use in a browser!!  Smith  Smith Smith

35 Feb 2001C.Watters34 Stylesheets are used to present XML: The Cascading Stylesheet Specification (CSS) The Extensible Style Language (XSL) CSSXSL Can be used with HTML?YesNo Can be used with XML?Yes Transformation language?NoYes SyntaxCSSXML

36 Feb 2001C.Watters35 CSS and XSL CSS - Cascading Style Sheets can predefined HTML display (font etc) these are shared and reused XSL - XML Style language predefine display characteristics for XML entities transform into CSS for browsers to use

37 Feb 2001C.Watters36 Cascading Style Sheets CSS last_name { font-family: verdana, arial; font-size: 15pt; font-weight:bold; display: block; margin-bottom: 5pt; } first_name { font-family: verdana, arial; font-size: 15pt; font-weight:bold; display: block; margin-bottom: 5pt; } street, city, town, state, province, ZIP, postal_code { font-family: verdana, arial; font-size: 12pt; font-weight:bold; color:green; display:block; margin-bottom: 20pt; margin-top: 40pt; } email { font-family: verdana, arial; font-size: 12pt; font-weight:bold; color:blue; display:block; margin-top: 5pt; }

38 Feb 2001C.Watters37 CSS Most local definition has precidence May be referred to (shared)

39 Feb 2001C.Watters38 <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns="http://www.w3.org/TR/REC-html40" result-ns=""> Address XSL (Style Language)

40 Feb 2001C.Watters39 Understanding A Template Most templates have the following form: The whole element is a template The match pattern determines where this template applies Literal result elements come from non-XSL namespace(s) XSLT elements come from the XSL namespace

41 Feb 2001C.Watters40 Options for displaying XML XML Document CSS Stylesheet CSS Stylesheet XSL Stylesheet XSL Stylesheet XML enabled Web Broswer XML enabled Web Broswer XML Display Engine XML Display Engine XSL Transformation spec HTML Document Web Broswer XSL Transformation

42 Feb 2001C.Watters41 2. Using XML: How does browser read XML ? XML parser: A tool for reading XML documents Microsoft's Internet Explorer 4.0 was the first Web browser to implement XML Netscape will support XML metadata in Communicator/Navigator 5.0 as a delivery component code-named Aurora.

43 Feb 2001C.Watters42 Desktop Middle - Tier Storage Display Multiple view created from the XML-base data Data Delivery, Manipulation: XML exchanged over HTTP manipulated via the DOM Data Integration XML emitted or generated from multiple source XML delivered to other applications or objects for further processing HTML view #1 (eg. Purchasing Agent) HTML view #2 (eg. Consumer) Web Server DB Access, Integration Business Rules (eg. Purchase order) Web Server DB Access, Integration Business Rules (eg. Purchase order) MainframeDatabase XML XML Architecture

44 Feb 2001C.Watters43 4. Case Study An example of XML Tree structure A simply example: Portfolio.xml Portfolio.xsl http://msdn.microsoft.com/xml/samples/review/review-xsl.xml

45 Feb 2001C.Watters44.. story address bookstore menu body review logo name phone date reviewer person summary person books office supplies.. Tree Structure of the example

46 Feb 2001C.Watters45

47 Feb 2001C.Watters46 In the major Web Browser products. In Microsoft Office 2000. In every major database tool by end of 2000. In every HTML tool by end of 2000. CommerceNet believes that XML may just be the “killer application” needed to open up the Worldwide Web for Electronic Commerce. Is this for real?

48 Feb 2001C.Watters47 XML - Advantages Platform and system independent User-defined tags Doesn’t require explicit DTD Display format and content are separate XML - Disadvantages Requires a processing application “Pickier” than HTML Must be converted to HTML to view in browser Summary

49 Feb 2001C.Watters48 W3 Consortium: www.w3.com kazillions of XML books in every bookstore! Resources

50 Feb 2001C.Watters49 6. Reference Jon Bosak and Tim Bray, Scientific American, May 1999 [http://www.sciam.com/1999/0599issue/0599bosak.html]http://www.sciam.com/1999/0599issue/0599bosak.html Norman Walsh: What is XML? Oct. 3, 1998 [http://xml.com/xml/pub/98/10/guide1.html#AEN58]http://xml.com/xml/pub/98/10/guide1.html#AEN58 Graphic Communications Association web site [http://www.gca.org/whats_xml/default.htm]http://www.gca.org/whats_xml/default.htm University College Cork [http://www.ucc.ie/xml/]http://www.ucc.ie/xml/ Microsoft MSDN online samples [http://msdn.microsoft.com/xml/samples/review/review-xsl.xml]http://msdn.microsoft.com/xml/samples/review/review-xsl.xml [http://www.oasis-open.org/cover/xsl.html]http://www.oasis-open.org/cover/xsl.html Charles F. Goldfarb, Paul Prescod, The XML Handbook, 1998


Download ppt "Feb 2001C.Watters1 Grammars, SGML, & XML Agreeing on the rules."

Similar presentations


Ads by Google