+ All Categories
Home > Documents > XML Technology in E-Commerce

XML Technology in E-Commerce

Date post: 07-Jan-2016
Category:
Upload: yitro
View: 20 times
Download: 1 times
Share this document with a friend
Description:
XML Technology in E-Commerce. Lecture 5 XPath, XLink. Course Announcements. Examination XTEC 2000/2001. The list for registration is available at INF room 5047 (Joke Lammerink). Lecture on June 12 will be in CC3. - PowerPoint PPT Presentation
37
Sheet 1 XML Technology in E-Commerce 2001 Lecture 5 XML Technology in E- Commerce Lecture 5 XPath, XLink
Transcript
Page 1: XML Technology in E-Commerce

Sheet 1XML Technology in E-Commerce 2001 Lecture 5

XML Technology in E-Commerce

Lecture 5

XPath, XLink

Page 2: XML Technology in E-Commerce

Sheet 2XML Technology in E-Commerce 2001 Lecture 5

Course Announcements

Deadline EventMay 28, 9:00 Submit topic for the essay (per

email)May 29, 17:00 Register for presentationJune 12, 17:00 Register for the examination in

June 26 and 28and July 3 and 5

August 13, 9:00 Submit topic for the essay (peremail)

August 14, 17:00 Register for the examination inAugust 21 and 23

Examination XTEC 2000/2001

The list for registration is available at INF room 5047 (Joke Lammerink).Lecture on June 12 will be in CC3.Additional information can be found in Announcements at URL: http://trese.cs.utwente.nl/courses/xtec

Page 3: XML Technology in E-Commerce

Sheet 3XML Technology in E-Commerce 2001 Lecture 5

• XPath– Purpose;

– Data Model;

– Location Path Syntax;

– Location Path Evaluation and Examples;

• XLink– HTML Links;

– Requirements for Linking;

– Extended Link Model;

– XML representation;

– Simple Links;

Lecture Outline

Page 4: XML Technology in E-Commerce

Sheet 4XML Technology in E-Commerce 2001 Lecture 5

XML

XML Namespaces

XPath

XPointerXSLT

XLink

XML Schema

XML Languages

Parser

DOMSAX

Software Application

Overview

Page 5: XML Technology in E-Commerce

Sheet 5XML Technology in E-Commerce 2001 Lecture 5

XPathPurpose

• Specifies string-based, non-XML language for expressions;

• Addresses parts in XML documents;• Provides functions for manipulation of strings,

numbers and booleans;

Specification address - http://www.w3.org/TR/xpath (Recommendation since 16 November 1999)

Page 6: XML Technology in E-Commerce

Sheet 6XML Technology in E-Commerce 2001 Lecture 5

XPathApplications

• Specification of patterns of nodes in XML documents (used in XSLT templates);

• Specification of points (addresses) in XML documents used as anchors for links (XPointer and XLink);

• Querying and extracting parts of XML documents;• XPath expressions can be values of XML

attributes;• XPath expressions can be a part of URIs;

Page 7: XML Technology in E-Commerce

Sheet 7XML Technology in E-Commerce 2001 Lecture 5

Data Model• XML document is modeled as a tree of nodes;• Node types:

– root nodes;

– element nodes;

– text nodes;

– attribute nodes;

– namespace nodes;

– processing instruction nodes;

– comment nodes;

• Nodes are ordered;• Examples - Deitel 11.2, fig. 11.2, page 300;

Page 8: XML Technology in E-Commerce

Sheet 8XML Technology in E-Commerce 2001 Lecture 5

XPathExample

• Simple DTD:<!ELEMENT book (title, chapter*) >

<!ELEMENT chapter (title, section*) >

<!ELEMENT section (section | para)* >

• Example XPath expression that selects element nodes:

child::chapter/descendant::para

Selects all paragraphs contained in the chapters of the book (provided that the book is the context node)

Page 9: XML Technology in E-Commerce

Sheet 9XML Technology in E-Commerce 2001 Lecture 5

