fnogatz / xsd2json

Translate XML Schema into equivalent JSON Schema
MIT License
150 stars 28 forks source link

Syntax errors #6

Closed albanm closed 9 years ago

albanm commented 9 years ago

Hello again :)

When running cli.pl I encounter the following errors:

ERROR: c:/users/mouton-a/sandbox/git/xsd2json/prolog-xsd2json/merge_json.pl:60:14: Syntax error: Operator expected ERROR: c:/users/mouton-a/sandbox/git/xsd2json/prolog-xsd2json/xsd2json.pl:380:12: Syntax error: Operator expected ERROR: c:/users/mouton-a/sandbox/git/xsd2json/prolog-xsd2json/xsd2json.pl:381:11: Syntax error: Operator expected

Most of the times this is non-blocking. But on some XSDs it is followed by the blocking error:

ERROR: c:/users/mouton-a/sandbox/git/xsd2json/prolog-xsd2json/cli.pl:5: Initialization goal raised exception: ERROR: xsd2json:convert_xsd_restriction/3: Undefined procedure: xsd2json:json_false/1

The 3 lines contain arobases. Coincidence ? I think not !

Wondering if this could be an encoding problem I tried adding ':- encoding(utf8).' to the source files. But it didn't fix anything and being totally ignorant of prolog I am already out of ideas.

Environment:

$ swipl -v
SWI-Prolog version 6.6.6 for i386-win32
albanm commented 9 years ago

FYI, I have identified that the syntax error becomes blocking when the XSD contains an element of type xs:positiveInteger

fnogatz commented 9 years ago

Do you have a concrete example where the error occurs? The test set contains a test for xs:positiveInteger and it does not through any error:

swipl -q -f lib-pl/cli.pl -- < test/xsd/element_positiveInteger.xsd
|:  {"type":"integer", "minimum":0, "exclusiveMinimum":true}
fnogatz commented 9 years ago

Found two issues that might were the reason for this error: There's a built-in Prolog predicate =@=/2 which makes the unification exlusiveMinimum=@false throwing a syntax error. And the JSON representation of true is @(true) in SWI-Prolog 6.x.

Fixed both by 43228a7af3e9cefe61b1b775abe5e89bacbc6d3b, published the new version 1.0.1 here and on npm.

albanm commented 9 years ago

Hello,

Thanks, but I still got this:

ERROR: c:/users/mouton-a/sandbox/git/node-xsd2json/prolog-xsd2json/merge_json.pl:60:14: Syntax error: Operator expected

ERROR: c:/users/mouton-a/sandbox/git/node-xsd2json/prolog-xsd2json/xsd2json.pl:650:84: Syntax error: Operator expected

ERROR: c:/users/mouton-a/sandbox/git/node-xsd2json/prolog-xsd2json/xsd2json.pl:651:84: Syntax error: Operator expected

ERROR: c:/users/mouton-a/sandbox/git/node-xsd2json/prolog-xsd2json/xsd2json.pl:676:48: Syntax error: Operator expected

ERROR: c:/users/mouton-a/sandbox/git/node-xsd2json/prolog-xsd2json/xsd2json.pl:681:48: Syntax error: Operator expected

The syntax errors in xsd2json.pl can be fixed by imitating what you did and add someparenthesis. The error in merge_json.pl I don't know.

gabrielmancini commented 8 years ago

me too

fnogatz commented 8 years ago

Could you please provide your error messages, @gabrielmancini? This issue is two years old, the codebase has changed since then :)