Schema validation on document with a DOCTYPE block

SyntaxEditor Web Languages Add-on for WPF Forum

Posted 4 years ago by Jason Ruakere
Version: 14.1.0321
Avatar

It appears that automatic schema validation doesn't work when there's a DOCTYPE block at the top of the XML document.

If I simply remove the DOCTYPE block, the red squiggly line immediately appears under the invalid child element.

Any suggestions would be greatly appreciated.

Regards, Jason.

Comments (4)

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Jason,

I checked but I'm not seeing that happen in our demo.  As long as our XmlValidator has a Mode=Schema, which is the default, it tells the core XML validator to ignore DTDs.

Note that if you have a syntax error in your XML, all validation is skipped.  It could simply be that you had a syntax error in this case, which prevented the schema validation from executing.


Actipro Software Support

Posted 4 years ago by Jason Ruakere
Avatar

Thanks for the quick response. I've just realised that I've posted to the WPF forum instead of the WinForms forum. Are you able to check the problem using the WinForms demo?

In the WinForms demo, I receive the following error...

'For security reasons DTD is prohibited in this XML document. To enable DTD processing set the ProhibitDTD property on XmlReader Settings to false and pass the settings into XmlReader.Create method.'

As the SyntaxEditor.Document.LoadFile() method only takes a file path, I tried changing the DtdSupportEnabled property exposed by the XmlSchemaResolver. This, unfortunately, appears to then expect a DTD for use with validation.

Thanks again, 

Jason.

Answer - Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Jason,

If you make a class that inherits XmlSchemaResolver, there is a protected virtual CreateValidationXmlReaderSettings method you can override that creates the XmlReaderSettings.  We target .NET 3.5 so we can't fix this particular scenario on our own, but if you target .NET 4.0 or higher in your app, you can call the base method and on the settings object that is returned, set its DtdProcessing property (added in .NET 4.0) to Ignore.  I believe that will solve the problem, as it's what we do in the WPF version.


Actipro Software Support

Posted 4 years ago by Jason Ruakere
Avatar

Your solution worked perfectly! Thanks so much for your help :)

Cheers, Jason.

The latest build of this product (v2018.1 build 0675) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.