Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML and friends Part 1 - XML and DTD ELAG 2001 workshop 8 Jan Erik Kofoed © BIBSYS Library Automation.

Similar presentations


Presentation on theme: "XML and friends Part 1 - XML and DTD ELAG 2001 workshop 8 Jan Erik Kofoed © BIBSYS Library Automation."— Presentation transcript:

1 XML and friends Part 1 - XML and DTD ELAG 2001 workshop 8 Jan Erik Kofoed © BIBSYS Library Automation

2 XML © Jan Erik Kofoed 20012 XML – eXtensible Markup Language Describing content The grammar of the language is given, but ”any” word is allowed Readable for both man and machine Generally usable as meta language Uses tags for describing content

3 XML © Jan Erik Kofoed 20013 SGML and XML SGML – Standard Generalized Markup Language, ISO 8879:1986(E) XML – Extensible Markup Language 1.0 2nd Ed., W3C Recommendation 06.10.2000 XML is compatible with SGML SGML is of many considered as difficult and expensive XML is designed to be easy to implement and to operate together with SGML and HTML

4 XML © Jan Erik Kofoed 20014 Design goals for XML 1.XML shall be straight forwardly useable 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. 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.

5 XML © Jan Erik Kofoed 20015 HTML and XML HTML – HyperText Markup Language 4.01, W3C Recommendation 24.12.1999. –Now replaced by: XHTML - Extensible HyperText Language 1.0, W3C Recommendation 26.01.2000. Both XML and HTML is compatible with SGML. HTML describes presentation. XML describes content. XHTML is HTML with XML syntax.

6 XML © Jan Erik Kofoed 20016 HTML shows layout Book Hamsun, Knut: Markens grøde. Oslo, Aschehoug, 1948

7 XML © Jan Erik Kofoed 20017 XML is marking the content Hamsun, Knut Markens grøde Oslo Aschehoug 1948

8 XML © Jan Erik Kofoed 20018 One simple document Åse Østby Furuveien 8 3721 Skogheim

9 XML © Jan Erik Kofoed 20019 Remember to add encoding! Åse Østby Furuveien 8 3721 Skogheim

10 XML © Jan Erik Kofoed 200110 Architecture of XML-documents Processing instruction Element content –Empty element Attribute Comment Entity &entity; CDATA ]]> DTD

11 XML © Jan Erik Kofoed 200111 Example is the root element. ]]> Hamsun, Knut Markens grøde Kristiania Gyldendal 1917 <Dedication "Til Marie" on the title page. >

12 XML © Jan Erik Kofoed 200112 Presented i MS IE is the root element. ]]> Hamsun, Knut Markens grøde Kristiania Gyldendal 1917

13 XML © Jan Erik Kofoed 200113 Two types of XML documents Well formed XML –Must follow certain rules Valid XML –Must be well formed –Must follow rules given in a DTD, Document Type Definition

14 XML © Jan Erik Kofoed 200114 Well formed XML 1.The document must begin with a XML declaration. 2.All elements that contains data must begin with a start and end tag. 3.Empty elements without end tag must end with: /> 4.One root element must span all other elements. 5.Elements may be nested, but cannot be overlapped. 6.Attribute values must be inside quotes: “ “ 7.The characters < and & must only be used to start tags and entities. 8.An element may not have two attributes with the same name. 9.Comments and processing instructions may not appear inside tags.

15 XML © Jan Erik Kofoed 200115 Rules for XML Name of elements and attributes –must start with a letter or _ –can then contain letter, number, -,. or _ –is case sensitive –may not start with xml, XML, Xml, xMl... –non ASCII (“national”) letters are allowed Standard character set is UTF8 (Unicode) –use the encoding attribute.

16 XML © Jan Erik Kofoed 200116 Reserved attributes (1) xml:lang –language code. Defined in RFC-1766. xml:space –preservePreserve space, tab and carriage return –defaultThe XML processor decides how spaces shall be processed.

17 XML © Jan Erik Kofoed 200117 Reserved attributes (2) xml:link –simpleone way pointer –documentpointer to a member of a group –extendedmultiple and extended pointer –groupgroup with pointers to documents xml:attribute –old-attribute new-attribute switches attributes

18 XML © Jan Erik Kofoed 200118 Entities in XML Entities starts with & and ends with ; && << >> &qout;” &apos;’ &#xnnnn;character with Unicode value nnnn

19 XML © Jan Erik Kofoed 200119 Document type definition DTD Rules for the structure of XML documents Defines names of elements and attributes Defines succession (order) Defines occurrence Defines type of attributes Defines default values for attributes Defines required elements and attributes

20 XML © Jan Erik Kofoed 200120 DTD: entities (1) General entity – –Ex.: – &www; Parameter entity – –Ex.: –

21 XML © Jan Erik Kofoed 200121 DTD: entities (2) External entities – – &addresses; Non-XML entity – Notation –

22 XML © Jan Erik Kofoed 200122 DTD: ELEMENT –

23 XML © Jan Erik Kofoed 200123 DTD: Definition of occurrences (none)Must occur exactly once. ?Can occur zero or once. +Must occur once or more. *Can occur zero or more.

24 XML © Jan Erik Kofoed 200124 DTD: attributes Example: –

25 XML © Jan Erik Kofoed 200125 DTD: Attribute types –CDATAString –(name | name |...)List of values –ENTITYDefined entity –ENTITIESList of entities –IDUnique identifier –IDREFReference to an ID –IDREFSList of ID references –NMTOKENA word built from name characters –NMTOKENSList of nmtokens –NOTATIONNon-analyzed entities

26 XML © Jan Erik Kofoed 200126 DTD:Examples (1) <!ATTLIST person name CDATA #REQUIRED number ID #REQUIRED sex (M | K) #IMPLIED> <person name=”Mary Hill” number=”p12077137651” sex=”M” />

27 XML © Jan Erik Kofoed 200127 DTD:Examples (2) Gold feber

28 XML © Jan Erik Kofoed 200128 DTD:Examples (3) <!DOCTYPE DOCUMENT [ ]> Susan Jack Chelsea David

29 XML © Jan Erik Kofoed 200129 DTD:Examples (4)

30 XML © Jan Erik Kofoed 200130 DTD:Examples (5a)

31 XML © Jan Erik Kofoed 200131 DTD:Examples (5b) Hamsun, Knut Markens grøde Oslo Aschehoug 1948


Download ppt "XML and friends Part 1 - XML and DTD ELAG 2001 workshop 8 Jan Erik Kofoed © BIBSYS Library Automation."

Similar presentations


Ads by Google