Knowledge Representation Part IV The Semantics Web Starting

Knowledge Representation Part IV The Semantics Web Starting with XML Jan Pettersen Nytun, Ui. A Jan Pettersen Nytun, UIA, page 1

S P O The Semantic Web • A W 3 C recommendation. • Common data formats. • Allow specification of data about data - which again allows automatic reasoning. • Globally unique ids by using the addressing mechanism of the web. Jan Pettersen Nytun, UIA, page 2

S P O Some of the W 3 C hold Specifications – HTML – OWL – RDF – SOAP – SPARQL – SVG – XHTML – XPath –… Jan Pettersen Nytun, UIA, page 3

S P O The Semantic Web Language Stack Hierarchy of languages, where each layer exploits and uses capabilities of the layers below. / XML Schema Jan Pettersen Nytun, UIA, page 4

S P O About Semantic Web Languages • Can use XML syntax – E. g. , XML Schema can define an element type (~ class) with help of XML syntax. • One language may constrain a lower level language – E. g. , XML Schema limits XML. • One language may extend a lower level language – E. g. , RDF Schema (RDFS) extends XML Schema with a richer vocabulary. Jan Pettersen Nytun, UIA, page 5

S P O EXtensible Markup Language (XML) / XML Schema Jan Pettersen Nytun, UIA, page 6

XML • XML is a general format while html is meant for human readable web pages! • XML has no fixed tag vocabulary – hence, users can define their own custom element and attribute names. • It has some keywords, e. g. , xmlns. Jan Pettersen Nytun, UIA, page 7

S P O XML Syntax in Well-formed Documents • The document must have exactly one root element. The following is a wellformed XML document: <journal>This is a journal. </journal> start-tag content end-tag • The basic syntax for one element is: <name attribute="value“…>content</name> • The following is also correct syntax: <journal txt=“This is a journal. ” /> Jan Pettersen Nytun, UIA, page 8

S P O XML Syntax Continues… The root element can be preceded by an optional XML declaration. E. g. , <? xml version="1. 0" encoding="UTF-8"? > There may be elements inside elements, but XML requires that elements be properly nested, i. e. , no overlap. Example: Start-tag and end-tag of element medicalsystem Attribute <medicalsystem> <journal name=“Ola Norman" id=“ 1"> <journalrecord>May be a little overweight</journalrecord> </journal> <journal name=“Kari Norman" id=“ 2"> <journalrecord>Lack of iron. </journalrecord> <journalrecord>A slight attack of shopomania? </journalrecord> </journal> </medicalsystem> Jan Pettersen Nytun, UIA , page 9

S P O xmlns - XML Namespace Gives unique names to elements and attributes. xmlns can be used to solve name conflicts inside one xml page, e. g. , “table” may be a furniture or a data structure. Jan Pettersen Nytun, UIA, page 10

S P O Namespace Examples An xml name space is often a web address. The address may go to a none existing web page - only the URI (URL) addressing mechanism is used. [1]: <root xmlns: h=“http: //www. w 3. org/TR/html 4/” xmlns: f="http: //www. w 3 schools. com/furniture"> <h: table> …. </h: table> <f: name>African Coffee Table</f: name> <f: width>80</f: width> <f: length>120</f: length> </f: table> </root> Jan Pettersen Nytun, UIA, page 11

S P XML - UML O Medical System UML Model Journal name: String SSN: String * 1 Journal. Record description: String : Journal name=“Ola” SSN=“ 1” : Journal. Record description=“May be a little bit fat? ” : Journal. Record name=“Kari” SSN=“ 2” description=“Lack of iron. ” : Journal. Record Data description=“A slight attack of shopomania? ” <medicalsystem> <journal name=“Ola Norman" ssn=“ 1"> <journalrecord>May be a little bit fat? </journalrecord> </journal> <journal name=“Kari Norman" ssn=“ 2"> <journalrecord>Lack of iron. </journalrecord> <journalrecord>A slight attack of shopomania? </journalrecord> </journal> </medicalsystem> Jan Pettersen Nytun, UIA, page 12

S P O The Document Object Model (DOM) A cross-platform and language-independent application programming interface that treats an HTML, XHTML, or XML document as a tree structure wherein each node is an object representing a part of the document. Jan Pettersen Nytun, Ui. A, page 13

