NaturalIntelligence / fast-xml-parser

Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback.
https://naturalintelligence.github.io/fast-xml-parser/
MIT License
2.53k stars 303 forks source link

Feature: Validate XML against XSD #220

Closed boddi7 closed 1 year ago

boddi7 commented 4 years ago

I noticed that there is no way to validate a XML file against a XSD file. This would be a great feature for this project and would prevent people parsing invalid XML files.

github-actions[bot] commented 4 years ago

I'm glad you find this repository helpful. I'll try to address your issu ASAP. You can watch the repo for new changes or star it.

amitguptagwl commented 4 years ago

FXP is basically a syntax parser. But yes, parsing/validating against XSD is required in many cases. Hence, it is in the plan in the next major release.

anxxp commented 4 years ago

FXP is basically a syntax parser. But yes, parsing/validating against XSD is required in many cases. Hence, it is in the plan in the next major release.

First of all , thanks Amit for this excellent library. Just wanted to know, is there any timeline that you have planned for this feature? This would be really useful.

amitguptagwl commented 4 years ago

@anoop29 I'm working on FXP v4. This will take some time to complete. I have to then incorporate some priority issues in that. And then I'll pick this feature. Working in free time, I currently can't comment on any timelines. But hoping to complete v4 in next 2 weeks.

guerrap commented 3 years ago

Hi, any update on this?

pumano commented 3 years ago

@amitguptagwl any news on this?

amitguptagwl commented 3 years ago

Sorry I have taken a big gape from opensource in this pandemic. I'm completing cytorus and then will pick FXP v4. Sorry for the delay. But this feature is gonna take long time.

pumano commented 3 years ago

@amitguptagwl thank you! I personally want validation by xsd schema it's very important for me now, if you find time to implement that, it's will be very good!

sdykae commented 3 years ago

This feature will be killing if done ;') I have a case, duno if is going to work but, xsd files sometimes uses 'refs' and imports another xsd files namespaces to resolve the full xsd. An example is https://cpe.sunat.gob.pe/sites/default/files/inline-files/XSD%202.1.zip from https://cpe.sunat.gob.pe/node/88

These xsd files are used to validate against UBL 2.1 xml standard. The main xsd is XSD 2.1/maindoc/UBL-Invoice-2.1.xsd and it calls other namespaces from around the dir. Hope the funcion that calls validation understands and resolves agains relative references from those files ;')

ehaynes99 commented 3 years ago

This would also help with https://github.com/NaturalIntelligence/fast-xml-parser/issues/279

Without the schema, there's no real way it could determine that both of these are strings:

<FullName>Joe Schmoe</FullName>
<PhoneNumber>1234567890</PhoneNumber>

But it could properly differentiate if aware of a schema:

<xsd:element name="FullName" type="xsd:string"/>
<xsd:element name="PhoneNumber" type="xsd:string"/>
hadwrf commented 3 years ago

It would be really useful feature. Please take consider that there are no consistent library doing xsd validation. If anyone knows, please notify me. Thank you.

pumano commented 3 years ago

without parsing xml using xsd schema, for complex large structures this library is useless. @ehaynes99 show small example of it.

amitguptagwl commented 3 years ago

All, I've just completed detailed-xml-validator for some other need. Can you please explore and provide your feedback based on your need.

Narretz commented 5 months ago

@amitguptagwl a new schema format is cool I guess, but it doesn't replace the xsd schemas already out there that are used to validate xml files. Imo this issue should be reopened.

amitguptagwl commented 5 months ago

@Narretz I found XSD little complex than the new format I used in detailed-xml-validator. Though, I've not add more features in that but some existing features make it easy to use. And direct embedding of rules make it to be used by non-technical people as well. Hence, there is no plan for XSD validation currently,