How to report an error for XML with xmlns, which differs from one in XSD?

SyntaxEditor Web Languages Add-on for Windows Forms Forum

Posted 10 years ago by AlexanderB - Software Developer, Edifecs
Version: 13.1.0311
Avatar

We need to catch the case when user edits XML with nodes where "xmlns" attribute is different from "targetNamespace" and "xmlns" defined in XSD.

For example, lets take your SyntaxEditor Demo called "XML Editor (Web Lang. Add-on)".

This demo contains XSD file "Mammals.xsd" which is intended to validate documents with namespace "http://ActiproSoftware/Mammals".

Now let's switch to XML file from this example - "Mammals-Dog.xml". It contains root element that looks as following:

<mammal xmlns="http://ActiProSoftware/Mammals" species="Dog" locomotion="terrestrial">

 In case if I change value of "xmlns" attribute in this "mammal" element or just delete the attribute at all, SyntaxEditor will stop performing XSD validation of "mammal" node inner contents.

In this case I would like to get validation message saying that "mammal" element is not expected here (or some custom message).

For example, MS Visual Studio's 2010 editor in this case shows message "Could not find schema information for the element 'mammal'"

 

Is there any easy way to achieve this behavior? Please suggest a direction to move.

Thank you in advance

Comments (3)

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

Hi Alexander,

If you inherit our XmlValidator class and override the CreateXmlReader method, look at the settings parameter.  I believe you might need to change the ValidationFlags to include ReportValidationWarnings.  Then call the base method.

Once you have that, register your updated class as an IXmlValidator service on the language, which should replace our original instance with yours.


Actipro Software Support

Posted 10 years ago by AlexanderB - Software Developer, Edifecs
Avatar

Thank you for your answer.

The only problem - class ActiproSoftware.Text.Languages.Xml.Implementation.XmlValidator does not expose CreateXmlReader method. Are you sure class and method name are correct? I tried to find correct class/method by myself, but unsuccesfully.

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

Hi Alexander,

It's protected access in the recent versions.  I see now you said you were on 2013.1.  This change might have been made after that.


Actipro Software Support

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.