Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property '$ns' of undefined #8

Open
ottosson opened this issue Jul 3, 2015 · 10 comments
Open

TypeError: Cannot read property '$ns' of undefined #8

ottosson opened this issue Jul 3, 2015 · 10 comments

Comments

@ottosson
Copy link

ottosson commented Jul 3, 2015

When I try to parse a xml file I get the error "TypeError: Cannot read property '$ns' of undefined", and it seems to be coming from xml2js. I just copied and pasted the example code:

xml4js.parseString(xml, {downloadSchemas: true}, function (err, result) {
    console.log(util.inspect(result, false, null));
});

There is no problem parsing the same xml with xml2js.

I use xml2js 0.4.9 and xml4js 0.1.2.

@mitar
Copy link
Member

mitar commented Jul 3, 2015

Sorry, I will not be able to help you much here without more data. Can you do a pull request with a failing test case?

@bogdanbujdea
Copy link

Hi! I'm facing the same issue. Here's an XML example:

<?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:gsa='http://schemas.google.com/gsa/2007'><id>http://213.229.151.228:8002/feeds/status/documentStatus</id><updated>2015-10-15T08:33:58.161Z</updated><app:edited xmlns:app='http://purl.org/atom/app#'>2015-10-15T08:33:58.161Z</app:edited><link rel='self' type='application/atom+xml' href='https://213.229.151.228:8002/feeds/status/documentStatus'/><link rel='edit' type='application/atom+xml' href='https://213.229.151.228:8002/feeds/status/documentStatus'/><gsa:content name='entryID'>documentStatus</gsa:content><gsa:content name='servedURLs'>1,180</gsa:content><gsa:content name='crawlPagesPerSecond'>0.03</gsa:content><gsa:content name='crawledURLsToday'>0</gsa:content><gsa:content name='foundURLs'>96,362</gsa:content><gsa:content name='filteredBytes'>208,478,568,448</gsa:content><gsa:content name='errorURLsToday'>0</gsa:content></entry>

@mlooney
Copy link

mlooney commented May 2, 2016

Same issue here:

<?xml version="1.0"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">

xmllint has no problem, and validates the document successfully. Note that amzn-envelope.xsd includes all sorts of other xsds as well.

(updated to include xml preamble in example.)

@mitar
Copy link
Member

mitar commented May 3, 2016

Yes, as I mentioned in other issues, I made this package for a particular XSD I had and developed features only for what was needed. I know some things are not implemented. But at the moment I do not have time to further work on this, especially because it works for me. But I would be glad to accept pull requests adding more features.

@mitar
Copy link
Member

mitar commented May 3, 2016

One thing, this package uses a fork of xml2js because two pull requests have not been merged upstream. Are you using that fork or not?

@mitar
Copy link
Member

mitar commented May 3, 2016

Can people create pull requests with tests which are failing?

@mitar
Copy link
Member

mitar commented May 3, 2016

OK, and people, those are different issues here. Do not all write in the same ticket. Are you all getting Cannot read property '$ns' of undefined? You are not.

@TheWinDev: You problem is that for http://www.w3.org/2005/Atom namespace there is no XML Schema definition (XSD) location provided.

@mlooney: Your example is not a valid XML?

@mlooney
Copy link

mlooney commented May 3, 2016

no, that particular snippet is not, but the document is rather large, so i didn't paste it in its entirety. I'll come up with a smaller test case to reproduce.

@mlooney
Copy link

mlooney commented May 3, 2016

@mitar
Copy link
Member

mitar commented May 3, 2016

I see, noNamespaceSchemaLocation seems to not be supported. That should be a fairly straightforward addition here: https://github.com/peerlibrary/node-xml4js/blob/master/lib/xsd.js#L515

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants