title: Getting "XQueryException", Unexpected token syntax error
body: <p>I have created Xdbc database connection and run the sample program it was successful.
  I have created class <code>markLogics.java</code> and imported the jar file <code>marklogic-xcc-4.0.1.jar</code></p>
  
  <p><strong>Code Snapshot:</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>package com.marklogic;
  import java.net.URI;
  import java.net.URISyntaxException;
  import com.marklogic.xcc.ContentSource;
  import com.marklogic.xcc.ContentSourceFactory;
  import com.marklogic.xcc.Session;
  import com.marklogic.xcc.Request;
  import com.marklogic.xcc.ResultSequence;
  import com.marklogic.xcc.exceptions.RequestException;
  import com.marklogic.xcc.exceptions.XccConfigException;**
  
  class markLogics {
  public static void main(String args[]) throws XccConfigException,
          RequestException {
      URI uri = null;
      try {
          uri = new URI("xcc://user:pwd@localhost:8008/Marklogics");
          // uri=new URI("");
      } catch (URISyntaxException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      String queryResult = "";
      ContentSource contentSource = ContentSourceFactory
              .newContentSource(uri);
      Session session = contentSource.newSession();
      String queryStr = "let $uri := xdmp:get-request-field(\"uri\")"
              + "return"
              + "if (empty($uri) or $uri eq\"\") then"
              + "("
              + " xdmp:set-response-content-type(\"\text/html\"),"
              + "&lt;ul&gt;"
              + "{for $i in collection()"
              + "let $doc := document-uri($i)    return"
              + "&lt;li&gt;"
              + "&lt;a href="
              + "\"view.xqy?uri={xdmp:url-encode($doc)}\""
              + " &gt;{$doc}&lt;/a&gt;&lt;/li&gt;"
              + "}&lt;/ul&gt;)"
              + "else (   xdmp:set-response-content-type(\"text/xml\"),   if (empty(doc($uri)))"
              + "then &lt;error&gt;No content" + "&lt;/error&gt;    else doc($uri)  )";
      // String
      // queryStr="let $uri := xdmp:get-request-field(\"uri\")for $v in $doc//uri    $a in $doc//play";
      Request request = session.newAdhocQuery(queryStr);
      try {
          ResultSequence rs = session.submitRequest(request);
          System.out.println(rs.asString());
      } catch (Exception e) {
          e.printStackTrace();
      }
      session.close();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>While executing the code, I get that exception :</p>
  
  <pre><code>com.marklogic.xcc.exceptions.XQueryException: XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected QName_on line 1
  expr:
      at com.marklogic.xcc.impl.handlers.ServerExceptionHandler.handleResponse(ServerExceptionHandler.java:31)
      at com.marklogic.xcc.impl.handlers.EvalRequestController.serverDialog(EvalRequestController.java:68)
      at com.marklogic.xcc.impl.handlers.AbstractRequestController.runRequest(AbstractRequestController.java:72)
      at com.marklogic.xcc.impl.SessionImpl.submitRequest(SessionImpl.java:280)
      at com.marklogic.markLogics.main(test.java:34)
  </code></pre>
  
  <p><em><strong>Understanding:</em></strong></p>
  
  <p>According to my understanding in the query I have call use the <code>view.xqy</code> file that is throwing the exception.</p>
  
  <p>Approach Follows:
  I have tried the following approach to overcome this by archiving the the <code>view.xqy</code> and added into build path of the project, but it does not help me out.</p>
  
  <p>Could you give me some guidance to overcome the hiccups?</p>