fast-xml-parser icon indicating copy to clipboard operation
fast-xml-parser copied to clipboard

Feature: Validate XML against XSD

Open boddi7 opened this issue 4 years ago • 13 comments

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.

boddi7 avatar Jan 02 '20 16:01 boddi7

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.

github-actions[bot] avatar Jan 02 '20 16:01 github-actions[bot]

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.

amitguptagwl avatar Jan 03 '20 00:01 amitguptagwl

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.

anxxp avatar Jan 15 '20 06:01 anxxp

@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.

amitguptagwl avatar Jan 16 '20 01:01 amitguptagwl

Hi, any update on this?

guerrap avatar Apr 12 '21 10:04 guerrap

@amitguptagwl any news on this?

pumano avatar May 12 '21 12:05 pumano

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.

amitguptagwl avatar Jun 06 '21 09:06 amitguptagwl

@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!

pumano avatar Jun 06 '21 11:06 pumano

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 ;')

sdykae avatar Jun 16 '21 03:06 sdykae

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"/>

ehaynes99 avatar Jul 20 '21 00:07 ehaynes99

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.

hadwrf avatar Sep 17 '21 08:09 hadwrf

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

pumano avatar Sep 17 '21 10:09 pumano

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

amitguptagwl avatar Sep 27 '21 15:09 amitguptagwl

@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.

Narretz avatar Apr 16 '24 14:04 Narretz

@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,

amitguptagwl avatar Apr 19 '24 09:04 amitguptagwl