5
• Namespace information are represented as namespace node which maps in scope on an element • Attach to every element node where namespace is declared root comment element namespace text element namespace text element

Namespace information are represented as namespace node which maps in scope on an element Attach to every element node where namespace is declared root

Embed Size (px)

Citation preview

Page 1: Namespace information are represented as namespace node which maps in scope on an element Attach to every element node where namespace is declared root

• Namespace information are represented as namespace node which maps in scope on an element

• Attach to every element node where namespace is declared

root

comment element

namespace text element

namespace text element

Page 2: Namespace information are represented as namespace node which maps in scope on an element Attach to every element node where namespace is declared root

//title[@lang="de"]

/descendant-or-self::book[last()]

//node() or //*

//book[price>30]

<?xml version="1.0" encoding="ISO-8859-1"?><bookstore>

<book category="COOKING"><title lang="de">Everyday Italian</title><author>Giada De Laurentiis</author><year>2005</year><price>30.00</price>

</book><book category="CHILDREN">

<title lang="en">Harry Potter</title><author>J K. Rowling</author><year>2005</year><price>29.99</price>

</book><book category="WEB">

<title lang="en">XQuery Kick Start</title><author>James McGovern</author><author>Per Bothner</author><author>Kurt Cagle</author><author>James Linn</author><author>Vaidyanathan Nagarajan</author><year>2003</year><price>49.99</price>

</book><book category="WEB">

<title lang="en">Learning XML</title><author>Erik T. Ray</author><year>2003</year><price>39.95</price>

</book></bookstore>

Page 3: Namespace information are represented as namespace node which maps in scope on an element Attach to every element node where namespace is declared root

//author[../title[contains(string(.),"XML")]]

//title[contains(string(.),"XML")]/parent::node()/child::author

Page 4: Namespace information are represented as namespace node which maps in scope on an element Attach to every element node where namespace is declared root

for $x in //book return if(contains(string($x/title),"XML"))then (replace($x/title, "XML", "Extensible Markup Language"))elseupper-case($x/title)

for $x in //book returnif( $x/price >= 35.00)then (replace( string($x/price), string($x/price), 40 cast as xs:string))else$x/price

XPath variable are “read-only” and cannot be modified

for $x in //booklet $y:=$x/pricereturn if( $y >= 35.00)then ($y=40.00)else$x/price

Page 5: Namespace information are represented as namespace node which maps in scope on an element Attach to every element node where namespace is declared root

<?xml version="1.0" encoding="UTF-8"?><class name="input">

<description>This class handles input</description><function name="text">

<argument type="string"/><return type="int"/>

</function><function name="number">

<argument type="string"/></function>

</class>

Expression Result

count( //* ) 7

count( //@* ) 6

count( //argument ) 2

count( //class ) 1

count( //function ) 2

count( //description ) 1

count( //return ) 1

count( //text() ) 1

count( //function/return ) 1

count( //function/argument )

2

count( //class/* ) 3

count( //description/* ) 0

//class/description {"This class handles input"}

//@name {"input", "text", "number"}

//@type {"string", "int", "string"}

//return/@type {"int"}

//argument/@type {"string", "string"}

boolean( //function/@name )

true

boolean( //class/@name ) true