fnogatz / xsd2json

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

Keep getting error running example from doc #76

Closed Heucles closed 6 years ago

Heucles commented 6 years ago

Used xsd:

<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="dog" type="xs:string" />
</xs:schema>

code:

let xsd2json = require('xsd2json');
let filename = '${__dirname}/schema.xsd';

// use as function
xsd2json(filename, (err, schemaObject) => {
    console.log(err);
    console.log(JSON.stringify(schemaObject));
});

Error message:

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /home/heucles/dev/c4-omnigateway/app/node_modules/xsd2json/index.js:55:25
    at ConcatStream.<anonymous> (/home/heucles/dev/c4-omnigateway/app/node_modules/concat-stream/index.js:36:43)
    at emitNone (events.js:110:20)
    at ConcatStream.emit (events.js:207:7)
    at finishMaybe (/home/heucles/dev/c4-omnigateway/app/node_modules/readable-stream/lib/_stream_writable.js:607:14)
    at endWritable (/home/heucles/dev/c4-omnigateway/app/node_modules/readable-stream/lib/_stream_writable.js:615:3)
    at ConcatStream.Writable.end (/home/heucles/dev/c4-omnigateway/app/node_modules/readable-stream/lib/_stream_writable.js:571:41)
    at Socket.onend (_stream_readable.js:598:10)
    at Object.onceWrapper (events.js:314:30)
undefined
<Buffer 5b 46 41 54 41 4c 20 45 52 52 4f 52 3a 0a 09 43 6f 75 6c 64 20 6e 6f 74 20 6f 70 65 6e 20 72 65 73 6f 75 72 63 65 20 64 61 74 61 62 61 73 65 20 22 2f ... >
fnogatz commented 6 years ago

I just updated the Markdown formatting of your message and will have a look at the reported bug soon.

fnogatz commented 6 years ago

For me this works as expected. I get the following result:

{"type":"string"}

What versions of node, npm and SWI-Prolog are you using? Please provide the output of npm version and swipl --version.

Heucles commented 6 years ago
npm -version
5.5.1

node -v
v8.4.0

swipl --version
SWI-Prolog version 7.2.3 for x86_64-linux

Also I think it is worth mentioning that my node was installed using NVM and aldo I didn´t installed xsd2json globally, only locally on the project.

fnogatz commented 6 years ago

Ah, this is due to a known bug in SWI-Prolog 7.2.x, as documented in the readme file. Please upgrade your installation of SWI-Prolog, either with your package manager or using the SWI-Prolog version manager swivm.

I will close this issue. If the error occurs for a newer version of SWI-Prolog, too, please open a new issue.