What is meant with the following statement: “XML is Syntax”? Syntax: …the rules about how words are arranged and connected … to make phrases and sentences… Jan Pettersen Nytun, UIA, page 14

S P O XML “is Syntax” • Custom tags like <musician>, and <record> can make XML documents at least partly selfdescribed to humans. • But what is meant by a tag, e. g. , <musician>, is not given (the term “musician” is used but not explained). Jan Pettersen Nytun, UIA, page 15

S From Wikipedia: O P XML is a generic framework for storing text or any data whose structure can be represented as a tree. Why a tree? <medicalsystem> <journal name=“Ola Norman" id=“ 1"> <journalrecord>May be a little overweight</journalrecord> </journal> <journal name=“Kari Norman" id=“ 2"> <journalrecord>Lack of iron. </journalrecord> Directed. Tree <journalrecord>A slight attack of shopomania? 0. . 1 </journalrecord> </journal> </medicalsystem> 0. . 1 top. Root Node child * 1 root edge Jan Pettersen Nytun, UIA, page 16

<medicalsystem> <journal name=“Ola Norman" id=“ 1"> <journalrecord>May be a little overweight</journalrecord> </journal> <journal name=“Kari Norman" id=“ 2"> <journalrecord>Lack of iron. </journalrecord> <journalrecord>A slight attack of shopomania? </journalrecord> </journal> </medicalsystem> medicalsystem journal name “Ola Norman" journal id journalrecord “ 1" name “Kari Norman" “May be a little overweight " Where did the end-tags go? What about the order of things? id “ 2" journalrecord “Lack of iron. " “A slight attack of shopomania? " Jan Pettersen Nytun, UIA, page 17

S P O Element Attribute Text content * Building blocks for defining an XML document (Using UML) 0. . 1 container Node name : String Element Attribute text. Content : String value : String (A bit simplified)

An XML Schema functioning as model Example (simplified): <xsd: schema …. > <xsd: element name = “Building” type = “Building. Type”/> <xsd: complex. Type name=" Building. Type"> <xsd: attribute name=“name" type="xsd: string"/> <xsd: attribute name=“area" type="xsd: integer"/> </xsd: complex. Type> XML document (= instance of some XML schema)): <? xml version=1. 0” …> … <Building name=“Blue. Box" area = 300/> …. . Jan Pettersen Nytun, UIA, page 19
![S P O URI [1] • A URI (a Uniform Resource Identifier) is used S P O URI [1] • A URI (a Uniform Resource Identifier) is used](http://slidetodoc.com/presentation_image_h2/1a63dc9f7c1c1e35a04659883117d318/image-20.jpg)
S P O URI [1] • A URI (a Uniform Resource Identifier) is used to uniquely identify a resource. • A URI is a string that refers to a resource, such as a web page, a person, or a corporation. In some cases it is just a web address (where there are no content). Jan Pettersen Nytun, UIA, page 20

S P O Uniform Resource Locator (URL) From Wikipedia: … a URL is a subset of URI that specifies where an identified resource is available and the mechanism for retrieving it… … often incorrectly used as a synonym for URI… Jan Pettersen Nytun, Ui. A, Ontologies, page 21
![S P O URI/URL [1] • Often URIs use the syntax of web addresses S P O URI/URL [1] • Often URIs use the syntax of web addresses](http://slidetodoc.com/presentation_image_h2/1a63dc9f7c1c1e35a04659883117d318/image-22.jpg)
S P O URI/URL [1] • Often URIs use the syntax of web addresses since they are unique. • A "#" in a URI denotes an individual that is referred to on a web page. For example, http: //cs. ubc. ca/∼poole/foaf. rdf#david denotes the individual david referred to in http: //cs. ubc. ca/∼poole/foaf. rdf. Jan Pettersen Nytun, UIA, page 22
![S P O References [1] Book: David Poole and Alan Mackworth, Artificial Intelligence: Foundations S P O References [1] Book: David Poole and Alan Mackworth, Artificial Intelligence: Foundations](http://slidetodoc.com/presentation_image_h2/1a63dc9f7c1c1e35a04659883117d318/image-23.jpg)
S P O References [1] Book: David Poole and Alan Mackworth, Artificial Intelligence: Foundations of Computational Agents, Cambridge University Press, 2010, http: //artint. info/ Jan Pettersen Nytun, UIA, page 23
- Slides: 23