Chapter 2A Semantic Web Primer 1 Chapter 2 Structured Web Documents in XML Grigoris Antoniou Frank van Harmelen.

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

XML: Extensible Markup Language
An Introduction to XML Based on the W3C XML Recommendations.
CS 898N – Advanced World Wide Web Technologies Lecture 21: XML Chin-Chih Chang
XSL Concepts Lecture 7. XML Display Options What can XSL Transformations do? generation of constant text suppression of content moving text (e.g., exchanging.
1 COS 425: Database and Information Management Systems XML and information exchange.
XML(EXtensible Markup Language). XML XML stands for EXtensible Markup Language. XML is a markup language much like HTML. XML was designed to describe.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Introduction to XML This material is based heavily on the tutorial by the same name at
1 Advanced Topics XML and Databases. 2 XML u Overview u Structure of XML Data –XML Document Type Definition DTD –Namespaces –XML Schema u Query and Transformation.
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
4/20/2017.
ECA 228 Internet/Intranet Design I Intro to XSL. ECA 228 Internet/Intranet Design I XSL basics W3C standards for stylesheets – CSS – XSL: Extensible Markup.
ECA 228 Internet/Intranet Design I Intro to XML. ECA 228 Internet/Intranet Design I HTML markup language very loose standards browsers adjust for non-standard.
XP New Perspectives on XML Tutorial 4 1 XML Schema Tutorial – Carey ISBN Working with Namespaces and Schemas.
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
RDF (Resource Description Framework) Why?. XML XML is a metalanguage that allows users to define markup XML separates content and structure from formatting.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 XML Taken from Chapter 7.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
Chapter 2 Structured Web Documents in XML Adapted from slides from Grigoris Antoniou and Frank van Harmelen.
Why XML ? Problems with HTML HTML design - HTML is intended for presentation of information as Web pages. - HTML contains a fixed set of markup tags. This.
Lecture 6 of Advanced Databases XML Schema, Querying & Transformation Instructor: Mr.Ahmed Al Astal.
Dr. Azeddine Chikh IS446: Internet Software Development.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
Extensible Markup and Beyond
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
Towards a Knowledge Society Why & How? XML. What information can we see… WWW2002 The eleventh international world wide web conference Sheraton waikiki.
Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
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 –
Chapter 2A Semantic Web Primer 1 Chapter 2 Structured Web Documents in XML Grigoris Antoniou Frank van Harmelen.
XML 2nd EDITION Tutorial 1 Creating An Xml Document.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation An Introduction to XML.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
1 Credits Prepared by: Rajendra P. Srivastava Ernst & Young Professor University of Kansas Sponsored by: Ernst & Young, LLP (August 2005) XBRL Module Part.
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
XML Introduction. Markup Language A markup language must specify What markup is allowed What markup is required How markup is to be distinguished from.
Tutorial 13 Validating Documents with Schemas
Chapter 2 Structured Web Documents in XML Adapted from slides from Grigoris Antoniou and Frank van Harmelen.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
Chapter 15: XML TP2543 Web Programming Mohammad Faidzul Nasrudin.
Information Design Trends Unit 4: Sources and Standards Lecture 3: A Brief Introduction to XML.
XML CSC1310 Fall HTML (TIM BERNERS-LEE) HyperText Markup Language  HTML (HyperText Markup Language): December  Markup  Markup is a symbol.
What information can we see… WWW2002 The eleventh international world wide web conference Sheraton waikiki hotel Honolulu, hawaii, USA 7-11 may
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
The Semantic Web Vision. Semantic Web Technologies Explicit Metadata Ontologies Logic and Inference Agents.
Chapter 5 The Semantic Web 1. The Semantic Web  Initiated by Tim Berners-Lee, the inventor of the World Wide Web.  A common framework that allows data.
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
SEMI-STRUCTURED DATA (XML) 1. SEMI-STRUCTURED DATA ER, Relational, ODL data models are all based on schema Structure of data is rigid and known is advance.
Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 14 This presentation © 2004, MacAvon Media Productions XML.
XML – Basic Concepts (modified version from Dr. Praveen Madiraju) 2015, Fall Pusan National University Ki-Joune Li.
Chapter 2 Structured Web Documents in XML Adapted from slides from Grigoris Antoniou and Frank van Harmelen.
XML Introduction to XML Extensible Markup Language.
XML Schema – XSLT Week 8 Web site:
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)
CH 15 XSL Transformations 1. Objective What is XSL? Overview of XSL transformations Understanding XSL templates Computing the value of a node with xsl:value-of.
Chapter 2A Semantic Web Primer 1 Chapter 2 Structured Web Documents in XML Grigoris Antoniou Frank van Harmelen.
Chapter 2 Structured Web Documents in XML Adapted from slides from Grigoris Antoniou and Frank van Harmelen.
Unit 4 Representing Web Data: XML
XML QUESTIONS AND ANSWERS
Chapter 7 Representing Web Data: XML
ece 720 intelligent web: ontology and beyond
Presentation transcript:

Chapter 2A Semantic Web Primer 1 Chapter 2 Structured Web Documents in XML Grigoris Antoniou Frank van Harmelen

Chapter 2A Semantic Web Primer 2 An HTML Example Nonmonotonic Reasoning: Context- Dependent Reasoning by V. Marek and M. Truszczynski Springer 1993 ISBN

Chapter 2A Semantic Web Primer 3 The Same Example in XML Nonmonotonic Reasoning: Context- Dependent Reasoning V. Marek M. Truszczynski Springer

Chapter 2A Semantic Web Primer 4 HTML versus XML: Similarities Both use tags (e.g. and ) Tags may be nested (tags within tags) Human users can read and interpret both HTML and XML representations quite easily … But how about machines?

Chapter 2A Semantic Web Primer 5 Problems with Automated Interpretation of HTML Documents An intelligent agent trying to retrieve the names of the authors of the book Authors’ names could appear immediately after the title or immediately after the word by Are there two authors? Or just one, called “V. Marek and M. Truszczynski”?

Chapter 2A Semantic Web Primer 6 HTML vs XML: Structural Information HTML documents do not contain structural information: pieces of the document and their relationships. XML more easily accessible to machines because – Every piece of information is described. – Relations are also defined through the nesting structure. – E.g., the tags appear within the tags, so they describe properties of the particular book.

Chapter 2A Semantic Web Primer 7 HTML vs XML: Structural Information (2) A machine processing the XML document would be able to deduce that – the author element refers to the enclosing book element – rather than by proximity considerations XML allows the definition of constraints on values – E.g. a year must be a number of four digits

Chapter 2A Semantic Web Primer 8 HTML vs XML: Formatting The HTML representation provides more than the XML representation: – The formatting of the document is also described Τhe main use of an HTML document is to display information: it must define formatting XML: separation of content from display – same information can be displayed in different ways

Chapter 2A Semantic Web Primer 9 HTML vs XML: Another Example In HTML Relationship matter-energy E = M × c2 In XML Relationship matter energy E M × c2

Chapter 2A Semantic Web Primer 10 HTML vs XML: Different Use of Tags In both HTML docs same tags In XML completely different HTML tags define display: color, lists … XML tags not fixed: user definable tags XML meta markup language: language for defining markup languages

Chapter 2A Semantic Web Primer 11 XML Vocabularies Web applications must agree on common vocabularies to communicate and collaborate Communities and business sectors are defining their specialized vocabularies – mathematics (MathML) – bioinformatics (BSML) – human resources (HRML) – …

Chapter 2A Semantic Web Primer 12 Lecture Outline 1. Introduction 2. Detailed Description of XML 3. Structuring a) DTDs b) XML Schema 4. Namespaces 5. Accessing, querying XML documents: XPath 6. Transformations: XSLT

