Skip to main content
summaryrefslogtreecommitdiffstats
blob: d41430c666560bf50ea716c328c4de2e8a84c3dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2006. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="STYLESHEET" href="../book.css" charset="ISO-8859-1" type="text/css"/>
<title>Essential XPath</title>
</head>
<body>
<h2>Essential XPath</h2>
<p>
JET implements the <a href="http://www.w3.org/TR/xpath">W3C XPath 1.0 Specification</a>, with a few minor exceptions.
Although the XPath language is rich, there are only a small part of the XPath language that is required to use most
JET tags.
</p>
<p>XPath (and JET) assumes that it is working on a model that has a tree structure. While this
certainly include XML documents (the X in XPath), it can include many other kinds of models as well. Out of the box,
JET supports XML documents and any model that is represented by EMF. 
(See <a href="http://www.eclipse.org/emf">Eclipse Modeling Framework</a>).
</p>
<p>A major element of XPath is the <b>path expression</b>. These are similar to file system paths. </p>
<ul>
  <li> An path is a series of <b>steps</b> separated by forward slashes (/).</li>
  <li> The steps are evaluated from left to right, and generally decend the model's tree as they do so. </li>
  <li> Each step generally identifies tree nodes by their name (although other possibilities exist).</li>
  <li> Steps may have an optional filter condition which is written in square brackets ([ and ]) at the end of the step.</li>
  <li> An initial slash (/) indicates an expression starts at the root of the model tree.</li>
  <li> Path expressions can also start with a variable, which is a name preceded by a dollar sign ($). </li>
</ul>
<p>XPath also supports general mathematical, boolean and comparison expressions as well as function calls.</p>
<p>JET tags that use XPath expressions have common characteristics:</p>
<ul>
  <li>Variables are defined by several JET tags - look for a <code>var</code> attribute. They may also be defined by
  the <code><a href="../references/taglibs/controlTags/setVariableTag.html">c:setVariable</a></code> tag.</li>
  <li> JET tags requiring a path expresion have a <code>select</code> attribute.</li>
  <li> JET tags requiring a boolean expression have a <code>test</code>.</li>
  <li> Any tag attribute may include a dynamic XPath expression - an XPath expression surrounded by braces ({ and }).</li>
</ul>
<p>The following tutorials provide a quick introduction to XPath expressions. The first tutorial allows you to
type expressions, and see their results!</p>
<ul>
  <li> <a href="http://www.zvon.org/xxl/XPathTutorial/General/examples.html">http://www.zvon.org/xxl/XPathTutorial/General/examples.html</a> </li>
  <li> <a href="http://www.w3schools.com/xpath/xpath_intro.asp">http://www.w3schools.com/xpath/xpath_intro.asp</a> </li>
</ul>
</body>
</html>

Back to the top