Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.

Similar presentations


Presentation on theme: "XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended."— Presentation transcript:

1 XML Language Family Detailed Examples Most information contained in these slide comes from: http://www.w3.org, http://www.zvon.org/ These slides are intended to be used as a tutorial on XML and related technologies Slide author: Jürgen Mangler (juergen.mangler@univie.ac.at) This section contains examples on: XML, DTD (Document Type Definition)

2 The W3C is the "World Wide Web Consortium", a voluntary association of companies and non-profit organizations. Membership is very expensive but confers voting rights. The decisions of W3C are guided by the Advisory Committee, lead by Tim Berners-Lee. The stages in the life of a W3C Recommendation (REC) Working Draft (maximum gap target: 3 months) Last Call (public comment invited; W3C must respond) Candidate Recommendation (design is stable; implementation feedback invited) Proposed Recommendation (Advisory Committee review) The XML recommendation was written by the W3C's XML Working Group (WC), which has since divided into a number of subgroups.

3 XML First line: Elements + Attributes Wellformed (start/closing tag, correctly nested) One root element <& must be escaped ><&’” can be escaped (> < & quot; &apos;) Attributes in quotes Elements start with _ or letters Elements can consist of alphanumeric characters - _ (no :, don’t start with xml)

4 An XML document is valid if it has an associated document type definition and if the document complies with the constraints expressed in it. The document type definition (DTD) must appear before the first element in the document. The name following the word DOCTYPE in the document type definition must match the name of the root element. tutorial.dtd: tutorial.xml: This is an XML document

5 An element type has element content if elements of that type contain only child elements (no character data), optionally separated by white space. tutorial.dtd: tutorial.xml: fad graubraun tutorial.xml (with errors, farbe missing): Start

6 If an element name in the DTD is followed by the star [*], this element can occur zero, once or several times tutorial.dtd: tutorial.xml: vollmundig herb rot The root element XXX can contain zero or more elements AAA followed by precisely one element BBB. Element BBB must be always present.:

7 If an element name in the DTD is followed by the plus [+], this element can occur once or several times. tutorial.dtd: tutorial.xml: lieblich blumig weiss tutorial.xml (with errors, AAA must occur at least once): weiss

8 If an element name in the DTD is followed by the question mark [?], this element can occur zero or one times. tutorial.dtd: tutorial.xml: süffig This example uses a combination of [ + * ?] How could a valid document look like?

9 With the character [ | ] you can select one from several elements. test.dtd: test.xml: Ottakringer The root element XXX must contain either one element AAA or one element BBB: test.xml: Riesling Text can be interspersed with elements.

10 Attributes are used to associate name-value pairs with elements. Attribute specifications may appear only within start-tags and empty-element tags. The declaration starts with !ATTLIST followed by the name of the element (myElement) to which the attributes belong to, followed by the definition of the individual attributes (myAttributeA, myAttributeB). Text

11 An attribute of type CDATA may contain any arbitrary character data, given it conforms to well formedness constraints. Type NMTOKEN can contain only letters, digits and point [. ], hyphen [ - ], underline [ _ ] and colon [ : ] NMTOKENS can contain the same characters as NMTOKEN plus whitespaces. White space consists of one or more space characters, carriage returns, line feeds, or tabs. <!ATTLIST taskgroup group CDATA #IMPLIED purpose NMTOKEN #REQUIRED names NMTOKENS #REQUIRED>

12 The value of an attribute of type ID may contain only characters permitted for NMTOKEN and must start with a letter. No element type may have more than one ID attribute specified. The value of an ID attribute must be unique between all values of all ID attributes (in the document!).

13 The value of an attribute of type IDREF has to match the value of some ID attribute in the document. The value of an IDREF attribute can contain several references to elements with ID attributes separated by whitespaces. <!ATTLIST restaurant name CDATA #REQUIRED weinsorte IDREF #REQUIRED>

14 Permitted attribute values can be defined in the DTD If an attribute is implied, a default value can be provided in case the attribute isn't used. #Required: You must set the attribute #Implied: You can set the attribute

15 An element can be defined as EMPTY. In such a case it may contain attributes only but no text. money, power Are there errors in this example? Where are they?


Download ppt "XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended."

Similar presentations


Ads by Google