XML Technology in E-Commerce - PowerPoint PPT Presentation

1 / 37
About This Presentation
Title:

XML Technology in E-Commerce

Description:

type, href, role, arcrole, title, show, actuate, label, from, and to; ... actuate attribute: Specifies the desired timing of traversal; ... – PowerPoint PPT presentation

Number of Views:10
Avg rating:3.0/5.0
Slides: 38
Provided by: treseCs
Category:

less

Transcript and Presenter's Notes

Title: XML Technology in E-Commerce


1
XML Technology in E-Commerce
Lecture 5 XPath, XLink
2
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. Additional information can be
found in Announcements at URL http//trese.cs.utw
ente.nl/courses/xtec
3
Lecture Outline
  • 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

4
Overview
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)

6
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

7
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

8
XPathExample
  • Simple DTD
  • lt!ELEMENT book (title, chapter) gt
  • lt!ELEMENT chapter (title, section) gt
  • lt!ELEMENT section (section para) gt
  • Example XPath expression that selects element
    nodes
  • childchapter/descendantpara
  • Selects all paragraphs contained in the chapters
    of the book (provided that the book is the
    context node)

9
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

10
Location path
  • Example
  • childchapter/descendantpara
  • 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

Context node
.
chapter
chapter
para
para
para
para
11
Location Path Syntax
childchapter / descendantpara
Location path
Location step
Location step
child para position()1
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

12
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.

13
Axes
14
Axes
15
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

16
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
  • paraposition()3, para3
  • paralast()
  • paraid(id_string)
  • paraattributetype"warning"

17
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

18
Location PathAdditional Details
  • Absolute and relative location path
  • relative childchapter/descendantpara
  • absolute / childchapter/descendantpara
  • Abbreviated Syntax
  • If no axis is specified, child is the default
  • attributename _at_name
  • selfnode() . (selects the context node)
  • parent ..
  • /descendant-or-selfnode()/ //
  • div/descendant-or-selfnode()/childpara
    div//para

19
Location PathAbbreviation Syntax Examples
  • /para - selects all para grandchildren of the
    context node
  • //olist/item - selects all item elements that
    have olist parent element
  • ../_at_lang - selects the lang attribute of the
    parent of the context node
  • para_at_type"warning"5 - selects the fifth para
    child element of the context node that has type
    attribute with value warning
  • para5 _at_type"warning" - selects the fifth
    para child of context node if it has attribute
    type with value warning

20
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
21
Lecture Outline
  • 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

22
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

23
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 ltA nameanchor/gt element
  • Links have fixed behavior
  • Links have only two ends

24
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)

25
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)

26
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

27
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

28
Extended Link Model
Arc
Locator to remote resource
Locator to remote resource
LabelL3
LabelL4
Extended link
Local resource
Arc
LabelL5
LabelL1
LabelL2
Locator to remote resource
Locator to remote resource
29
Extended LinkXML Representation
  • Example link that represents the relationship
    between student, course and students grade
  • Representation of the link element
  • ltcourseload
  • xmlnsxlinkhttp//www.w3.org/1999/xlink
  • xlinktypeextendedgt
  • ...elements for student, course and grade...
  • traversal information as arc elements
  • lt/courseloadgt

30
XML RepresentationExternal Resources
  • Student and course information are external
    resources represented by a locator type element
  • ltstudent
  • xlinktypelocator
  • xlinkhrefhttp//some.site/student007
  • xlinklabelstudent/gt
  • ltcourse
  • xlinktypelocator
  • xlinkhrefhttp//some.site/course6
  • xlinklabelcourse /gt

31
XML RepresentationLocal Resources
  • Grade information is local resource represented
    by resource type element
  • ltgrade
  • xlinktyperesource
  • xlinklabelgradegt5.5lt/gradegt

32
XML RepresentationArcs
  • We can specify two arcs between the student and
    the course and the student and his grade
  • ltarcEl xlinktypearc
  • xlinkfromstudent
  • xlinktocourse
  • xlinktitlepartcipates/gt
  • ltarcEl xlinktypearc
  • xlinkfromstudent
  • xlinktograde
  • xlinktitlehas grade/gt

33
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
  • ltarcEl xlinktypearc
  • xlinkfromstudent
  • xlinktograde
  • xlinkarcrolehttp//some.site/arcinfo
    .xml
  • xlinktitlestudents grade/gt

34
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
  • ltstudent xlinktypesimple
  • xlinkhrefhttp//some.site.com/student.h
    tmlgt
  • John Smith
  • lt/studentgt

35
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

36
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

37
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.
Write a Comment
User Comments (0)
About PowerShow.com