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

Error when includes more than one XMLNS #93

Closed
dandanknight opened this issue Nov 9, 2015 · 2 comments
Closed

Error when includes more than one XMLNS #93

dandanknight opened this issue Nov 9, 2015 · 2 comments

Comments

@dandanknight
Copy link

Hi there, I'm looking to create a pretty complicated XML, that includes about 8 namespaces. When I create a template, if I reference more than one namespace, I get the following error.....

/Users/dan/WebstormProjects/adiBuilder/node_modules/vash/lib/parser.js:108
  var consumed = this[dispatch](this.node, curr, next, ahead, nnwon);
                               ^
TypeError: undefined is not a function
    at Parser.read (/Users/dan/WebstormProjects/adiBuilder/node_modules/vash/lib/parser.js:108:32)
    at Object.exports.compile (/Users/dan/WebstormProjects/adiBuilder/node_modules/vash/index.js:62:33)
    at Object.<anonymous> (/Users/dan/WebstormProjects/adiBuilder/app.js:30:16)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

This is before I include any variables/model or anything, seems to just fails parsing.

So, this works....

var tpl = vash.compile('<?xml version="1.0" encoding="UTF-8"?><ADI xmlns:core="http://www.cablelabs.com/namespaces/metadata/xsd/core/1" xmlns:ext="URN:NNDS:CMS:ADI3:01" xmlns="http://www.cablelabs.com/namespaces/metadata/xsd/vod30/1"><ext:title><AnotherElement>Hello</AnotherElement></ext:title></ADI>');

var out = tpl({});

...and XML pretty printed...

<?xml version="1.0" encoding="UTF-8"?>
<ADI xmlns:core="http://www.cablelabs.com/namespaces/metadata/xsd/core/1" xmlns:ext="URN:NNDS:CMS:ADI3:01"
     xmlns="http://www.cablelabs.com/namespaces/metadata/xsd/vod30/1">
    <ext:title>
        <AnotherElement>Hello</AnotherElement>
    </ext:title>
</ADI>

And this does not work...

var tpl = vash.compile('<?xml version="1.0" encoding="UTF-8"?><ADI xmlns:core="http://www.cablelabs.com/namespaces/metadata/xsd/core/1" xmlns:ext="URN:NNDS:CMS:ADI3:01" xmlns="http://www.cablelabs.com/namespaces/metadata/xsd/vod30/1"><ext:title><core:AnotherElement>Hello</core:AnotherElement></ext:title></ADI>');

var out = tpl({});

...and XML pretty printed...

<?xml version="1.0" encoding="UTF-8"?>
<ADI xmlns:core="http://www.cablelabs.com/namespaces/metadata/xsd/core/1" xmlns:ext="URN:NNDS:CMS:ADI3:01"
     xmlns="http://www.cablelabs.com/namespaces/metadata/xsd/vod30/1">
    <ext:title>
        <core:AnotherElement>Hello</core:AnotherElement>
    </ext:title>
</ADI>

Maybe Vash isn't the ideal tool for creating XMLs this way, any help is appreciated.

Dan

@kirbysayshi
Copy link
Owner

Hello!

Vash is definitely not well prepared for XML. It's parser is well tested against html at the moment, but xml is new territory.

But I just pushed a fix (v0.11.0) that will solve the problem you were having. It was related to the colons in the namespaces: vash wasn't treating them as part of the tag name.

Hope this helps, and let me know if you run into more issues!

@dandanknight
Copy link
Author

Hi kirbysayshi, wow, amazing response! Thank you so much. I'll give the new version a go right now.

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

2 participants