DevToys-app / DevToys

A Swiss Army knife for developers.
https://devtoys.app/
MIT License
26.92k stars 1.45k forks source link

XML Validator not working #604

Closed NEKolev closed 2 years ago

NEKolev commented 2 years ago

Description

XML Validator doesn't work (xml is always valid) if you don't add the path to the xsd schema in the xml file. A program like XMLSpy when validating against a schema asks if it should modify the xml file and adds the path to the xsd schema in the xml file itself.

Steps To Reproduce

Go to the XML Validator When the check doesn't work

  1. adding the attached 'Shema.xsd'
  2. adding the attached 'not-working.xml' When the check works
  3. adding the attached 'working.xml'. In the file is added the following change in the line cpFile. Need to change the path to the schema <cpFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://nhif.bg/xsd/hosp/cp file:///E:\TestXML/Schema.xsd" xmlns="http://nhif.bg/xsd/hosp/cp">

It is now apparent that the xml is not validating according to the schema.

Expected behavior

Changing the xml file is done automatically for the check to work properly.

DevToys Version

Version 1.0.9.0 | X64 | RELEASE | 8bcfa60 | 8bcfa60

Relevant Assets/Logs

TestXML.zip

NEKolev commented 2 years ago

@JustAGabriel FYI

NEKolev commented 2 years ago

@JustAGabriel @veler is a correction planned in the near future?

gm0stache commented 2 years ago

Hi @NikolayEKolev I will look into this!

gm0stache commented 2 years ago

Alright, I am done with the investigation - the xsd<>xml validation logic is working fine.

The general thing missing in my opinion is a better logging/display of a warning for namespace inconsistencies.

Exemplary scenario: trying to validate a xsd that explicitly defines a namespace with a xml that is missing the namespace. Desired result: warning that the xml is missing a reference/define the according namespace and the validation result therefore will always be true.

I am currently working on a solution. Though the solution does not aim to implement a option to automatically adjust/add namespaces within the validation scope.

gm0stache commented 2 years ago

PR will be created mid/end of next week.

NEKolev commented 2 years ago

I am currently working on a solution. Though the solution does not aim to implement a option to automatically adjust/add namespaces within the validation scope.

Is there an option to implement an automatic mechanism for namespace inconsistencies with a warning that the original file will be changed?

gm0stache commented 2 years ago

In general for sure. But I simply don't see the need nor the demand for it.

Create a feature request, get some up votes and prove me wrong 🙂

NEKolev commented 2 years ago

In general for sure. But I simply don't see the need nor the demand for it.

Create a feature request, get some up votes and prove me wrong 🙂

I guess the question is whether to ask to modify the file. If this is what you are talking about, there is no need to create a new FR. I think in XMLSpy it asks that's why I wrote it :)

I can prepare another schematic and file for testing.