Presentation is loading. Please wait.

Presentation is loading. Please wait.

FIGIS’ML Hands-on training - © FAO/FIGIS 2001 1 An introduction to XML Objectives : –what is XML? –XML and HTML –XML documents structure well-formedness.

Similar presentations


Presentation on theme: "FIGIS’ML Hands-on training - © FAO/FIGIS 2001 1 An introduction to XML Objectives : –what is XML? –XML and HTML –XML documents structure well-formedness."— Presentation transcript:

1 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 1 An introduction to XML Objectives : –what is XML? –XML and HTML –XML documents structure well-formedness –Validation of XML documents : the DTDs creation of a DTD the schemas –creating XML documents

2 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 2 An introduction to XML What is XML? : –XML stands for eXtensible Markup Language XML is similar to HTML but –HTML deals with presentation –XML deals with content and structure XML is extensible : you can create your own tags –XML is an open standard managed by the World Wide Web Consortium (W3C) http://www.w3c.org –XML is text-based

3 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 3 An introduction to XML What is XML? : an example Groovy beats Howie C. Average Records Piano for Dummies - vol1 K. Board Dubious & P. Ano

4 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 4 An introduction to XML XML and HTML –HTML : pros : widely used, simple to use; cons : mixes data and formatting, non-extensible –XML : handles only the content - formatting is done by stylesheets the tags are defined by the authors tags definition and structure is handled by dictionnaries (DTD)

5 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 5 An introduction to XML XML and HTML : examples –HTML –XML Groovy beats Howie C. Average Records Groovy beats Howie C. Average Records

6 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 6 An introduction to XML an XML document Groovy beats Howie C. Average Records Piano for Dummies - vol1 K. Board Dubious & P. Ano declaration element entity attribute root

7 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 7 An introduction to XML an XML document –Elements they define the document’s content they can contain other elements or text they can be empty –Attributes add information about one element one attribute can only appear once in one element attributes can only contain text –Entities can be used as “shortcuts” are similar to variables

8 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 8 An introduction to XML an XML document –Declaration always the first line of an XML document can be omitted (not recommended) always like : can contain language-related info : –Root (element) mandatory always unique

9 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 9 An introduction to XML Creating well-formed XML documents –well-formed means that the document respects the XML rules –the main rules are : there must be a root there must be at least one element inside the root all elements must be properly imbricated and closed elements, attributes and entities are case-sensitive attribute values have to be quoted

10 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 10 An introduction to XML Valid XML documents –an XML document is valid when : it follows the structure that has been defined all the elements respect the defined rules –valid elements –valid attributes –optional and mandatory elements/attributes –the validation rules are defined in a “dictionnary” : a Document Type Definition (DTD) a schema (still a proposal)

11 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 11 An introduction to XML Valid XML documents – well-formed doesn’t imply valid well-formed means syntaxically correct valid is similar to grammatically correct –but a valid document is always well-formed

12 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 12 An introduction to XML Valid XML documents : DTD – Creating a DTD : sample XML Groovy beats Howie C. Average Records Piano for Dummies - vol1 K. Board Dubious & P. Ano

13 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 13 An introduction to XML Valid XML documents : DTD – Creating a DTD : insert the declaration identify the root element ORDER identify its direct children ITEM with TYPE and Quantity as attributes define children grouping and repetition any number of ITEM elements repeat these steps for each level of elements ITEM contains one mandatory occurrence of AVAILABLE, TITLE, AUTHOR and EDITOR

14 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 14 An introduction to XML Valid XML documents : DTD – Creating a DTD : define root element : <!ELEMENT ORDER define its direct children and their order/number: repeat those steps for each element : define the attributes of each element :

15 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 15 An introduction to XML Valid XML documents : DTD – Creating a DTD : grouping an repeating elements specifiying the number of elements : –0 or 1 : –1 or more : –0 or more : –1 exactly : specifying the order of elements : –any order : –specified order : and any combination of those :

16 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 16 An introduction to XML Valid XML documents : DTD – Creating a DTD : elements content elements can be empty : –example : –they should be declared using EMPTY : elements can contain other elements :... elements can contain text : –example : Groovy beats –they should be declared using (#PCDATA) :

17 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 17 An introduction to XML Valid XML documents : DTD – Creating a DTD : adding attributes using ATTLIST : <!ATTLIST ITEM TYPE (CD | book) “CD” QUANTITY CDATA #REQUIRED > this defines : –two attributes of the element ITEM –gives the list of possible TYPE values (“CD”/“book”) –defines “CD” as the default value for TYPE –defines QUANTITY as a mandatory attribute there are three attribute types : –#REQUIRED : a value is mandatory –#IMPLIED : a value is optional –#FIXED : the attribute always has the same value

18 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 18 An introduction to XML Valid XML documents : DTD – Creating a DTD : example Groovy beats Howie C. Average Records Piano for Dummies - vol1 K. Board Dubious & P. Ano

19 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 19 An introduction to XML Valid XML documents : DTD – Creating a DTD : example hands-on : creating a DTD with XMLSpy this is the DTD defined for the sample XMl document : <!ATTLIST ORDER orderref CDATA #REQUIRED > <!ATTLIST ITEM TYPE (CD | book) "CD" QUANTITY CDATA #REQUIRED > <!ATTLIST AVAILABLE TIME (2days | 1week | normal) #IMPLIED STATUS (YES | NO) #REQUIRED >

20 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 20 An introduction to XML Valid XML documents : schemas –schemas are still a proposal –schemas are written in XML they don’t require learning a new language they can be handled and transformed as normal XML documents –schemas can contain more complex rules that DTDs conditions tests...

21 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 21 An introduction to XML creating XML documents –XML is pure text –XML documents can be created manually –XML editing softwares make the task easier check for well-formedness and validity provide a graphical user interface –Various solutions exist : XMLSpy by Altova (Windows) Xmetal by SoftQuad(Windows) Morphon XML Editor Suite by Morphon (MacOS) ElfData XML Editor by ElfData (MacOS)

22 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 22 An introduction to XML Creating XML documents : –hands-on : creating a document with XMLSpy example of an order form : –1 order : reference 120136 –two items in the order : »1 CD, “Groovy beats” by Howie C., ed. “Average Records”, available with 2-days delivery »2 copies of the book “Piano for dummies - vol1” by K. Board, published by “Dubious & P. Ano”, available with 1-week delivery

23 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 23 An introduction to XML Creating XML documents : –hands-on : creating a document with XMLSpy Groovy beats Howie C. Average Records Piano for Dummies - vol1 K. Board Dubious & P. Ano

24 FIGIS’ML Hands-on training - © FAO/FIGIS 2001 24 An introduction to XML using XML documents –exchanging data between systems from a DB to another DB data manipulation by softwares –submitting data to a system automatically (software) manually (creation of content) –presenting data to the user web pages data export in any format (text, pdf, etc.)


Download ppt "FIGIS’ML Hands-on training - © FAO/FIGIS 2001 1 An introduction to XML Objectives : –what is XML? –XML and HTML –XML documents structure well-formedness."

Similar presentations


Ads by Google