title: How to use XPATH functions(concat, string-join) in JDOM2?
body: <p>Here I have a simple project. 
  pom.xml</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.jeecourse.tutorial&lt;/groupId&gt;
  &lt;artifactId&gt;JDOM2Demo&lt;/artifactId&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;JDOM2Demo&lt;/name&gt;
  &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.jdom&lt;/groupId&gt;
          &lt;artifactId&gt;jdom&lt;/artifactId&gt;
          &lt;version&gt;2.0.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;jaxen&lt;/groupId&gt;
          &lt;artifactId&gt;jaxen&lt;/artifactId&gt;
          &lt;version&gt;1.1.6&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>hr.xml put in the root folder of project:</p>
  
  <pre><code>&lt;HolidayRequest xmlns="http://mycompany.com/hr/schemas"&gt;
  &lt;Holiday&gt;
      &lt;StartDate&gt;2006-07-03&lt;/StartDate&gt;
      &lt;EndDate&gt;2006-07-07&lt;/EndDate&gt;
  &lt;/Holiday&gt;
  &lt;Employee&gt;
      &lt;Number&gt;42&lt;/Number&gt;
      &lt;FirstName&gt;Arjen&lt;/FirstName&gt;
      &lt;LastName&gt;Poutsma&lt;/LastName&gt;
  &lt;/Employee&gt;
  &lt;/HolidayRequest&gt;
  </code></pre>
  
  <p>Source Code to decode:</p>
  
  <pre><code>package com.jeecourse.tutorial;
  
  import java.io.IOException;
  
  import org.jdom2.Document;
  import org.jdom2.Element;
  import org.jdom2.JDOMException;
  import org.jdom2.Namespace;
  import org.jdom2.filter.Filters;
  import org.jdom2.input.SAXBuilder;
  import org.jdom2.xpath.XPathExpression;
  import org.jdom2.xpath.XPathFactory;
  
  public class XPathDecode {
  
  private static final String NAMESPACE_URI = "http://mycompany.com/hr/schemas";
  public static void main(String args[]) {
  
      XPathExpression&lt;Element&gt; startDateExpression;
      XPathExpression&lt;Element&gt; endDateExpression;
      XPathExpression&lt;Element&gt; nameExpression;
      XPathExpression&lt;Element&gt; nameExpression2;
      XPathExpression&lt;Element&gt; fnameExpression;
      XPathExpression&lt;Element&gt; lnameExpression;
      XPathFactory xFactory;
  
  
      SAXBuilder sax = new SAXBuilder();
      Document holidayRequest = null;
      try {
          holidayRequest = sax.build("hr.xml");
      } catch (JDOMException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
  
      Namespace namespace = Namespace.getNamespace("hr", NAMESPACE_URI);
  
      // use the default implementation
      xFactory = XPathFactory.instance();
      startDateExpression = xFactory.compile("//hr:StartDate", Filters.element(), null, namespace);
      endDateExpression = xFactory.compile("//hr:EndDate", Filters.element(), null, namespace);
      fnameExpression = xFactory.compile("//hr:FirstName", Filters.element(), null, namespace);
      lnameExpression = xFactory.compile("//hr:LastName", Filters.element(), null, namespace);
      nameExpression = xFactory.compile("concat(//hr:FirstName,'#',//hr:LastName)", Filters.element(), null, namespace);
      //nameExpression2 = xFactory.compile("string-join((//hr:FirstName, //hr:LastName), '#')", Filters.element(), null, namespace);
  
      Element startDate = startDateExpression.evaluateFirst(holidayRequest);
      System.out.println(startDate.getValue());
  
      Element endDate = endDateExpression.evaluateFirst(holidayRequest);
      System.out.println(endDate.getValue());
  
      Element fname = fnameExpression.evaluateFirst(holidayRequest);
      System.out.println(fname.getValue());
  
      Element lname = lnameExpression.evaluateFirst(holidayRequest);
      System.out.println(lname.getValue());
  
      Element name = nameExpression.evaluateFirst(holidayRequest);
      System.out.println(name.getValue());
  
      //Element name2 = nameExpression2.evaluateFirst(holidayRequest);
      System.out.println(name2.getValue());
  }
  }
  </code></pre>
  
  <p>But both the nameExpression and nameExpression2 don't work. The output result is:</p>
  
  <pre><code>2006-07-03
  2006-07-07
  Arjen
  Poutsma
  Exception in thread "main" java.lang.NullPointerException
  at com.jeecourse.tutorial.XPathDecode.main(XPathDecode.java:62)
  </code></pre>
  
  <p>nameExpression2 causes compilation error. Could you please help. Thanks.</p>