Chapter 2A Semantic Web Primer 13 The XML Language An XML document consists of a prolog a number of elements an optional epilog (not discussed)

Chapter 2A Semantic Web Primer 14 Prolog of an XML Document The prolog consists of an XML declaration and an optional reference to external structuring documents

Chapter 2A Semantic Web Primer 15 XML Elements The “things” the XML document talks about – E.g. books, authors, publishers An element consists of: – an opening tag – the content – a closing tag David Billington

Chapter 2A Semantic Web Primer 16 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 – E.g. “Xml”, “xML”

Chapter 2A Semantic Web Primer 17 Content of XML Elements Content may be text, or other elements, or nothing David Billington +61 − 7 − If there is no content, then the element is called empty; it is abbreviated as follows: for

Chapter 2A Semantic Web Primer 18 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

Chapter 2A Semantic Web Primer 19 XML Attributes: An Example <order orderNo="23456" customer="John Smith" date="October 15, 2002">

Chapter 2A Semantic Web Primer 20 The Same Example without Attributes John Smith October 15, 2002 a528 1 c817 3

Chapter 2A Semantic Web Primer 21 XML Elements vs Attributes Attributes can be replaced by elements When to use elements and when attributes is a matter of taste But attributes cannot be nested

Chapter 2A Semantic Web Primer 22 Well-Formed XML Documents Syntactically correct documents Some syntactic rules: – Only one outermost element (called root element) – Each element contains an opening and a corresponding closing tag – Tags may not overlap Lee Hong – Attributes within an element have unique names – Element and tag names must be permissible

Chapter 2A Semantic Web Primer 23 The Tree Model of XML Documents: An Example <from name="Michael Maher" <to name="Grigoris Antoniou" Where is your draft? Grigoris, where is the draft of the paper you promised me last week?

Chapter 2A Semantic Web Primer 24 The Tree Model of XML Documents: An Example (2)

Chapter 2A Semantic Web Primer 25 The Tree Model of XML Docs The tree representation of an XML document is an ordered labeled tree: – There is exactly one root – There are no cycles – Each non-root node has exactly one parent – Each node has a label. – The order of elements is important – … but the order of attributes is not important

Chapter 2A Semantic Web Primer 26 Lecture Outline 1. Introduction 2. Detailed Description of XML 3. Structuring a) DTDs b) XML Schema 4. Namespaces 5. Accessing, querying XML documents: XPath 6. Transformations: XSLT

Chapter 2A Semantic Web Primer 27 Structuring XML Documents Define all the element and attribute names that may be used Define the 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

Chapter 2A Semantic Web Primer 28 Structuring XML Dcuments (2) 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)

Chapter 2A Semantic Web Primer 29 XML Schema Significantly richer language for defining the structure of XML documents Tts syntax is based on XML itself – not necessary to write separate tools Reuse and refinement of schemas – Expand or delete already existent schemas Sophisticated set of data types, compared to DTDs (which only supports strings)

Chapter 2A Semantic Web Primer 30 XML Schema (2) An XML schema is an element with an opening tag like <schema " version="1.0"> Structure of schema elements – Element and attribute types using data types

Chapter 2A Semantic Web Primer 31 Element Types Cardinality constraints: minOccurs="x" (default value 1) maxOccurs="x" (default value 1) Generalizations of *,?,+ offered by DTDs

Chapter 2A Semantic Web Primer 32 Attribute Types < 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

Chapter 2A Semantic Web Primer 33 Data Types There is a variety of built-in data types – Numerical data types: integer, Short etc. – String types: string, ID, IDREF, CDATA etc. – Date and time data types: time, Month etc. There are also user-defined data types – simple data types, which cannot use elements or attributes – complex data types, which can use these

Chapter 2A Semantic Web Primer 34 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

Chapter 2A Semantic Web Primer 35 A Data Type Example <element name="firstname" type="string" minOccurs="0“ maxOccurs="unbounded"/>

Chapter 2A Semantic Web Primer 36 XML Schema: The Example