Expressions• Expressions are the primary syntactic construct in

XPath;• Expression evaluation yields object of one of the

following types:– node set;

– boolean;

– number;

– string;

• Location path - expression that selects a set of nodes. The result is a node set;

Page 10: XML Technology in E-Commerce

Sheet 10XML Technology in E-Commerce 2001 Lecture 5

Location path• Example:

child::chapter/descendant::para

• Evaluation is always made against a particular context node.

• The example selects all paragraph elements that have ancestor among the chapter children of the context node:

chapter chapter

parapara

para

para

…….

Context node

Page 11: XML Technology in E-Commerce

Sheet 11XML Technology in E-Commerce 2001 Lecture 5

Location Path Syntax

child::chapter / descendant::para

Location step Location step

child :: para [position()=1]

Location path:

Location step:

Axis Node test Predicates

• Axis: specifies the tree relationship between the context node and the nodes that will be selected by the step;

• Node test: specifies the node type to be selected;

• Predicate: refines the selection;

Page 12: XML Technology in E-Commerce

Sheet 12XML Technology in E-Commerce 2001 Lecture 5

Axes• Axes:

– self;

– parent;

– child;

– ancestor;

– ancestor-or-self;

– descendant;

– descendant-or-self;

– following-sibling;

– preceding-sibling;

– following;

– preceding;

– attribute;

– namespace;

• Axis can be forward or reverse axis. See Deitel 11.3.1, fig. 11.6, page 305.

Page 13: XML Technology in E-Commerce

Sheet 13XML Technology in E-Commerce 2001 Lecture 5

child

descendant

self

descendant-or-self

parent

ancestorancestor-or-self

Axes

Page 14: XML Technology in E-Commerce

Sheet 14XML Technology in E-Commerce 2001 Lecture 5

following-siblingpreceding-sibling

precedingfollowing

Axes

Page 15: XML Technology in E-Commerce

Sheet 15XML Technology in E-Commerce 2001 Lecture 5

Node Tests• Axes have principal node type:

– Attribute type for attribute axis;

– Namespace type for namespace axis;

– Element type for others;

• Node tests:– * - true for any node of the principal node type;

– node() - true for any node of any type;

– text() - true for any text node;

– comment();

– processing-instruction();

– node name, e.g. chapter;

Page 16: XML Technology in E-Commerce

Sheet 16XML Technology in E-Commerce 2001 Lecture 5

Predicates

• Predicates refine the selected node set in a location step;

• Predicates are evaluated sequentially from left to right;

• Predicates always result in true or false;

• Examples:– para[position()=3], para[3];

– para[last()];

– para[id(id_string)];

– para[attribute::type="warning"];

Page 17: XML Technology in E-Commerce

Sheet 17XML Technology in E-Commerce 2001 Lecture 5

Location Path Evaluation

• The starting point is the context node. It is specified through additional, application specific mechanism;

• For a given location step and given context node a node set is generated by applying axis information, node test and predicates;

• Each node in the resulting node set becomes a context node for the next step. The result is an union of the nodes sets generated for each context node;

• Expression value is the node set generated by the last location step;

Page 18: XML Technology in E-Commerce

Sheet 18XML Technology in E-Commerce 2001 Lecture 5

Location PathAdditional Details

• Absolute and relative location path:– relative: child::chapter/descendant::para;

– absolute: / child::chapter/descendant::para;

• Abbreviated Syntax:– If no axis is specified, child is the default;

– attribute::name = @name;

– self::node() = . (selects the context node);

– parent:: = ..;

– /descendant-or-self::node()/ = //;

– div/descendant-or-self::node()/child::para = div//para;

Page 19: XML Technology in E-Commerce

Sheet 19XML Technology in E-Commerce 2001 Lecture 5

Location PathAbbreviation Syntax Examples

• */para - selects all para grandchildren of the context node;

• //olist/item - selects all item elements that have olist parent element;

