Skip to content

Expected start or end tag when unmarshalling #223

Open

Description

@nfigay

I'm currently assessing jsonix as a component for an open souce capability for Enterprise Models visualisation.
From an XML schema, I created the P0 mapping.
I then referenced it for unmarshaling an xml file created according to the schema. But I had the message error indicated in the title.
I tried it with a simpler schema, but had the same error message.
I've difficulties interpreting where the problem comes from.
Error message is the following:
`/Users/nicolasfigay/node_modules/jsonix/jsonix.js:1298
throw new Error('Expected start or end tag.');
^

Error: Expected start or end tag.
at Object.nextTag (/Users/nicolasfigay/node_modules/jsonix/jsonix.js:1298:10)
at Object.unmarshalDocument (/Users/nicolasfigay/node_modules/jsonix/jsonix.js:2129:9)
at /Users/nicolasfigay/node_modules/jsonix/jsonix.js:2099:18
at /Users/nicolasfigay/node_modules/jsonix/jsonix.js:164:8
at Object.handleTransport (/Users/nicolasfigay/node_modules/jsonix/jsonix.js:309:7)
at transport.onreadystatechange (/Users/nicolasfigay/node_modules/jsonix/jsonix.js:298:13)
at dispatchEvent (/Users/nicolasfigay/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
at setState (/Users/nicolasfigay/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
at handleError (/Users/nicolasfigay/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:532:5)
at ClientRequest.errorHandler (/Users/nicolasfigay/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:459:14)`

Code is the following:
`ar http = require('http');
var fs = require('fs');
var Jsonix = require('jsonix').Jsonix;
var PO = require('./PO.js').PO;

http.createServer(function (req, res) {

// First we construct a Jsonix context - a factory for unmarshaller (parser)
// and marshaller (serializer)
var context = new Jsonix.Context([PO]);

// Then we create a unmarshaller
var unmarshaller = context.createUnmarshaller();

unmarshaller.unmarshalURL('./Model_View.xml',
function (unmarshalled) {
console.log('OK');
});

res.writeHead(200, {'Content-Type': 'text/html'});
res.end('Hello World!');
}).listen(8080);`

Any idea concerning the origin of the error?

Best regards.

Activity

  1. highsource commented on Aug 12, 2019

    @highsource
    Owner

    I'd first check if ./Model_View.xml really delivers valid XML.

  2. nfigay commented on Aug 12, 2019

    @nfigay
    Author

    Thanks for your quick response.
    After multiple changes, I identified the issue came from usage of unmarshaling with URL which was probably invalid. Using UnmarshalFile with node.js worked well.
    It was not very easy identifying the problem with the error message.
    Best regards.

  3. mikaello commented on Apr 5, 2021

    @mikaello

    I had the exact same mistake, copy pasted the example from the README, with unmarshallURL and a local file. Changing to unmarshalFile solved the issue for me:

      // Unmarshal an object from the XML retrieved from the URL
    - unmarshaller.unmarshalURL('po.xml',
    + unmarshaller.unmarshalFile('po.xml',
          // This callback function will be provided
          // with the result of the unmarshalling
          function (unmarshalled) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions