Posted 11 years ago by Andrey Zenchenko
Version: 12.1.0304
Avatar

Hi,

I have all that I need for validation in xsd files but HTML entities can not be defined in xsd.

So when I validate an XHTML document which contains HTML entities (like  ) I get validation errors like this one: Reference to undeclared entity 'nbsp'.

So I would like to don't use DTD but escape from that kind of validation errors also.

Is it possible?

Thank you.

Comments (7)

Posted 11 years ago by Andrey Zenchenko
Avatar

Perhaps I found a solution.

I made my own XmlSchemaResolver class and overrided CreateValidationXmlReaderSettings method.

I this method I set

ValidationType = ValidationType.Schema;

DtdProcessing = DtdProcessing.Parse;

ProhibitDtd = false;

for returning XmlReaderSettings.

Just for check, is it right solution?

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

Hi Andrey,

What you tried there seems to be excluding the schemas from the validation.  So you probably won't get any schema validation whatsoever that way.

Another thing you could try to keep schema validation active but remove entity-related errors would be to override your SyntaxLanguage class' OnDocumentSemanticParseDataChanged method.  If the document's SemanticParseData property is a CompilationUnit, look at its SyntaxErrors collection.  Then you could remove the errors that relate to entities.


Actipro Software Support

Posted 11 years ago by Andrey Zenchenko
Avatar

Hi,

Not sure you are right :)

I haven't checked Microsoft XmlReader source code yet, but it doesn't seem (according the documentation) that the DtdProcessing.Parse influences on the ValidationType property, and at least in your editor it works fine (what I wanted). I mean in my case a document is validated by XSD.

As for SyntaxErrors collection I'm not sure it's the best way, because it's not a good idea to rely on error descriptions to filter them.
But perhaps I'm wrong and I can be sure (even on localized Windows versions) that the error related to an entity?

Anyway, thank you very much for your reply.

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

For our idea, you'd likely have to code for things in the description like 'nbsp' and whatever known entities there are.  As long as the other way you are doing it is working for you, it's probably easiest to stick with that.


Actipro Software Support

Posted 11 years ago by Andrey Zenchenko
Avatar

Thank you guys, I see your advice and appreciate it.

But something is bothering me, your answer seems like you think that my way is a trick or a hack and I want to be sure that is not truth and this way is a legal.

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

Well as mentioned, I didn't think the schema validation would work with the XmlReaderSettings you used since you didn't set the Schemas property or set ValidationType = ValidationType.Schema.  But if everything is working that you need working, then go ahead with that implementation.


Actipro Software Support

Posted 11 years ago by Andrey Zenchenko
Avatar

Sorry, I just want to leave this topic clear for other customers.

Of course, I set ValidationType = ValidationType.Schema (this line is mentioned in my first post), and of course every schema I need is added into XmlSchemaResolver.

To be honest, I just think something is missing in XmlSchemaResolver, I mean it has only the DtdSupportEnabled boolean property that switches the validator to XSD or DTD only. If you make it as enum (Prohibit, Parse, Ignore) it will make user life easier and in the case of DtdSupportEnabled = Parse they will be able to use XSD and DTD validation together (like me).

The latest build of this product (v24.1.0) 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.