Presentation is loading. Please wait.

Presentation is loading. Please wait.

Of 33 lecture 3: xml and xml schema. of 33 XML, RDF, RDF Schema overview XML – simple introduction and XML Schema RDF – basics, language RDF Schema –

Similar presentations


Presentation on theme: "Of 33 lecture 3: xml and xml schema. of 33 XML, RDF, RDF Schema overview XML – simple introduction and XML Schema RDF – basics, language RDF Schema –"— Presentation transcript:

1 of 33 lecture 3: xml and xml schema

2 of 33 XML, RDF, RDF Schema overview XML – simple introduction and XML Schema RDF – basics, language RDF Schema – basics, language Semantics of RDF and RDF Schema SPARQL – query language for RDF ece 627, winter '132

3 of 33 XML introduction XML – Extensible Markup Language  designed to describe structured documents  users may create their own tags (they can create their own specific languages)  tags have no semantics indicting how to present documents through a Web browser ece 627, winter '133

4 of 33 XML example Semantic Web is Cool John Smith Springer 1993 0387976892 ece 627, winter '134

5 of 33 ece 627, winter '135 XML prolog of a document the prolog:  an XML declaration  an optional reference to external structuring documents

6 of 33 ece 627, winter '136 XML elements “things” the XML document talks about  books, authors, publishers, … each element contains three parts  an opening tag  the content  a closing tag John Smith

7 of 33 ece 627, winter '137 XML elements (2) tag names can be chosen almost freely the first character must be a letter, an underscore, or a colon no name may begin with the string “xml” in any combination of cases (“Xml”, “xML”)

8 of 33 ece 627, winter '138 XML content of elements content may be text, or other elements, or nothing John Smith +1 − 780 − 492 5507 if no content for

9 of 33 ece 627, winter '139 XML attributes an empty element is not necessarily meaningless  it may have some properties in terms of attributes an attribute is a name-value pair inside the opening tag of an element

10 of 33 ece 627, winter '1310 XML other components comments processing instructions (define procedural attachments)

11 of 33 ece 627, winter '1311 XML well-formed documents syntactically correct documents – ones that obey some syntactic rules:  there is only one outermost element (called root element)  each element has an opening and a corresponding closing tag  tags may not overlap Lee Hong  attributes have unique names  names of elements and tags must be permissible

12 of 33 ece 627, winter '1312 XML tree model of XML documents <from name=”John Smith" address=”johnsmith@gmail.com"/> <to name=”Jenny Doe" address=”jennydoe@hotmail.com"/> How are you? Hi, it was nice …

13 of 33 ece 627, winter '1313 XML tree model of XML documents

14 of 33 ece 627, winter '1314 XML structure of documents definition of all element and attribute names that may be used definition of structure  what values an attribute may take  which elements may or must occur within other elements, etc. if such structuring information exists, the document can be validated

15 of 33 ece 627, winter '1315 an XML document is valid if  it is well-formed  respects the structuring information it uses there are two ways of defining the structure of XML documents:  DTDs (the older and more restricted way)  XML Schema (offers extended possibilities) XML structure of documents (2)

16 of 33 ece 627, winter '1316 John Smith +1 − 780 − 492 5507 DTD for above element (and all author elements): XML structure of documents: DTD

17 of 33 ece 627, winter '1317 XML DTD: its meaning the element types author, name, and phone may be used in the document an author element contains a name element and a phone element, in that order (sequence)

18 of 33 ece 627, winter '1318 XML DTD: its meaning a name element and a phone element may have any content in DTDs, #PCDATA is the only atomic type for elements

19 of 33 ece 627, winter '1319 XML Schema richer language for defining the structure of XML documents its syntax is based on XML itself sophisticated set of data types, compared to DTDs (which only supports strings)

20 of 33 ece 627, winter '1320 XML Schema (2) it is like an element with an opening tag like <xsd:schema xmlns:xsd=“http://www.w3.org/2001 XMLSchema” version=“1.0”>...

21 of 33 ece 627, winter '1321 XML Schema element types type=“…” minOccurs=“x” (x may be any natural number) maxOccurs=“x” (any number of unbounded)

22 of 33 ece 627, winter '1322 XML Schema element types - examples

23 of 33 ece 627, winter '1323 XML Schema attribute types type=“…” use=“x” (x may be optional or required or prohibited) default value

24 of 33 ece 627, winter '1324 XML Schema attribute types - examples < attribute name="speaks" type="Language" use="default" value="en"/> existence: use="x", where x may be optional or required default value: use="x" value="...", where x may be default or fixed

25 of 33 ece 627, winter '1325 XML Schema data types built-in data types  numerical data: integer, Short, …  string: string, ID, IDREF, CDATA, …  date and time: time, Month, … user-defined data types  simple data types, which cannot use elements or attributes  complex data types, which can use these

26 of 33 ece 627, winter '1326 XML Schema data types (2) complex data types are defined from already existing data types by defining some attributes (if any) and using:  sequence, a sequence of existing data type elements (order is important)  all, a collection of elements that must appear (order is not important)  choice, a collection of elements, of which one will be chosen

27 of 33 ece 627, winter '1327 XML Schema data type extension already existing data types can be extended by new elements or attributes <element name="email" type="string" minOccurs="0" maxOccurs="1"/>

28 of 33 ece 627, winter '1328 XML Schema data type restriction an existing data type may be restricted by adding constraints on certain values (it is not the opposite process from extension) the following hierarchical relationship still holds:  instances of the restricted type are also instances of the original type (they satisfy at least the constraints of the original type and some new ones)

29 of 33 ece 627, winter '1329 XML Schema data type restriction – example <element name="firstname" type="string" minOccurs="1" maxOccurs="2"/> <attribute name="title" type="string" use="required"/>

30 of 33 ece 627, winter '1330 XML Schema restriction of simple data types

31 of 33 ece 627, winter '1331 XML Schema namespaces a single XML document may use more than one DTD or schema in order to avoid clashes a different prefix for each DTD or schema can/should be used prefix:name

32 of 33 ece 627, winter '1332 XML Schema namespaces namespaces are declared within an element and can be used in that element and any of its children (elements and attributes) a namespace declaration has the form: xmlns:prefix="location" location is the address of the DTD or schema if a prefix is not specified: xmlns="location" then the location is used by default

33 of 33 ece 627, winter '1333 XML Schema namespaces – example <… xmlns="http://www.ua.ca/basic.xsd" xmlns:staff="http://www.ua.ca/staff.xsd"> <staff:facultystaff:title=“professor" staff:name="John Smith" staff:department=”ECE"/> <academicStafftitle="lecturer" name=”Jenny Doe" school="Information Technology"/>


Download ppt "Of 33 lecture 3: xml and xml schema. of 33 XML, RDF, RDF Schema overview XML – simple introduction and XML Schema RDF – basics, language RDF Schema –"

Similar presentations


Ads by Google