microsoft/XmlNotepad

Not able to validate XML against multiple not referenced Schemas

bmaehr opened this issue · 6 comments

Hello,

I'm still looking for a tool that is able to validate XML files against the Schemas correctlly without referencing the schemas in the XML file.

As an example the XML file looks like this

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
	<SOAP-ENV:Header/>
	<SOAP-ENV:Body>
		<ns2:getServiceInfoResponse 
		  xmlns:ns2="http://soap.mvb-online.com/data/common/ServiceInformation/V1" 
		  xmlns:ns3="http://soap.mvb-online.com/data/order/OrderTypes/V1" 
		  xmlns:ns4="http://ns.editeur.org/onix/3.0/reference"
		  xmlns:ns5="http://soap.mvb-online.com/data/common/Exception/V1" 
		  xmlns:ns6="http://soap.mvb-online.com/OrderServiceMessagesV1" 
		  xmlns:ns7="http://soap.mvb-online.com/data/common/AddressTypes/V1">
			<ns2:Name>My Service</ns2:Name>
			<ns2:Version>1.0</ns2:Version>
			<ns2:ExecutionEnvironment>
				<ns2:Environment>TEST</ns2:Environment>
				<ns2:ServerName>localhost</ns2:ServerName>
			</ns2:ExecutionEnvironment>
			<ns2:ServiceSpecific>
				<ns5:Message>
					<ns5:Message>Work in progress</ns5:Message>
				</ns5:Message>
			</ns2:ServiceSpecific>
		</ns2:getServiceInfoResponse>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I'm now able to add the different schemas to XmlNotepad but it doesn't do a validation.
In fact I would expect, that I have to add only two Schemas:

But even after adding all needed schemas manually I don't see a validation error if I - for example - change the ns2Version element to ns2:VersionX

If I remove the SOAP-ENV:Envelope and SOAP-ENV:Body from the XML file, the validation of getServiceInfoResponse seams to work correctlly.
Also if the processContents of SOAP-ENV:Body in the schema is changed from lax to strict, this has no effect on the validation.

Editing the Schema Dialog is supposed to enable this scenario, but looks like you found a bug. Looking at that soap envelope schema, it is not much of a schema, it allows anything in both the header and footer.

<xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>

But if I add another element after the Body I get an error:
image

Can you provide a link to the http://soap.mvb-online.com/data/common/ServiceInformation/V1 schema? I am having trouble finding it.

Here it is.
ExceptionTypes.xsd.txt
BaseTypes.xsd.txt
ServiceInformationTypes.xsd.txt

How it is defined is not important as you said it allows anything. It just validate the "anything".

Got it, thanks for the additional schemas, I had to edit a couple "schemaLocation" attributes to remove the path "../../common/V1/" so that XMLNotepad could resolve those xsd:imports and I fixed the bug in XML notepad. Previously it only looked at xmlns attributes on the root of the document, which this sample does not have. I have changed XML notepad to pick up schema target namespaces associations from anywhere in the document and now your sample correctly produces the validation error and intellisense. This fix is checked into the repo master branch, in case you want to try it, and will be included in the next release.

image

Thank you. I will try the next release.

Funny thing: I have tried this kind of complex validation with several tools for Windows and all failed. Even the expensive XML Spy fails.

The fix is in the new version 2.9.0.13.

I'll let you close the issue when you've verified the fix.