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

Issue with XML containing subdeclaration #62

Closed
7 tasks done
edi9999 opened this issue Mar 1, 2018 · 8 comments
Closed
7 tasks done

Issue with XML containing subdeclaration #62

edi9999 opened this issue Mar 1, 2018 · 8 comments

Comments

@edi9999
Copy link

edi9999 commented Mar 1, 2018

  • Are you running the latest version?
  • Have you include sample input?
  • Have you include actual output?
  • Have you include expected output?
  • Have you checked if you are using correct configuration?
  • Did you try online tool?
  • Did you bookmarked the repository for further updates? ;)

Input data

require('fast-xml-parser').validate(`<?xml version="1.0"?><?mso-contentType?><h1></h1>`)

Output data

{ err:
   { code: 'InvalidXml',
     msg: 'XML declaration allowed only at the start of the document.' } }

expected data

true

@Delagen
Copy link
Contributor

Delagen commented Mar 2, 2018

I think processing instructions not covered yet

@amitguptagwl
Copy link
Member

Sorry for the late response. It is a festive season here. As @Delagen said, it is not covered yet. It's a very small change. I'll publish the changes on Monday.

@amitguptagwl
Copy link
Member

Please use 3.4.0

@keponk
Copy link

keponk commented Oct 2, 2020

@amitguptagwl i can't find a reference on how to access the processing instructions. Is it correct to say that only the validator is aware of it? I would like to access the processing instructions after validation as well, they contain valuable info.

@amitguptagwl
Copy link
Member

Validator is checking for valid syntax of PI. And parser is ignoring them to read. Can you please tell me some use case where you feel you want keep their data and the desire format of the data. We can plan to include it into v4.

@keponk
Copy link

keponk commented Oct 3, 2020

@amitguptagwl thanks for the quick reply. PI's do have a dedicated purpose, normally it is a connection between XML authors and the xml-aware application [1].

My use case is that I receive an XML from someone else. This author decided to use PI's to embed metadata of the XML. One could argue that the purpose of PIs is not related to metadata and the author could've chosen to embed that metadata in a real tag, but this is where we are and technically the author is complying with the XML standard.

Further, it seems to me that a parser reading a valid xml should return to me all the information in there, including the PI, which is part of XML standard. Sadly, as XML popularity declines it seems to me there are not many robust parsers out there who do take PIs into account as it may be more of an obscure use case in 2020, I've only found hobby parser projects that do keep PI's in the JSON output.

Regarding the desired format, I think continuing with fast-xml-parser standard would be best, that is, in similarity to using the attr keyword, the PIs could be packed as an array with a relevant keyword such as instr. They should follow the same nesting rules as attr if possible.

Let me know if this makes sense or if I can provide more specific examples.

[1] https://docstore.mik.ua/orelly/xml/xmlnut/ch17_02.htm

@amitguptagwl
Copy link
Member

I have created another issue to track it

@amitguptagwl amitguptagwl mentioned this issue Oct 5, 2020
@amitguptagwl
Copy link
Member

Please check v4.0.0-beta.6

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

No branches or pull requests

4 participants