M.Sc. of Advanced Software Engineering - PowerPoint PPT Presentation

About This Presentation
Title:

M.Sc. of Advanced Software Engineering

Description:

... asp?url=/library/en-us/xmlsdk/html/1431789e-c545-4765-8c09-3057e07d3041.asp ... Mailto:rmc20_at_le.ac.uk. Office G3 (Usually I am there) Dr. El-Ramly is ... – PowerPoint PPT presentation

Number of Views:14
Avg rating:3.0/5.0
Slides: 13
Provided by: csL88
Category:

less

Transcript and Presenter's Notes

Title: M.Sc. of Advanced Software Engineering


1
  • M.Sc. of Advanced Software Engineering CO7206Sy
    stem Reengineering XPath
  • Many Slides are by Georgios Koutsoukos

2
Objectives
  • To give some knowledge about core technologies
    used in CARE
  • This lecture covers
  • XPath

3
Outline
  • XPath basics
  • XPath axes
  • XPath examples

4
Useful links
  • Useful links
  • http//www.w3schools.com/xpath/default.asp
  • http//msdn.microsoft.com/library/default.asp?url
    /library/en-us/xmlsdk/html/1431789e-c545-4765-8c09
    -3057e07d3041.asp
  • http//www.mulberrytech.com/quickref/XSLTquickref.
    pdf

5
XPath Basics (1)
  • XPath is a language for specifying parts of an
    XML document
  • XPath uses path expressions to identify XML
    document parts. When evaluated, the expression
    returns an object that can be of type node-set (a
    group of nodes of the XML document tree
    structure), boolean, number, or string.
    Expressions are evaluated within a context.

6
XPath Basics (2)
  • A path expression is typically constructed from
    steps, which include
  • an axis, specifying the tree relationships
    between the nodes
  • a node test, specifying the name of the selected
    nodes and
  • zero or more predicates, which refine the set of
    nodes selected.
  • For example, in the expression
  • childpetattributeType"dog" child
    specifies the axis, pet the node test and ...
    the predicate. Abbreviated syntax is also
    used, for instance "_at_Type" instead of
    "attributeType", "/pet" instead of "childpet"
    (and others).

7
XPath Basics (3)
  • XPath also inludes a library of standard
    functions for node-sets, strings, boolean and
    numbers.
  • L-CARE provides an, extension to XPath, set of
    functions, for performing various operations. For
    instance
  • boolean cmpIgnoreCase(String s1, String s2) for
    case-insensitive string comparison.
  • int startLine(Node node) for getting the line
    where a statement represented by XML "Node"
    begins
  • int sizeInLines(Node n) for getting the size in
    lines of code of a statement represented by XML
    "Node"

8
XPath axes
  • The axes in XPath are shown in the picture below
    (attributes and namespaces are not shown).

9
XPath examples (1)
  • The following XML document example is the one
    used on the introduction to XML.
  • lt?xml version"1.0" encoding"iso-8859-1"?gt
    ltpetsgt ltpet type"dog" color"brown"gtMaxlt/petgt
    ltpet type"cat" color"white"gtToulalt/petgt
    lt/petsgt
  • We will now demonstrate some very simple XPath
    examples using that document.

10
XPath examples (2)
  • Select all pet elements
  • //pet or alternatively /pets/pet or
    /pets/child
  • Select the first pet
  • /pets/pet1
  • Select all pets of type dog
  • //pet_at_type "dog"
  • Select all pets of white color
  • //pet_at_color"white"
  • Select the color of all dogs
  • //pet_at_type "dog"/_at_color
  • Get the types of pets with the name Max
  • /pets/pettext()"Max"/_at_type

11
Key Points
  • XPath is an efective and powerful way of query
    XML documents.
  • At this point you should have a basic idea about
    what XML and XPath is all about.
  • It is VERY IMPORTANT that BEFORE next weeks
    tutorial on L-CARE you feel quite confortable
    using XPath, so PLEASE take a couple of hours on
    your own practicing it.

12
Contacts
  • Mailtormc20_at_le.ac.uk
  • Office G3 (Usually I am there)
  • Dr. El-Ramly is pleased to help
Write a Comment
User Comments (0)
About PowerShow.com