Chapter 2A Semantic Web Primer 37 XML Schema: The Example (2) <element name="to" type="nameAddress" minOccurs="1" maxOccurs="unbounded"/> <element name="cc" type="nameAddress" minOccurs="0" maxOccurs="unbounded"/>

Chapter 2A Semantic Web Primer 38 XML Schema: The Example (3) Similar for bodyType

Chapter 2A Semantic Web Primer 39 Lecture Outline 1. Introduction 2. Detailed Description of XML 3. Structuring a) DTDs b) XML Schema 4. Namespaces 5. Accessing, querying XML documents: XPath 6. Transformations: XSLT

Chapter 2A Semantic Web Primer 40 Namespaces An XML document may use more than one DTD or schema Since each structuring document was developed independently, name clashes may appear The solution is to use a different prefix for each DTD or schema – prefix:name

Chapter 2A Semantic Web Primer 41 An Example <vu:instructors xmlns:vu=" xmlns:gu=" xmlns:uky=" <uky:facultyuky:title="assistant professor" uky:name="John Smith" uky:department="Computer Science"/> <gu:academicStaffgu:title="lecturer" gu:name="Mate Jones" gu:school="Information Technology"/>

Chapter 2A Semantic Web Primer 42 Namespace Declarations 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

Chapter 2A Semantic Web Primer 43 Lecture Outline 1. Introduction 2. Detailed Description of XML 3. Structuring a) DTDs b) XML Schema 4. Namespaces 5. Accessing, querying XML documents: XPath 6. Transformations: XSLT

Chapter 2A Semantic Web Primer 44 Addressing and Querying XML Documents In relational databases, parts of a database can be selected and retrieved using SQL – Same necessary for XML documents – Query languages: XQuery, XQL, XML-QL The central concept of XML query languages is a path expression – Specifies how a node or a set of nodes, in the tree representation of the XML document can be reached

Chapter 2A Semantic Web Primer 45 XPath XPath is core for XML query languages Language for addressing parts of an XML document. – It operates on the tree data model of XML – It has a non-XML syntax

Chapter 2A Semantic Web Primer 46 Types of Path Expressions Absolute (starting at the root of the tree) – Syntactically they begin with the symbol / – It refers to the root of the document (situated one level above the root element of the document) Relative to a context node

Chapter 2A Semantic Web Primer 47 An XML Example

Chapter 2A Semantic Web Primer 48 Tree Representation

Chapter 2A Semantic Web Primer 49 Examples of Path Expressions in XPath Address all author elements /library/author Addresses all author elements that are children of the library element node, which resides immediately below the root /t1/.../tn, where each ti+1 is a child node of ti, is a path through the tree representation

Chapter 2A Semantic Web Primer 50 Examples of Path Expressions in XPath (2) Address all author elements //author Here // says that we should consider all elements in the document and check whether they are of type author This path expression addresses all author elements anywhere in the document

Chapter 2A Semantic Web Primer 51 Examples of Path Expressions in XPath (3) Address the location attribute nodes within library element nodes The is used to denote attribute nodes

Chapter 2A Semantic Web Primer 52 Examples of Path Expressions in XPath (4) Address all title attribute nodes within book elements anywhere in the document, which have the value “Artificial Intelligence” Intelligence"

Chapter 2A Semantic Web Primer 53 Examples of Path Expressions in XPath (5) Address all books with title “Artificial Intelligence” Intelligence"] Test within square brackets: a filter expression – It restricts the set of addressed nodes. Difference with query 4. – Query 5 addresses book elements, the title of which satisfies a certain condition. – Query 4 collects title attribute nodes of book elements

Chapter 2A Semantic Web Primer 54 Tree Representation of Query 4

Chapter 2A Semantic Web Primer 55 Tree Representation of Query 5

Chapter 2A Semantic Web Primer 56 Examples of Path Expressions in XPath (6) Address the first author element node in the XML document //author[1] Address the last book element within the first author element node in the document //author[1]/book[last()] Address all book element nodes without a title attribute