• ../@lang - selects the lang attribute of the parent of the context node;

• para[@type="warning"][5] - selects the fifth para child element of the context node that has type attribute with value “warning”;

• para[5] [@type="warning"] - selects the fifth para child of context node if it has attribute type with value “warning”;

Page 20: XML Technology in E-Commerce

Sheet 20XML Technology in E-Commerce 2001 Lecture 5

XPathSummary

• XPath defines syntax for expressions used in other XML specifications (XSLT, XPointer);

• XPath defines a tree-like logical model of XML documents;

• Location paths are expressions that select a set of nodes;

• Software support: MSXML Parser, Apache XML Project,

Read: Deitel 11

Assignment: Deitel Ex 11.3, page 316

Page 21: XML Technology in E-Commerce

Sheet 21XML Technology in E-Commerce 2001 Lecture 5

• XPath– Purpose;

– Data Model;

– Location Path Syntax;

– Location Path Evaluation and Examples;

• XLink– HTML Links;

– Requirements for Linking;

– Extended Link Model;

– XML representation;

– Simple Links;

Lecture Outline

Page 22: XML Technology in E-Commerce

Sheet 22XML Technology in E-Commerce 2001 Lecture 5

Linking

• Linking in the context of WWW:– Link is a relationship between resources;– Resource - any addressable unit of information

or service on the Web;• Examples - HTML pages, images, documents,

programs (services), database queries;

– URIs are used for addressing a resource;– Links are asserted by linking elements;

• Example - hyperlinks in HTML;

Page 23: XML Technology in E-Commerce

Sheet 23XML Technology in E-Commerce 2001 Lecture 5

HTML Links

Web Resource

Web page

• Inline link - the link is embedded in the one end;• Dedicated link element - A element;• Only specific part of the page can be addressed -

marked by <A name=“anchor”/> element;• Links have fixed behavior;• Links have only two ends;

Page 24: XML Technology in E-Commerce

Sheet 24XML Technology in E-Commerce 2001 Lecture 5

Requirements for Linking

• Addressing - any element of an XML document must be addressable. Also, document authors must be able to select single character or portion of text;

• Relationships between more than two resources;• Any element in an XML document must be able to

assert a link;• Attaching external links without resource modification

must be possible (so called third party links);

• Separation of link semantics from link type;• Support for the basic link semantics (inclusion,

expansion);

Page 25: XML Technology in E-Commerce

Sheet 25XML Technology in E-Commerce 2001 Lecture 5

XLink

• Specifies language for link description used in XML documents;

• Satisfies the previously formulated requirements;• Provides support for simple links (similar to

HTML links) and for more sophisticated links;• Depends on other standard for addressing:

XPointer;• Specification address:

http://www.w3.org/TR/2000/PR-xlink-20001220/ (Status: proposed recommendation)

Page 26: XML Technology in E-Commerce

Sheet 26XML Technology in E-Commerce 2001 Lecture 5

XLinkBasic Terms

• XLink link is an explicit relationship between resources;

• The link is made explicit by a linking element;

• Using or following a link is called traversal. It always involves two resources;

• Information about how to traverse a pair of resources is called arc;

• Local resource - the linking element by itself or a child of the linking element;

• Remote resource - addressed by a URI;

Page 27: XML Technology in E-Commerce

Sheet 27XML Technology in E-Commerce 2001 Lecture 5

XLinkMarkup Design

• XLink defines a namespace with URI:

http://www.w3.org/1999/xlink

• The namespace contains the following attributes:– type, href, role, arcrole, title, show, actuate, label,

from, and to;

• XLink defines two kinds of links:– Extended;

– Simple;

Page 28: XML Technology in E-Commerce

Sheet 28XML Technology in E-Commerce 2001 Lecture 5

Extended Link Model

Extended linkLocal resource

Locator to remote

resource

Locator to remote

resource

Locator to remote

resource

Locator to remote

resource

Label=“L1” Label=“L2”

Label=“L3”Label=“L4”

Label=“L5”

Arc

Arc

Page 29: XML Technology in E-Commerce

Sheet 29XML Technology in E-Commerce 2001 Lecture 5

Extended LinkXML Representation

• Example: link that represents the relationship between student, course and student’s grade;

• Representation of the link element:<courseload

xmlns:xlink=“http://www.w3.org/1999/xlink”

xlink:type=“extended”>

...elements for student, course and grade...

…traversal information as arc elements…

</courseload>

Page 30: XML Technology in E-Commerce

Sheet 30XML Technology in E-Commerce 2001 Lecture 5

XML RepresentationExternal Resources

• Student and course information are external resources represented by a locator type element:<student

xlink:type=“locator”

xlink:href=“http://some.site/student007”

xlink:label=“student”/>

<course

xlink:type=“locator”

xlink:href=“http://some.site/course6”

xlink:label=“course” />

Page 31: XML Technology in E-Commerce

Sheet 31XML Technology in E-Commerce 2001 Lecture 5

XML RepresentationLocal Resources

• Grade information is local resource represented by resource type element:

<grade

xlink:type=“resource”

xlink:label=“grade”>5.5</grade>

Page 32: XML Technology in E-Commerce

Sheet 32XML Technology in E-Commerce 2001 Lecture 5

XML RepresentationArcs

• We can specify two arcs: between the student and the course and the student and his grade<arcEl xlink:type=“arc”

xlink:from=“student”

xlink:to=“course”

xlink:title=“partcipates”/>

<arcEl xlink:type=“arc”

xlink:from=“student”

xlink:to=“grade”

xlink:title=“has grade”/>

Page 33: XML Technology in E-Commerce

Sheet 33XML Technology in E-Commerce 2001 Lecture 5

XML RepresentationOther XLink Attributes

• Semantic attributes:– role: can be applied to extended, locator and resource

type elements. It asserts a property that describes the semantics of the resource. The value is URI;

– arcrole: used on arc type elements;

– title: provides human readable information;

<arcEl xlink:type=“arc”

xlink:from=“student”

xlink:to=“grade”

xlink:arcrole=“http://some.site/arcinfo.xml”

xlink:title=“student’s grade”/>

Page 34: XML Technology in E-Commerce

Sheet 34XML Technology in E-Commerce 2001 Lecture 5

Simple Links

• Simple links can be perceived as a special kind of extended link, with some limitations imposed:– associates exactly two resources: one local and one

remote;

– specifies an arc from local to remote resource;

– provides a short syntax for the equivalent extended link;

<student xlink:type=“simple”

xlink:href=“http://some.site.com/student.html”>

John Smith

</student>

Page 35: XML Technology in E-Commerce

Sheet 35XML Technology in E-Commerce 2001 Lecture 5

Behavioral Attributes

• Describe the intended behavior for simple and arc type elements;

• show attribute:– Specifies the desired presentation of the ending

resource; – Values: new, replace, embed, other, none;

• actuate attribute:– Specifies the desired timing of traversal;

– Values: onLoad, onRequest, other, none;

Page 36: XML Technology in E-Commerce

Sheet 36XML Technology in E-Commerce 2001 Lecture 5

XLink and DTDs

• In XLink linking elements are asserted via a set of attributes;

• The syntax is rather verbose, a large set of attributes must be specified;

• DTD can be used to provide default and fixed values for attributes. Attributes can be omitted in instance documents;

• See Deitel 14.3;

Page 37: XML Technology in E-Commerce

Sheet 37XML Technology in E-Commerce 2001 Lecture 5

XLinkSummary

• XLink provides powerful mechanism for links definition in XML documents:

– Multi-ended, third party links with additional meta

information through extended link type;– HTML like links through simple link type

• XLink depends on XPointer as a mechanism for

addressing elements and points in XML documents;

Read: Deitel 14.1-14.3, skip 14.4-14.6

Assignment: Deitel Ex 14.3, page 394. For some hints see the course web site.


Recommended