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

Namespace validation is not done #265

Open
5 of 6 tasks
edi9999 opened this issue May 28, 2020 · 2 comments · May be fixed by #275
Open
5 of 6 tasks

Namespace validation is not done #265

edi9999 opened this issue May 28, 2020 · 2 comments · May be fixed by #275
Labels
Feature-Request New features suggested by users

Comments

@edi9999
Copy link

edi9999 commented May 28, 2020

  • Are you running the latest version?
  • Have you included sample input, output, error, and expected output?
  • Have you checked if you are using correct configuration?
  • Did you try online tool?

Description

Input

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
      <pic:pic>
      </pic:pic>
</w:document>

Code

const fastXmlParser = require("fast-xml-parser");
const result = fastXmlParser.validate(str);
// result is true, but I expect it to be an error object.

Expected behavior

I would expect to see an error telling that the "pic" namespace was not defined in the document.

This is what is shown when using : https://xmlvalidation.com/
Selection_001

Would you like to work on this issue?

  • Yes, if you tell me that you're ok for it to be done and if you help me locate the changes to be done
  • No
@amitguptagwl
Copy link
Member

Yes, I hope it'll not be tuff to implement.

In validator.js, when we extract attributes name to validate them, we can extract NS to some object.

const result = readAttributeStr(xmlData, i);

We're already stacking tagName. Instead, we can stack a small object which will contain tagName and NS array attached with that tag.

tags.push(tagName);

Now when we're popping the tagName to verify the closing tag, we can remove those NS from the NS object that we created in starting.

const otg = tags.pop();

Validation
Now when we extract tag name or attribute name we can validate if the NS is bound or not.

tags.push(tagName);

function validateAttributeString(attrStr, options) {

@amitguptagwl amitguptagwl added the Feature-Request New features suggested by users label May 29, 2020
@kk-08 kk-08 linked a pull request Jun 27, 2020 that will close this issue
3 tasks
@kk-08
Copy link

kk-08 commented Jun 27, 2020

Added a PR for this: #275
PS: Blocked due to this. Would love to see this in the master soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature-Request New features suggested by users
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants