Jan Pettersen Nytun, UIA, page 1
Knowledge Representation Part IV The Semantics Web
Starting with XML
Jan Pettersen Nytun, UiA
Part IV The Semantics Web Starting with XML Jan Pettersen Nytun, - - PowerPoint PPT Presentation
Knowledge Representation Part IV The Semantics Web Starting with XML Jan Pettersen Nytun, UiA Jan Pettersen Nytun, UIA, page 1 S O P The Semantic Web A W3C recommendation. Common data formats. Allow specification of data
Jan Pettersen Nytun, UIA, page 1
Jan Pettersen Nytun, UiA
S O
P
allows automatic reasoning.
mechanism of the web.
Jan Pettersen Nytun, UIA, page 2
S O
P
Jan Pettersen Nytun, UIA, page 3
– HTML – OWL – RDF – SOAP – SPARQL – SVG – XHTML – XML – XPath – …
S O
P
Jan Pettersen Nytun, UIA, page 4
Hierarchy of languages, where each layer exploits and uses capabilities of the layers below.
/ XML Schema
S O
P
– E.g., XML Schema can define an element type (~ class) with help of XML syntax.
– E.g., XML Schema limits XML.
– E.g., RDF Schema (RDFS) extends XML Schema with a richer vocabulary.
Jan Pettersen Nytun, UIA, page 5
S O
P
Jan Pettersen Nytun, UIA, page 6
/ XML Schema
Jan Pettersen Nytun, UIA, page 7
meant for human readable web pages!
hence, users can define their own custom element and attribute names.
S O
P
Jan Pettersen Nytun, UIA, page 8
formed XML document: <journal>This is a journal. </journal>
<name attribute="value“…>content</name>
<journal txt=“This is a journal.” />
start-tag end-tag content
S O
P
Jan Pettersen Nytun, UIA , page 9
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: <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>
Attribute Start-tag and end-tag of element medicalsystem
S O
P
Gives unique names to elements and attributes. xmlns can be used to solve name conflicts inside
a data structure.
Jan Pettersen Nytun, UIA, page 10
S O
P
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.w3.org/TR/html4/” xmlns:f="http://www.w3schools.com/furniture"> <h:table> …. </h:table> <f: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 O
P
Jan Pettersen Nytun, UIA, page 12
<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>
Journal JournalRecord
name:String SSN:String description:String
:Journal :JournalRecord name=“Ola” SSN=“1” description=“May be a little bit fat?” :Journal :JournalRecord name=“Kari” SSN=“2” description=“Lack of iron.” :JournalRecord description=“A slight attack of shopomania?”
Medical System UML Model
Data 1 *
S O
P
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, UiA, page 13
Syntax: …the rules about how words are arranged and connected to make phrases and sentences…
Jan Pettersen Nytun, UIA, page 14
S O
P
make XML documents at least partly self- described to humans.
not given (the term “musician” is used but not explained).
Jan Pettersen Nytun, UIA, page 15
S O
P
Jan Pettersen Nytun, UIA, page 16
From Wikipedia:
XML is a generic framework for storing text or any data whose structure can be represented as 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> <journalrecord>A slight attack of shopomania? </journalrecord> </journal> </medicalsystem>
Node
child * root 1
DirectedTree
0..1 0..1 edge topRoot
Jan Pettersen Nytun, UIA, page 17
<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 journal journalrecord journalrecord journalrecord name “Ola Norman" id “1" name “Kari Norman" id “2" “May be a little overweight " “Lack of iron." “A slight attack of shopomania?"
Where did the end-tags go? What about the order of things?
S O
P Node name : String Attribute Element value : String * 0..1 container
Building blocks for defining an XML document
(Using UML) Attribute Element Text (A bit simplified)
textContent : String content
Example (simplified):
<xsd:schema …. > <xsd:element name = “Building” type = “BuildingType”/> <xsd:complexType name=" BuildingType"> <xsd:attribute name=“name" type="xsd:string"/> <xsd:attribute name=“area" type="xsd:integer"/> </xsd:complexType>
XML document (= instance of some XML schema)):
<?xml version=1.0” …> … <Building name=“BlueBox" area = 300/> …..
Jan Pettersen Nytun, UIA, page 19
S O
P
uniquely identify a resource.
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 O
P
Jan Pettersen Nytun, UiA, Ontologies, page 21
From Wikipedia:
S O
P
since they are unique.
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 O
P
Jan Pettersen Nytun, UIA, page 23
[1] Book: David Poole and Alan Mackworth, Artificial Intelligence: Foundations of Computational Agents, Cambridge University Press, 2010, http://artint.info/