1 quick intro to xpath roger l. costello 14 december, 2012
TRANSCRIPT
![Page 1: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/1.jpg)
1
Quick Intro to XPath
Roger L. Costello14 December, 2012
![Page 2: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/2.jpg)
2
Objective
• XML Schema 1.1 uses XPath a lot, so if you don't know XPath then you're at a disadvantage.
• The purpose of this short tutorial is to teach you enough XPath that you won't be at a disadvantage.
![Page 3: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/3.jpg)
3
XPath is not a standalone language
• XPath requires a host language. There are currently several XML languages that host XPath.
![Page 4: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/4.jpg)
4
XPath is not a standalone language
XPath
XSLT
XQuery
XMLSchemas
XPointer
Schematron
![Page 5: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/5.jpg)
5
Document/
PI<?xml version=“1.0”?>
ElementFitnessCenter
ElementMember
ElementMember
ElementMember
ElementName
ElementFavoriteColor
TextJeff
Textlightgrey
ElementName
ElementFavoriteColor
TextDavid
Textlightblue
ElementName
ElementFavoriteColor
TextRoger
Textlightyellow
<?xml version="1.0"?><FitnessCenter> <Member> <Name>Jeff</Name> <FavoriteColor>lightgrey</FavoriteColor> </Member> <Member> <Name>David</Name> <FavoriteColor>lightblue</FavoriteColor> </Member> <Member> <Name>Roger</Name> <FavoriteColor>lightyellow</FavoriteColor> </Member></FitnessCenter>
This XML document can berepresented as a tree, as shown below
![Page 6: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/6.jpg)
6
Terminology - node
Document/
PI<?xml version=“1.0”?>
ElementFitnessCenter
ElementMember
ElementMember
ElementMember
ElementName
ElementFavoriteColor
TextJeff
Textlightgrey
ElementName
ElementFavoriteColor
TextDavid
Textlightblue
ElementName
ElementFavoriteColor
TextRoger
Textlightyellow
Document nodeProcessing Instruction (PI) node
Element nodes
Text nodes
![Page 7: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/7.jpg)
7
Document/
PI<?xml version=“1.0”?>
ElementFitnessCenter
ElementMember
ElementMember
ElementMember
ElementName
ElementFavoriteColor
TextJeff
Textlightgrey
ElementName
ElementFavoriteColor
TextDavid
Textlightblue
ElementName
ElementFavoriteColor
TextRoger
Textlightyellow
With respect to this node, these are its children
![Page 8: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/8.jpg)
8
Document/
PI<?xml version=“1.0”?>
ElementFitnessCenter
ElementMember
ElementMember
ElementMember
ElementName
ElementFavoriteColor
TextJeff
Textlightgrey
ElementName
ElementFavoriteColor
TextDavid
Textlightblue
ElementName
ElementFavoriteColor
TextRoger
Textlightyellow
These are its descendant nodes
![Page 9: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/9.jpg)
9
Document/
PI<?xml version=“1.0”?>
ElementFitnessCenter
ElementMember
ElementMember
ElementMember
ElementName
ElementFavoriteColor
TextJeff
Textlightgrey
ElementName
ElementFavoriteColor
TextDavid
Textlightblue
ElementName
ElementFavoriteColor
TextRoger
Textlightyellow
This is the context node
![Page 10: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/10.jpg)
10
Document/
PI<?xml version=“1.0”?>
ElementFitnessCenter
ElementMember
ElementMember
ElementMember
ElementName
ElementFavoriteColor
TextJeff
Textlightgrey
ElementName
ElementFavoriteColor
TextDavid
Textlightblue
ElementName
ElementFavoriteColor
TextRoger
Textlightyellow
That's its parent
![Page 11: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/11.jpg)
11
Document/
PI<?xml version=“1.0”?>
ElementFitnessCenter
ElementMember
ElementMember
ElementMember
ElementName
ElementFavoriteColor
TextJeff
Textlightgrey
ElementName
ElementFavoriteColor
TextDavid
Textlightblue
ElementName
ElementFavoriteColor
TextRoger
Textlightyellow
Those are its ancestors
![Page 12: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/12.jpg)
12
Document/
PI<?xml version=“1.0”?>
ElementFitnessCenter
ElementMember
ElementMember
ElementMember
ElementName
ElementFavoriteColor
TextJeff
Textlightgrey
ElementName
ElementFavoriteColor
TextDavid
Textlightblue
ElementName
ElementFavoriteColor
TextRoger
Textlightyellow
It has 2 siblings
![Page 13: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/13.jpg)
13
Document/
PI<?xml version=“1.0”?>
ElementFitnessCenter
ElementMember
ElementMember
ElementMember
ElementName
ElementFavoriteColor
TextJeff
Textlightgrey
ElementName
ElementFavoriteColor
TextDavid
Textlightblue
ElementName
ElementFavoriteColor
TextRoger
Textlightyellow
They are following-siblings
![Page 14: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/14.jpg)
14
Document/
PI<?xml version=“1.0”?>
ElementFitnessCenter
ElementMember
ElementMember
ElementMember
ElementName
ElementFavoriteColor
TextJeff
Textlightgrey
ElementName
ElementFavoriteColor
TextDavid
Textlightblue
ElementName
ElementFavoriteColor
TextRoger
Textlightyellow
It has no preceding-siblings
![Page 15: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/15.jpg)
15
Here are the capabilities of XPath
• XPath provides a syntax for: – navigating around an XML document– selecting nodes and values – comparing node values– performing arithmetic on node values
• XPath provides some functions (e.g., concat(), substring(), etc.) to facilitate the above.
![Page 16: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/16.jpg)
16
Document/
PI<?xml version=“1.0”?>
ElementDocument
ElementPara
ElementPara
ElementPara
TextOne if …
TextAnd I …
TextReady to
<?xml version="1.0"?>Document classification="secret"> <Para classification="unclassified"> One if by land, two if by sea; </Para> <Para classification="confidential"> And I on the opposite shore will be, Ready to ride and spread the alarm </Para> <Para classification="unclassified"> Ready to ride and spread the alarm Through every Middlesex, village and farm, </Para></Document>
This XML document can berepresented as a tree, as shown below
Attributeclassification=“secret”
Attributeclassification=“unclassified”
Attributeclassification=“confidential”
Attributeclassification=“unclassified”
See document.xml in the xpathfolder, within the examples folder.
![Page 17: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/17.jpg)
17
Execute XPath using Oxygen XML
Type your XPath expression here
Change this to XPath 1.0
![Page 18: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/18.jpg)
18
Use XPath Builderfor long XPathexpressions
![Page 19: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/19.jpg)
19
Please Run the XPath Expressions
• The following slides contain XPath expressions.
• It's important that you copy the expression on the slide and paste it into Oxygen XML to see what the expression does.
• First, copy the XML document on slide 16, save it to a file, then drag and drop the file into Oxygen XML.
![Page 20: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/20.jpg)
20
Select all Para Elements
/Document/Para
![Page 21: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/21.jpg)
21
/Document/Para
This is an absolute XPath expression
![Page 22: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/22.jpg)
22
Establish a Context Node
Click on this to establish it as the "context node"(any XPath expressions will be relative to it)
![Page 23: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/23.jpg)
23
Relative XPath Expression
In Oxygen XML click on <Document> toestablish the “context node” and then typethis in the XPath box:
Para
![Page 24: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/24.jpg)
24
Select all Para Elements
//Para
descendents
![Page 25: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/25.jpg)
25
Select the first Para
//Para[1]
![Page 26: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/26.jpg)
26
Select the last Para
//Para[last()]
![Page 27: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/27.jpg)
27
Select the classification attribute of the first Para
//Para[1]/@classification
![Page 28: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/28.jpg)
28
Is the Document element’s classification top-secret?
/Document/@classification = 'top-secret'
![Page 29: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/29.jpg)
29
Is the Document element’s classification top-secret or
secret?
(/Document/@classification = 'top-secret') or (/Document/@classification='secret')
![Page 30: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/30.jpg)
30
A or BA and Bnot(A)
Logical Operators
![Page 31: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/31.jpg)
31
Select all Para’s with a secret classification
//Para[@classification = 'secret']
![Page 32: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/32.jpg)
32
Check that no Para has a top-secret classification
not(//Para[@classification = 'top-secret'])
![Page 33: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/33.jpg)
33
Establish a New Context Node
Make the second Para the context node
![Page 34: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/34.jpg)
34
Select the Following Siblings
following-sibling::*
![Page 35: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/35.jpg)
35
Select the FirstFollowing Sibling
following-sibling::*[1]
![Page 36: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/36.jpg)
36
Add Another Element
Add this <Test> element after the last Para
![Page 37: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/37.jpg)
37
Select the Following Para Siblings
following-sibling::Para
![Page 38: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/38.jpg)
38
Select all Following Siblings
following-sibling::*
![Page 39: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/39.jpg)
39
Select all Preceding Siblings
preceding-sibling::*
![Page 40: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/40.jpg)
40
Make Document the Context
Click on Document to make it thecontext node.
![Page 41: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/41.jpg)
41
Equivalent!
Para[1]
child::Para[1]
![Page 42: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/42.jpg)
42
Make Para[2] the context
Establish this as the context node.
![Page 43: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/43.jpg)
43
Get parent element's classification
../@classification
![Page 44: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/44.jpg)
44
Equivalent!
../@classification
parent::*/@classification
![Page 45: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/45.jpg)
45
Axis
following-siblingpreceding-siblingchildparentancestordescendentself
![Page 46: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/46.jpg)
46
Count the number of Para elements
count(//Para)
![Page 47: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/47.jpg)
47
Count the number of Para elements with secret
classification
count(//Para[@classification = 'secret'])
![Page 48: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/48.jpg)
48
Does the first Para element contain the string
“SCRIPT”?
contains(//Para[1], 'SCRIPT')
![Page 49: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/49.jpg)
49
Select all nodes containing the string “SCRIPT”
//node()[contains(., 'SCRIPT')]
The node() function matches on these nodes: - element - text - comment - processing instructions (PIs)Note that it does not match on these nodes: - attribute - document
![Page 50: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/50.jpg)
50
Count the number of nodes containing the
string “SCRIPT”
count(//node()[contains(., 'SCRIPT')])
![Page 51: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/51.jpg)
51
Select the first 20 characters of the first Para
substring(//Para[1], 1, 20)
![Page 52: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/52.jpg)
52
What's the length of the content of the first Para?
string-length(//Para[1])
![Page 53: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/53.jpg)
53
translate(/Document/@classification, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')
Convert Document’s classification to lowercase
![Page 54: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/54.jpg)
54
Add a new <Cost> element
Add this element and establishDocument as the context node.
![Page 55: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/55.jpg)
55
Multiply Cost by 2
Cost * 2
![Page 56: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/56.jpg)
56
N mod X = the remainder of dividing N by X
Cost mod 2
![Page 57: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/57.jpg)
57
Arithmetic Operators
*mod- (leave space on either side)div+
![Page 58: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/58.jpg)
58
Set this to XPath 2.0
![Page 59: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/59.jpg)
59
Does Document’s classification match one in
Classifications.xml?
/Document/@classification = doc('Classifications.xml')/Classifications/li
![Page 60: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/60.jpg)
60
Do the first two Para's have the same classification?
Para[1]/@classification eq Para[2]/@classification
![Page 61: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/61.jpg)
61
eq means equalne means not equallt means less thangt means greater thanle means less than or equal toge means greater than or equal to
Boolean Operators
![Page 62: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/62.jpg)
62
if Document's classification is top-secret then there can be no Para with a classification
not equal to top-secret
if (/Document/@classification eq 'top-secret') then not(//Para[@classification ne 'top-secret']) else true()
![Page 63: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/63.jpg)
63
Two built-in functions
true()
false()
![Page 64: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/64.jpg)
64
Cast a value to a numeric type
number(Cost)
![Page 65: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/65.jpg)
65Check that Document's children are: multiple Para's,
1 Test, and 1 Cost (and nothing else)
Para[2] and Test and Cost and empty(* except (Para, Test[1], Cost[1]))
![Page 66: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/66.jpg)
66
The sum() function
<?xml version="1.0"?><numbers> <number>23</number> <number>5</number> <number>-41</number> <number>50</number> <number>12</number></numbers>
sum(//number) returns 49.0
![Page 67: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/67.jpg)
67
Check that every Publisher has a string-length le 140
<BookStore> <Book> <Title>My Life and Times</Title> <Author>Paul McCartney</Author> <Date>1998</Date> <ISBN>1-56592-235-2</ISBN> <Publisher>McMillin Publishing</Publisher> <Author>John Ghostwriter</Author> </Book> <Book> <Publisher>Dell Publishing Co.</Publisher> <Author>Richard Bach</Author> <Date>1977</Date> <ISBN>0-440-34319-4</ISBN> <Title>Illusions The Adventures of a Reluctant Messiah</Title> </Book> <Book> <ISBN>0-06-064831-7</ISBN> <Title>The First and Last Freedom</Title> <Author>J. Krishnamurti</Author> <Date>1954</Date> <Publisher>Harper & Row</Publisher> </Book></BookStore>
![Page 68: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/68.jpg)
68
Check that every Publisher has a string-length le 140
every $i in //Publisher satisfies string-length($i) le 140
![Page 69: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/69.jpg)
69
The XPath every expression
• The form of the every expression is:every variable in sequence satisfies boolean expression
• The result of the expression is either true or false.
![Page 70: 1 Quick Intro to XPath Roger L. Costello 14 December, 2012](https://reader035.vdocuments.net/reader035/viewer/2022070305/55140190550346ec488b4928/html5/thumbnails/70.jpg)
70
Equivalent
every $i in //Publisher satisfies string-length($i) le 140
not(//Publisher[string-length(.) gt 140])