fnogatz / xsd2json

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

ERROR: -g user:main: Syntax error: Operator expected #122

Open joncorrin opened 4 years ago

joncorrin commented 4 years ago

I keep getting the following error when trying to convert my xsd file: ERROR: -g user:main: Syntax error: Operator expected

Seems to be a Prolog issue. Any idea what could be wrong? The XSD appears to be valid.

https://xilo-s3.s3-us-west-2.amazonaws.com/ezauto.xsd

nachtigall-83 commented 4 years ago

Similar problem here: With one xsd it's working fine, with the other I get a json file with no content.

With --debug-info it shows: ERROR: -g user:main: false

With --trace it shows: ERROR: -g user:main: Undefined procedure: chr_leash/1 ERROR: In: ERROR: [11] chr_leash(none) ERROR: [10] main([space(remove),...|...],['C:\Users\taascru2\AppData\Roaming\npm\\node_modules\xsd2json\lib-pl\cli.exe','AccountRead.xsd']) at c:/users/taascru2/appdata/roaming/npm/node_modules/xsd2json/lib-pl/cli.pl:107 ERROR: [8] catch(user:main,error(existence_error(procedure,...),context(...,_30256)),'$toplevel':true) at c:/program files/swipl/boot/init.pl:386 ERROR: [7] catch_with_backtrace(user:main,error(existence_error(procedure,...),context(...,_30314)),'$toplevel':true) at c:/program files/swipl/boot/init.pl:436 ERROR: ERROR: Note: some frames are missing due to last-call optimization. ERROR: Re-run your program in debug mode (:- debug.) to get more detail.

Same happens if I trace or debug the xsd that normally works. With --debug-info or --trace I get the error messages and an empty json. After deleting the empty file and rerun the command without flags, it works again.

For the second xsd that never works I get no hint what could be wrong with it. It has a dependency to another xsd that has a dependency to a third xsd. Could this be the reason?

Thanks in advance for your help.

fnogatz commented 4 years ago

With --debug-info it shows: ERROR: -g user:main: false

Hm, we should first try to get --debug-info working. Have you installed xsd2json as a global module (npm install -g xsd2json), or as a dependency in your local package.json?

nachtigall-83 commented 4 years ago

I installed it as a global module.

fnogatz commented 4 years ago

What version of SWI-Prolog are you using? (simply call swipl --version)

nachtigall-83 commented 4 years ago

SWI-Prolog version 8.0.3 for x64-win64

fnogatz commented 4 years ago

I think the problem here is the Windows OS. Actually, I never tried xsd2json on a Windows machine, but I see several possibilities for issues here. As I don't have a Windows machine at hand, I unfortunately can't provide an ad-hoc solution.

@joncorrin, are you using a Windows machine, too?

nachtigall-83 commented 4 years ago

I finally managed to install it on my ancient Mac, but not as a global module. Running with debug-info gives me a json file with this content (but nothing in the terminal):

xsd2json

1.12.16

SWI-Prolog

SWI-Prolog version 7.6.4 for x86_64-darwin15.6.0

npm

6.14.5

node

v12.18.1

Tracing option seems to work, it gives me a huge amount of output in the Terminal. I didn't have the time to check this, but last line is: ERROR: -g main: Domain error: 'chr_port' expected, found 'none'

This may give you a hint?