Download presentation
Presentation is loading. Please wait.
Published byMavis Cain Modified over 6 years ago
1
Knowledge Representation Part IV The Semantics Web Starting with XML
Jan Pettersen Nytun, UiA
2
The Semantic Web A W3C 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. One web-address identifies one page (also bookmarks…)
3
Some of the W3C hold Specifications
HTML OWL RDF SOAP SPARQL SVG XHTML XML XPath … XPath, the XML Path Language, is a query language for selecting nodes from an XML document. In addition, XPath may be used to compute values (e.g., strings, numbers, or Boolean values) from the content of an XML document.
4
The Semantic Web Language Stack
Hierarchy of languages, where each layer exploits and uses capabilities of the layers below. / XML Schema
5
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.
6
EXtensible Markup Language (XML)
/ XML Schema
7
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.
8
XML Syntax in Well-formed Documents
The document must have exactly one root element. The following is a well-formed XML document: <journal>This is a journal. </journal> The basic syntax for one element is: <name attribute="value“…>content</name> The following is also correct syntax: <journal txt=“This is a journal.” /> start-tag content end-tag
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: 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>
10
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.
11
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=“ xmlns:f=" <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> Xmlns is by definition bound to the namespace name which is an URI (URL)). It also gives shorter and more readable documents.
12
XML - UML Medical System UML Model <medicalsystem>
:Journal :JournalRecord name=“Ola” SSN=“1” description=“May be a little bit fat?” * Journal JournalRecord 1 :Journal :JournalRecord name:String SSN:String description:String name=“Kari” SSN=“2” description=“Lack of iron.” :JournalRecord 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>
13
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.
14
What is meant with the following statement: “XML is Syntax”
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… XM does not have semantics like Java,… It is more like a way of structuring data, e.g., does not say anything about reasoning, execution, etc.
15
XML “is Syntax” Custom tags like <musician>, and <record> can make XML documents at least partly self-described to humans. But what is meant by a tag, e.g., <musician>, is not given (the term “musician” is used but not explained).
16
From Wikipedia: 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> <journalrecord>A slight attack of shopomania? </journalrecord> </journal> </medicalsystem> DirectedTree Why tree? 0..1 0..1 topRoot 1 root Node child * edge
17
Where did the end-tags go? What about the order of things?
<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 name id journalrecord name id journalrecord journalrecord Why tree? “Ola Norman" “1" “Kari Norman" “2" “Lack of iron." “May be a little overweight " “A slight attack of shopomania?" Where did the end-tags go? What about the order of things?
18
Building blocks for defining an XML document (Using UML)
Element Attribute Text content Each XML document consists of nodes (in the model represented by Node class) and each node can contain either attributes (represented by Attribute class) or nested nodes. Both attribute and node have name (this and the Contains association are the reasons why there is a root abstract class named Element), in addition attribute has a value. Contains association expressing the fact that a node can contain both attributes and nodes is ordered on the elements end – this is because order of nodes is significant in XML. Text nodes are represented by a separate subclass of Node named TextNode. As each XML document consists of exactly one root node, it is convenient to define a separate subclass of Node class called RootNode for representing a root node in a document. This class also represents the document itself – it contains an additional attribute documentName. Node * Building blocks for defining an XML document (Using UML) name : String 0..1 Element Attribute container textContent : String value : String (A bit simplified)
19
An XML Schema functioning as model
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> Each XML document consists of nodes (in the model represented by Node class) and each node can contain either attributes (represented by Attribute class) or nested nodes. Both attribute and node have name (this and the Contains association are the reasons why there is a root abstract class named Element), in addition attribute has a value. Contains association expressing the fact that a node can contain both attributes and nodes is ordered on the elements end – this is because order of nodes is significant in XML. Text nodes are represented by a separate subclass of Node named TextNode. As each XML document consists of exactly one root node, it is convenient to define a separate subclass of Node class called RootNode for representing a root node in a document. This class also represents the document itself – it contains an additional attribute documentName. XML document (= instance of some XML schema)): <?xml version=1.0” …> … <Building name=“BlueBox" area = 300/> …..
20
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).
21
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…
22
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, denotes the individual david referred to in
23
References [1] Book: David Poole and Alan Mackworth, Artificial Intelligence: Foundations of Computational Agents, Cambridge University Press, 2010,
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.