Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

What is the reason for: Caused by: SaxonApiException: Unexpected token "<eof>" in path expression

What is the reason for: Caused by: SaxonApiException: Unexpected token "<eof>" in path expression

Expert Contributor

Hi, is there any possibility to understnd what do I do wrong:

Caused by: net.sf.saxon.s9api.SaxonApiException: Unexpected token "<eof>" in path expression

 

Here is a part of xquery:

 

xquery {
fragments : [
{
fragmentPath : "/"
  queryString : """
  declare namespace ecol="http://lol.ru/gbo/ecollector";
  declare namespace attr="http://lol.ru/gbo/ecollector/attributes/etp";
  return
     <entry>
          /ecol:collectorEvent/ecol:attributes/attr:etpEventCollectorAttributes/attr:ssoId/text
     </entry>
   """
}
]
}

error says:

[ERROR] Caused by: net.sf.saxon.trans.XPathException: Unexpected token "<eof>" in path expression
[ERROR] at net.sf.saxon.query.QueryParser.grumble(QueryParser.java:453)
[ERROR] at net.sf.saxon.expr.parser.ExpressionParser.grumble(ExpressionParser.java:226)

Caused by: com.cloudera.cdk.morphline.api.MorphlineCompilationException: Cannot compile near: {

where line number corresponds to "fragmentPath" configuration element

2 REPLIES 2

Re: What is the reason for: Caused by: SaxonApiException: Unexpected token "<eof>" i

Expert Contributor

I've made this example easier:

xquery {
  fragments : [
  {
    fragmentPath : "/"
    queryString : "/collectorEvent/attributes/etpEventCollectorAttributes/ssoId"
  }
]
}

 

and now my test works:

collector.reset()
startSession()
assertThat(morphline.process(record), equalTo(true))

 

//ok, it returns 1
assertThat(collector.getNumStartEvents(), equalTo(1))

 

//it returns 0

println collector.getRecords() 

 

I did use http://www.xpathtester.com/xquery as a cross-test tool and it does return a value for my xquery

 

 

Highlighted

Re: What is the reason for: Caused by: SaxonApiException: Unexpected token "<eof>" i

Expert Contributor

I did grab some code from com.cloudera.cdk.morphline.api.AbstractMorphlineTest

 

I see in trace:

696  [main] TRACE com.cloudera.cdk.morphline.saxon.XQueryBuilder$XQuery  - XQuery result sequence item #1 is of class: net.sf.saxon.tree.tiny.TinyElementImpl with value: <ssoId>DIT2012@mos.ruUUID12345</ssoId>
BEFORE collector.getRecords().each
AFTER collector.getRecords().each

 but collector doesn't get any records... Looks like I've grabbed code in a wrong way.