On 13/11/13 08:26, Andy Seaborne wrote:
On 12/11/13 14:42, Ian Dickinson wrote:
Hi Andy,
Can we have the various /validate/* methods return JSON when
application/json is requested? I'm replicating the behaviour of the
current validation forms, but I'd like to do them as Ajax requests and
display the results in a codemirror box. So all a JSON API needs to
return is the validation output.

Thanks,
Ian


Hi Ian,

Sure - the error reports are just the outputs of the underlying parser
for whatever is being validated so while it's big strings of the
formatter and error message it's simple to do.  I might be able to grab
the line/column as well (can't remember is that's separately available
by the time the exception bubbles up).

     Andy

I've put in a new query validator (and only the query validator for now) that returns a JSON structure. It does all the parsing and formatting choices in one go so the UI can switch quickly between them.

Example:

{ "algebra" : "(base <http://example/base/>\n  ...\n" ,
  "algebra-opt" : "(....)\n" ,
  "algebra-opt-quads" : "(..)\n" ,
  "algebra-quads" : "(...)\n" ,
"formatted" : "PREFIX : <http://example/>\n\nSELECT *\nWHERE\n { :s :p ?o }\n" ,
  "input" : "PREFIX : <http://example/> \nSELECT * { :s :p ?o }"
}

Or for a parse error:

{ "input" : "SELECT * { :s :p ?o }" ,
  "parse-error" : "Line 1, column 12: Unresolved prefixed name: :s" ,
  "parse-error-column" : 12 ,
  "parse-error-line" : 1
}

If I set the output to text/plain it appears in the VALIDATION OUTPUT area. It checked in as application/json (nothing appears - not surprisingly)

        Andy

Reply via email to