Question: I have a table below where i need to create a column of "Relevant" and "Non-Relevant" based on IDs.

The table looks like something below:

```

+----+--------------+--------+
| ID |  Experience  | Length |
+----+--------------+--------+
|  1 | Relevant     |      2 |
|  1 | Non-Relevant |      1 |
|  4 | Relevant     |      3 |
|  4 | Relevant     |      4 |
|  4 | Non-Relevant |      0 |
|  5 | Relevant     |      1 |
|  5 | Relevant     |      1 |
+----+--------------+--------+

```

This is the output I am trying to get

```
+----+----------+--------------+
| ID | Relevant | Non-Relevant |
+----+----------+--------------+
|  1 |        2 |            1 |
|  4 |        7 |            0 |
|  5 |        2 |            0 |
+----+----------+--------------+

```

Answer: 
You seem to be asking a whole series of separate questions, which are hard to disentangle.

Your C# code appears to be compiling the query

```
<saxon:example>{static-base-uri()}</saxon:example>

```

which bears no relationship to the XQuery code you supplied that involves `MyFlightLegs`.

The `MyFlightLegs` query uses `//FlightLeg` and is clearly designed to run against a source document containing a `FlightLeg` element, but your C# code makes no attempt to supply such a document. You need to add an `eval.ContextItem = value` statement.

Your second C# fragment creates an input document in the line

```
XdmNode indoc = loader.Build(loader.BaseUri);

```

but it doesn't supply it to the query evaluator.

A base URI can be either a directory or a file; resolving `relative.xml` against `file:///my/dir/` gives exactly the same result as resolving it against `file:///my/dir/query.xq`. By convention, though, the static base URI of the query is the URI of the resource (eg file) containing the source query text.

Yes, there's a lot of inconsistency in the use of strings versus URI objects in the API design. (There's also inconsistency about the spelling of `BaseURI` versus `BaseUri`.) Sorry about that; you're just going to have to live with it.
Bottom line solution based on Michael Kay's response; I added this line of code after doing the exp.Load(): 

```
eval.ContextItem = indoc;

```

The indoc object created earlier is what relates to the XML input file to be processed by the XQuery.