You perform this task when you have to specify conditions based on which the messages are routed to a receiver or an interface during runtime. If the message contains XML payload, you form expressions using the XPath-supported operators. If the message contains non-XML payload, you form expressions using the operators shown in the table below:
Usage of Operators in Non-XML Conditions
OperatorExample
=${header.SenderId} = '1'
!=${header.SenderId} != '1'
>${header.SenderId} > '1'
>=${header.SenderId} >= '1'
<${header.SenderId} < '1'
<=${header.SenderId} <= '1'
and${header.SenderId}= '1' and ${header.ReceiverId} = '2'
or${header.SenderId}= '1' or ${header.ReceiverId}= '2'
contains${header.SenderId} contains '1'
not contains${header.SenderId} not contains '1'
in${header.SenderId} in '1,2'
not in${header.SenderId} not in '1,2'
regex${header.SenderId} regex '1.*'
not regex${header.SenderId} not regex '1.*'
XPath Examples
Article
5 minutes to read
This topic reviews the syntax examples that appear throughout the XPath Reference. All are based on the Sample XML File for XPath Syntax (inventory.xml). For an example of using an XPath expression in a test file, see "Example of Unions ( | )", at the bottom of this topic.
Expression
Refers to
./author
All <author> elements within the current context. Note that this is equivalent to the expression in the next row.
author
All <author> elements within the current context.
first.name
All <first.name> elements within the current context.
/bookstore
The document element (<bookstore>) of this document.
//author
All <author> elements in the document.
book[/bookstore/@specialty=@style]
All <book> elements whose style attribute value is equal to the specialty attribute value of the <bookstore> element at the root of the document.
author/first-name
All <first-name> elements that are children of an <author> element.
bookstore//title
All <title> elements one or more levels deep in the <bookstore> element (arbitrary descendants). Note that this is different from the expression in the next row.
bookstore/*/title
All <title> elements that are grandchildren of <bookstore> elements.
bookstore//book/excerpt//emph
All <emph> elements anywhere inside <excerpt> children of <book> elements, anywhere inside the <bookstore> element.
.//title
All <title> elements one or more levels deep in the current context. Note that this situation is essentially the only one in which the period notation is required.
author/*
All elements that are the children of <author> elements.
book/*/last-name
All <last-name> elements that are grandchildren of <book> elements.
*/*
All grandchildren elements of the current context.
*[@specialty]
All elements with the specialty attribute.
@style
The style attribute of the current context.
price/@exchange
The exchange attribute on <price> elements within the current context.
price/@exchange/total
Returns an empty node set, because attributes do not contain element children. This expression is allowed by the XML Path Language (XPath) grammar, but is not strictly valid.
book[@style]
All <book> elements with style attributes, of the current context.
book/@style
The style attribute for all <book> elements of the current context.
@*
All attributes of the current element context.
./first-name
All <first-name> elements in the current context node. Note that this is equivalent to the expression in the next row.
first-name
All <first-name> elements in the current context node.
author[1]
The first <author> element in the current context node.
author[first-name][3]
The third <author> element that has a <first-name> child.
my:book
The <book> element from the my namespace.
my:*
All elements from the my namespace.
@my:*
All attributes from the my namespace (this does not include unqualified attributes on elements from the my namespace).
Note that indexes are relative to the parent. Consider the following data:
<x>
<y/>
<y/>
</x>
<x>
<y/>
<y/>
</x>
Expression
Refers to
x/y[1]
The first <y> child of each <x>. This is equivalent to the expression in the next row.
x/y[position() = 1]
The first <y> child of each <x>.
(x/y)[1]
The first <y> from the entire set of <y> children of <x> elements.
x[1]/y[2]
The second <y> child of the first <x>.
The remaining examples refer to the Sample XML file for XPath.
Expression
Refers to
book[last()]
The last <book> element of the current context node.
book/author[last()]
The last <author> child of each <book> element of the current context node.
(book/author)[last()]
The last <author> element from the entire set of <author> children of <book> elements of the current context node.
book[excerpt]
All <book> elements that contain at least one <excerpt> element child.
book[excerpt]/title
All <title> elements that are children of <book> elements that also contain at least one <excerpt> element child.
book[excerpt]/author[degree]
All <author> elements that contain at least one <degree> element child, and that are children of <book> elements that also contain at least one <excerpt> element.
book[author/degree]
All <book> elements that contain <author> children that in turn contain at least one <degree> child.
author[degree][award]
All <author> elements that contain at least one <degree> element child and at least one <award> element child.
author[degree and award]
All <author> elements that contain at least one <degree> element child and at least one <award> element child.
author[(degree or award) and publication]
All <author> elements that contain at least one <degree> or <award> and at least one <publication> as the children
author[degree and not(publication)]
All <author> elements that contain at least one <degree> element child and that contain no <publication> element children.
author[not(degree or award) and publication]
All <author> elements that contain at least one <publication> element child and contain neither <degree> nor <award> element children.
author[last-name = "Bob"]
All <author> elements that contain at least one <last-name> element child with the value Bob.
author[last-name[1] = "Bob"]
All <author> elements where the first <last-name> child element has the value Bob. Note that this is equivalent to the expression in the next row.
author[last-name [position()=1]= "Bob"]
All <author> elements where the first <last-name> child element has the value Bob.
degree[@from != "Harvard"]
All <degree> elements where the from attribute is not equal to "Harvard".
author[. = "Matthew Bob"]
All <author> elements whose value is Matthew Bob.
author[last-name = "Bob" and ../price > 50]
All <author> elements that contain a <last-name> child element whose value is Bob, and a <price> sibling element whose value is greater than 50.
book[position() <= 3]
The first three books (1, 2, 3).
author[not(last-name = "Bob")]
All <author> elements that do no contain <last-name> child elements with the value Bob.
author[first-name = "Bob"]
All <author> elements that have at least one <first-name> child with the value Bob.
author[* = "Bob"]
all author elements containing any child element whose value is Bob.
author[last-name = "Bob" and first-name = "Joe"]
All <author> elements that has a <last-name> child element with the value Bob and a <first-name> child element with the value Joe.
price[@intl = "Canada"]
All <price> elements in the context node which have an intl attribute equal to "Canada".
degree[position() < 3]
The first two <degree> elements that are children of the context node.
p/text()[2]
The second text node in each <p> element in the context node.
ancestor::book[1]
The nearest <book> ancestor of the context node.
ancestor::book[author][1]
The nearest <book> ancestor of the context node and this <book> element has an <author> element as its child.
ancestor::author[parent::book][1]
The nearest <author> ancestor in the current context and this <author> element is a child of a <book> element.
శ్రీకృష్ణుడు దేవుడా, భగవంతుడా. నేటి ప్రజలందరికి తెలిసిన ప్రకారము దేవుడనినా, భగవంతుడనినా రెండు ఒకటే అను భావముతో ఉన్నారు. చాలామంది స్వామీజీలు కూడ తమ తమ ఉపన్యాసములలో సృష్టికర్త అయిన పరమాత్మను గురించి తెలుపునపుడు ఒకప్పుడు దేవుడని, మరొకప్పుడు భగవంతుడని పలుకుచు చెప్పుచుందురు. దీనినిబట్టి ఇటు ప్రజల దృష్టిలోను, అటు బోధకులైన స్వామీజీల దృష్టిలోను దేవునికీ, భగవంతునికీ ఏమీ తేడా లేదనీ, అందువలన వారు ఇలా ఆ పదములను వాడుచున్నారని తెలియుచున్నది. ఆధ్యాత్మిక రంగములో ఇది చాలా ముఖ్యమైన విషయం అందరికి అవసరమైన విషయము. కావున దేవుడు మరియు భగవంతుడు అను పదములకు శాస్త్రీయత ఉందా? లేదా? అని యోచించవలసిన అవసరమున్నది. అంతేకాక ఒక పనిని చేయుటకు ఒక కారణముంటుంది. అలాగే ఒక పదమును పలుకుటకు కూడ కారణముంటుంది. అటువంటి కారణమునే హేతువు అంటాము. ఇక్కడ 'దేవుడు అనుటకు, భగవంతుడు అనుటకు హేతువును చూపకపోతే అది హేతుబద్దము కాదు. హేతువాదులు ఒప్పుకోరు. నాస్తికవాదులు ఒప్పుకోక పోయినా ఫరవాలేదు. కానీ హేతువాదులు తప్పక ఒప్పుకోవలసియున్నది. ఎక్కడైతే శాస్త్రీయత ఉంటుందో అక్కడ హేతువాదమునకు జవాబు ఉన్నట్లే. ఎక్కడైతే శాస్త్రీయత లేదో అక్కడ హేతువాదమున...
విషయ సూచిక. 1. గురు ప్రార్థనామంజరి 2. గురువు అంటే ఏవరు? 3. గురువును గురించి పెద్దలు ఏమి చెప్పారు? 4. గురువు యొక్క జ్ఞానమును ప్రజలు గుర్తించగలరా? 5. గురువును మనుషులు గౌరవిస్తారా? 6. గురువును దూషించిన వారిని గురువేమి చేయును? 7. గురువు అడవిలో ఉంటాడా లేక ఊరిలో ఉంటాడా? 8. గురువుకు శిష్యులుంటారా? 9. గురువుకు మహత్యములుండునా? 10. గురువుకు రోగాలు వస్తాయా? 11. గురువును ఎవరూ గుర్తించలేరా? 12. గురువు అందరివలె చనిపోవునా? 13. గురుపౌర్ణమి 14. గురువు-పౌర్ణమి 15. గురు 16. గురువులేని విద్య గ్రుడ్డివిద్య 17. గురుప్రార్థన శ్లోకములు -- గురు ప్రార్థనామంజరి. నేటి మానవులను మరియు కేవలము యాభైసంవత్సరముల వెనుకటి కాలపు మానవులను గమనిస్తే, ఇటు ప్రపంచపద్ధతిలోగానీ, అటు పరమాత్మ పద్ధతిలో గానీ ఎంతో గణనీయమైన తేడా కనిపిస్తున్నది. ప్రపంచ పద్ధతిలో చూస్తే ఒక నాగరికతే కాక, మానవుని జీవితములో ఎన్నో పరికరములూ, యంత్రములూ చోటు చేసుకొని మానవుని జీవితము సుఖవంతమైనట్లు కనిపిస్తున్నది. ఉన్నతమైన చదువులూ, అధునాతన యంత్రములూ, వేగవంతమైన వాహనములూ, సరిక్రొత్త పరిశోధనలు, ఖండాతర మారణా యుధములూ మనిషి జీవితములో ఎంతో ఉన...
దయ్యాల కోన అది ఒక భయంకరమైన అడవి. ఎత్తయిన చెట్లు, చిక్కుగ అల్లుకొనిన తీగలు, గుడ్లగూబలకు నిలయమైన మర్రిమాన్లు, భయంకర సర్పములకు నిలయమైన పొదలుకల్గి ఎటువైపు నరసంచారములేని అడవి మధ్యభాగములో పురాతన దేవాలయము ఒకటి కలదు. అది ఈశ్వర దేవాలయమైనప్పటికి అక్కడ పూజారిలేడు, పూజలు జరుగవు. కాని శివరాత్రి రోజు మాత్రము అక్కడికి జనముచేరి పూజలు చేయుట ఆనవాయితీగ కలదు. ఆ ఒక్క దినము తప్ప మానవ సంచారము ఆ అడవిలో ఉండెడిది కాదు. సంవత్సరమునకు ఒక రోజు పూజ జరుగు ఆ దేవాలయమునకు ఆ ఒక దినము లక్షల సంఖ్యలో మనుషులు వస్తారు కావున అందరి సౌకర్యార్థము దేవాలయము వరకు అడవిలో తారు రోడ్డును ప్రభుత్వమువారు నిర్మించారు. సంవత్సరమునకు ఒకమారు ఆ రోడ్డు వెంట మనుషులు ప్రయాణించెడివారు. అడవి ప్రారంభ మొదటి భాగమునుండి మధ్యలోగల దేవాలయమునకు అరవైమైళ్ల దూరము ఉండెడిది. అడవి మొదటి భాగములో రోడ్డు మీద పోలీస్ చెకో పోస్టు కూడ ఉండెడిది. శివరాత్రి రోజు కాకుండ విడి దినములలో ఆ రోడ్డు మీద ఎవరు ప్రయాణించకుండ పోలీస్ వారు చూచుకొనెడివారు. అడవిలో కౄరమృగములు సహితము విచ్చలవిడిగ ఉండుట వలన వాటి రక్షణ నిమిత్తము కూడ పోలీస్ వారుండెడివారు. శివరాత్రి రోజు తప్ప రోడ్డు వెంబడి...