INFS 797 DB Programming for the WEB - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

INFS 797 DB Programming for the WEB

Description:

Child::AAA select all AAA children. Ancestor:: AAA select all AAA ancestors ... element(s) which must be the 2nd child of its parent and its ancestors do not ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 13
Provided by: classw
Category:
Tags: infs | web | child | programming

less

Transcript and Presenter's Notes

Title: INFS 797 DB Programming for the WEB


1
INFS 797DB Programming for the WEB
  • Professor Alex Brodsky
  • GMU

2
XML Pattern Matching with XPath
  • XML Tree structure
  • Much like a file directory
  • Task
  • Starting from a node
  • Selection of (other) nodes in the tree
  • Use Path Expressions
  • XPath
  • According to W3C, XPath is a language for
    addressing parts of an XML document

3
XPath Details
  • Location Steps
  • Axis specifier
  • Node test
  • Predicates
  • Location Paths
  • Optional /
  • Followed by zero or more location steps,
    separated by /

4
Axis
  • Ancestor
  • Ancestor-or-self
  • Attribute
  • Child
  • Descendant
  • Descendant-or-self
  • Following
  • Following-sibling
  • Namespace
  • Parent
  • Preceding
  • Preceding-sibling
  • Self

Three types of nodes in the tree Elements,
Attributes, Namespace
5
Example
  • Ancestor
  • Ancestor-or-self
  • Attribute
  • Child
  • Descendant
  • Descendant-or-self
  • Following
  • Following-sibling
  • Namespace
  • Parent
  • Preceding
  • Preceding-sibling
  • Self

6
Axis Node Test
  • Self select self
  • SelfAAA select self if its AAA
  • ChildAAA select all AAA children
  • Ancestor AAA select all AAA ancestors
  • Selfnode() select self if its a node
  • Selfcomment() select self if its comment
  • AttributeAAA select Attributes AAA

7
Axis Node Test Predicates
  • ChildAAAposition()1
  • Select first AAA child
  • ChildAAAposition()last()
  • Select the last AAA child
  • Selfnode()
  • Select self if its a node (same as selfnode())
  • Selfcount(Ancestor)gt2
  • Select self if its 3 or more levels down from
    the root.

8
Union
  • Connected with
  • Example
  • Ancestor Self

9
Example Location Paths
  • Location Path
  • Optional / zero or more location steps
    separated by /
  • Examples
  • childAAA/childBBB
  • ancestorcount(ancestor)lt1
  • Find the root!!
  • /childAAAposition()1
  • The first AAA child of the root

10
Abbreviations for Axes
  • (nothing) child
  • / document root
  • _at_ attribute
  • // /descendant-or-selfnode()/
  • . Selfnode()
  • .. Parentnode()
  • Examples
  • AAA childAAA
  • /AAA start from the root childAAA
  • //AAA all AAA descendants of root
  • //AAA/./../. all AAA descendants of root

11
Node-Sets etc
  • Node sets
  • (union)
  • expr
  • Functions
  • Last(), position(), count(), starts-with(), etc
    etc.
  • Boolean
  • And, or, gt, lt, etc.

12
One More Example
  • Find the AAA element(s) which must be the 2nd
    child of its parent and its ancestors do not
    include an element with attribute B.
  • //AAAcount(preceding-sibling)1 and
  • count(ancestors_at_B)0
Write a Comment
User Comments (0)
About PowerShow.com