Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML eXtensible Markup Language by Darrell Payne. Experience Logicon / Sterling Federal C, C++, JavaScript/Jscript, Shell Script, Perl XML Training XML.

Similar presentations


Presentation on theme: "XML eXtensible Markup Language by Darrell Payne. Experience Logicon / Sterling Federal C, C++, JavaScript/Jscript, Shell Script, Perl XML Training XML."— Presentation transcript:

1 XML eXtensible Markup Language by Darrell Payne

2 Experience Logicon / Sterling Federal C, C++, JavaScript/Jscript, Shell Script, Perl XML Training XML Training Course 2001 DevXCon Training Conference Currently developing XML course for Logicon Darrell.Payne@Sterling-fsg.com

3 XML eXtensible Markup Language Standard General Markup Language(SGML) Meta-tag language Used for creating other markup languages Standard adopted for SGML in 1986 Hyper Text Markup Language(HTLM) Application of SGML Formatting Language eXtensible Markup Language(XML) Meta-tag language XML = DATA World Wide Web Consortium W 3 C ((!Standard) && (Specification)) // “c” code humor XML Version 1.0 February 1998 XML is not designed to replace HTML

4 SGML – HTML – XML diagram SGMLXML HTML application WML application

5 XML Family of Tools and Their Relationship Namespace SAX DOM XML Info set XML Schema XPath XSL XSLT XPointer XLink Style and Transformation Linking and Pointing Underlying And Object Model Programmatic Interface Complex Data Modeling XML Developer's Guide - McGraw Hill - Page 12

6 HTML vs. XML Html Predefined tags Syntax is loose File extensions usually “.html” of “.htm” Not required to be Well – Formed Some closing tags optional Attribute value quotes may be omitted XML User defined tags Syntax is exact File extensions usually “.xml” Closing tags mandatory Required to be Well - Formed

7 Well - Formed All XML documents must be Syntactically correct! Single root element All element start tags have end tags XML is case sensitive Properly nested tags //error //correct Attributes values in quotes “value“ or ‘value‘

8 Basic XML Parts Markup Tags Attributes, names and values Character Data Text PCDATA CDATA Binary XML document has two main sections Prolog Root Misc Optional and considered superfluous

9 Simple XML File Hello World! <!-- More Comments -->

10 Declaration If used: required Declaration optional Specifies version to which document conforms XML documents without XML declaration might be assumed to conform to the latest version Other declaration examples optional Default – Good for ASCII text – 8 bit characters “UTF-16” Good for foreign – 16 bit characters Used for Unicode characters To stay uniform use with 8 or 16 optional No external subset referenced – default

11 Comments <!-- More Comments --> XML uses same comment syntax as HTML

12 Root Element Lines preceding root element are contained in the Prolog All XML documents must contain only one root element All other elements are “child element”s

13 Child Element Hello World!

14 Sibling Element Hello World! Goodbye World! Nothing more to add!

15 Updating Microsoft’s Internet Explorer instmsia.exe Updates Microsoft’s Installer msxml3sp1.exe Updates Microsoft’s Internet Explorer IE now has built-in XML parser “msxml”

16 Create XML Document Include declaration Create root element Create child element Enter child element text “student name” Save file with “.xml” extension Open using Internet Explorer After success, add siblings elements and retest using Internet Explorer

17 Document viewed in Microsoft's Internet Explorer

18 More about Elements Element types Container Element Contains other elements Data Element Contains DATA Mixed Content Contains other elements and DATA Empty Element Contains no elements or DATA

19 Container Element Contains other elements Some text way down here in the center of it all

20 Data Element Contains DATA Parsable Character Data PCDATA Character Data CDATA

21 PCDATA Contains text Can be parsed by parser Can contain all text except < > “ ‘ &

22 Entity References XML provides built in entity references < > " &apos; &

23 CDATA Contains text Is a declaration Can contain reserved characters, “, ‘, & Starts with / ends with <![CDATA[ Data would be here ]]> CDATA can not contain ]]>

24 Declarations

25 Why CDATA section “C++” code example CDATA example If (this->getX() < 5 && array1[0] != 3) cerr displayError(); PCDATA example If (this->getX() < 5 && array1[0] != 3) cerr << this->displayError();

26 Mixed Content Elements and PCDATA combined outer element stuff inner element stuff more outer element stuff

27 Empty Element Contains no text or data May have an attribute Short cut notation for empty element Does this look unfamiliar HTML example of such a type of tag //Non Well Formed //Well Formed

28 Elements element Start-tag content End-tag

29 Create XML Document 2 Include declaration Create root element Create child element Enter child element text “student name” Create child element Child to root, sibling to Make this an empty element Create child element Child to root, sibling to Enter C++ code example in PCDATA section Create child element Enter same C++ code in a CDATA section Save file Open using Internet Explorer

30 XML Parser – DOM & SAX Required to process an XML document C, Java, Python, Perl Parsers are of type Document Object Model(DOM) Tree structure Like a drive directory structure Slower and requires large amounts of memory Simple API for XML(SAX) Events driven Events = tags, text, etc. Smaller, faster, but requires programmer to deal with data Validating and non-validating

31 XML Structure Logical structure Document divided into units Allows sub units XML is a logical tree structure document Physical structure Data stored inside document Data stored outside document Entities one example

32 Valid Conforms to some schema schema “s” Document Type Definition(DTD) Schema By definition, all valid XML documents are Well – Formed documents

33 DTD Document Type Definition Document Type Declaration(DTD) File extension of “.dtd” DTD is not an XML document DTD is a schema “s” Introduced into an XML document via the Document Type Declaration Three types of DOCTYPE declarations Internal Subset Contained in the Prolog External Subset Exist in different file Prolog contains reference to file containing DTD Referenced using key work SYSTEM or PUBLIC Internal Subset and External Subset combination

34 Internal Subset <!DOCTYPE document [ ]> Hello World! <!-- More Comments -->

35 External Subset Hello World! <!-- More Comments -->

36 DTD for HelloWorld.xml

37 Internal Subset and External Subset combination I <!DOCTYPE document SYSTEM "HelloWorld3.dtd"[ ]> <!-- More Comments -->

38 Internal Subset and External Subset combination II

39 Putting it all together HelloWorld3.dtd HelloWorld3.xml <!DOCTYPE document SYSTEM "HelloWorld3.dtd"[ ]> <!-- More Comments -->

40 XML Validator Type in HelloWorld3.xml

41 Create XML Document 3 Create root element Create child element of session1 Enter child element text “xml class” Create child element of session2 Enter child element text “class information” Create child element of session3 Enter child element text “more” Create DTD for this file dtd_info.dtd Reference file in XML document Save files Open validate_vbs.html Enter.xml file name Validate

42 Schema Schemas are XML documents Schemas can be manipulated via a parser More complicated than DTDs Schemas have “ElementType”s

43 Schema vs. DTD

44 Schema vs. DTD II

45 Schema vs. DTD III

46 Topics not covered NamespaceWhitespace XpathXpointer Xlink XSLXSLT SOAPDDI Web Services SMIL XHTML


Download ppt "XML eXtensible Markup Language by Darrell Payne. Experience Logicon / Sterling Federal C, C++, JavaScript/Jscript, Shell Script, Perl XML Training XML."

Similar presentations


Ads by Google