Chapter 2A Semantic Web Primer 57 Lecture Outline 1. Introduction 2. Detailed Description of XML 3. Structuring a) DTDs b) XML Schema 4. Namespaces 5. Accessing, querying XML documents: XPath 6. Transformations: XSLT

Chapter 2A Semantic Web Primer 58 Displaying XML Documents Grigoris Antoniou University of Bremen may be displayed in different ways:Grigoris AntoniouUniversity of

Chapter 2A Semantic Web Primer 59 Style Sheets Style sheets can be written in various languages – E.g. CSS2 (cascading style sheets level 2) – XSL (extensible stylesheet language) XSL includes – a transformation language (XSLT) – a formatting language – Both are XML applications

Chapter 2A Semantic Web Primer 60 XSL Transformations (XSLT) XSLT specifies rules with which an input XML document is transformed to – another XML document – an HTML document – plain text The output document may use the same DTD or schema, or a completely different vocabulary XSLT can be used independently of the formatting language

Chapter 2A Semantic Web Primer 61 XSLT (2) Move data and metadata from one XML representation to another XSLT is chosen when applications that use different DTDs or schemas need to communicate XSLT can be used for machine processing of content without any regard to displaying the information for people to read. In the following we use XSLT only to display XML documents

Chapter 2A Semantic Web Primer 62 XSLT Transformation into HTML An author

Chapter 2A Semantic Web Primer 63 Style Sheet Output An author Grigoris Antoniou University of Bremen

Chapter 2A Semantic Web Primer 64 Observations About XSLT XSLT documents are XML documents – XSLT resides on top of XML The XSLT document defines a template – In this case an HTML document, with some placeholders for content to be inserted xsl:value-of retrieves the value of an element and copies it into the output document – It places some content into the template

Chapter 2A Semantic Web Primer 65 A Template An author...

Chapter 2A Semantic Web Primer 66 Auxiliary Templates We have an XML document with details of several authors It is a waste of effort to treat each author element separately In such cases, a special template is defined for author elements, which is used by the main template

Chapter 2A Semantic Web Primer 67 Example of an Auxiliary Template Grigoris Antoniou University of Bremen David Billington Griffith University

Chapter 2A Semantic Web Primer 68 Example of an Auxiliary Template (2) Authors

Chapter 2A Semantic Web Primer 69 Example of an Auxiliary Template (3) Affiliation:<xsl:value-of select="affiliation"/>

Chapter 2A Semantic Web Primer 70 Multiple Authors Output Authors Grigoris Antoniou Affiliation: University of Bremen David Billington Affiliation: Griffith University

Chapter 2A Semantic Web Primer 71 Explanation of the Example xsl:apply-templates element causes all children of the context node to be matched against the selected path expression – E.g., if the current template applies to /, then the element xsl:apply-templates applies to the root element – I.e. the authors element (/ is located above the root element) – If the current context node is the authors element, then the element xsl:apply-templates select="author" causes the template for the author elements to be applied to all author children of the authors element

Chapter 2A Semantic Web Primer 72 Explanation of the Example (2) It is good practice to define a template for each element type in the document – Even if no specific processing is applied to certain elements, the xsl:apply-templates element should be used – E.g. authors In this way, we work from the root to the leaves of the tree, and all templates are applied

Chapter 2A Semantic Web Primer 73 Summary XML is a metalanguage that allows users to define markup XML separates content and structure from formatting XML is the de facto standard for the representation and exchange of structured information on the Web XML is supported by query languages

Chapter 2A Semantic Web Primer 74 Points for Discussion in Subsequent Chapters The nesting of tags does not have standard meaning The semantics of XML documents is not accessible to machines, only to people Collaboration and exchange are supported if there is underlying shared understanding of the vocabulary XML is well-suited for close collaboration, where domain- or community-based vocabularies are used – It is not so well-suited for global communication.