libxml2-wasm icon indicating copy to clipboard operation
libxml2-wasm copied to clipboard

Only partial results from XsdValidator.validate()

Open paulhiggs opened this issue 5 months ago • 1 comments

First, thanks for libxml2-wasm - I am enjoying the capabilities and performance and am using it my DVB-I validation tools.

I recently noticed an issue with XsdValidator.validate() that was not present when I previously used libxmljs2 (or at least I don't recall seeing it) and have created a small project to demonstrate it - https://github.com/paulhiggs/wasm-validate

The call to validator.validate(document1) throws an error as there is a misplaced element LCNTableList but there are also some errrors not reported.

Attempting to validate the same document in Altova XMLSpy yields 4 errors

File E:\code\wasm-validate\ospTest.xml is not valid.
	Element <LCNTableList> is not allowed at this location under element <ServiceList id="tag:onscreenpublishing.com,2024:ospTest">.
		Reason: The following elements are expected at this location (see below)
			'{##any except ##local urn:dvb:metadata:servicediscovery:2025}'
		Error location: ServiceList / LCNTableList
	Element <URI> is not allowed under element <UriBasedLocation>.
		Reason: The following elements are expected at this location (see below)
			'dvbi-types:URI'
		Hint: Element <URI> is in namespace 'urn:dvb:metadata:servicediscovery:2025', but a correspondent element from namespace 'urn:dvb:metadata:servicediscovery-types:2025' would be permitted.
		Error location: ServiceList / Service / ServiceInstance / DASHDeliveryParameters / UriBasedLocation / URI
	Element <CMCD> is not allowed under element <ServiceInstance>.
		Reason: The following elements are expected at this location (see below)
			'dvbisd:MulticastTSDeliveryParameters'
		Error location: ServiceList / Service / ServiceInstance / CMCD
	Element <URI> is not allowed under element <UriBasedLocation>.
		Reason: The following elements are expected at this location (see below)
			'dvbi-types:URI'
		Hint: Element <URI> is in namespace 'urn:dvb:metadata:servicediscovery:2025', but a correspondent element from namespace 'urn:dvb:metadata:servicediscovery-types:2025' would be permitted.
		Error location: ServiceList / Service / ServiceInstance / DASHDeliveryParameters / UriBasedLocation / URI

but xmllint seems to concur with libxml2-wasm...

>xmllint --schema dvbi_v7.0-with-hls-hbbtv.xsd --noout ospTest.xml
hls-url-7.0.xsd:3: element import: Schemas parser warning : Element '{http://www.w3.org/2001/XMLSchema}import': Skipping import of schema located at 'dvbi-types_v1.1.xsd' for the namespace 'urn:dvb:metadata:servicediscovery-types:2025', since this namespace was already imported with the schema located at 'dvbi_types_v1.1.xsd'.
ospTest.xml:51: element LCNTableList: Schemas validity error : Element '{urn:dvb:metadata:servicediscovery:2025}LCNTableList': This element is not expected. Expected is ( ##other{urn:dvb:metadata:servicediscovery:2025}* ).
ospTest.xml fails to validate

Is there any way to collect all validation errors via libxml2-wasm?

paulhiggs avatar Jul 31 '25 12:07 paulhiggs

Looks like to require an enhancement on the upstream project.

Reported on libxml2 project: https://gitlab.gnome.org/GNOME/libxml2/-/issues/962

jameslan avatar Aug 02 '25 07:08 jameslan