.net - Xml Validation error: validating against empty schema set -


  1. i getting error

    the xmlschemaset on document either null or has no schemas in it. provide schema information before calling validate.

    but have schema file located in location specified: c:\invschema.xsd

    there no specific namespace passed, set empty.

    so, why getting error?

  2. i need know if xml schema validated, validate function no return boolean value confirming it.

    how can value invimp.validate(evthandler)?

below code:

 private function validateschema() boolean             try                 dim settings xmlreadersettings = new xmlreadersettings()                 settings.schemas.add("", "c:\invschema.xsd")                 settings.validationtype = validationtype.schema                 dim evthandler validationeventhandler = new validationeventhandler(addressof validationeventhandler)                 dim reader xmlreader = xmlreader.create(_filename, settings)                 dim invimp xmldocument = new xmldocument                 invimp.validate(evthandler)                               validateschema = true             catch ex exception                 throw ex                 validateschema = false             end try         end function   shared sub validationeventhandler(byval sender object, byval e validationeventargs)         select case e.severity             case xmlseveritytype.error                 library.log("schema validation failed error " & e.message, logtype.errorlog, importtype.invcimp)             case xmlseveritytype.warning                 library.log("schema validation warning " & e.message, logtype.eventlog, importtype.invcimp)         end select                 end sub 

i think there 2 problems. event handler isn't getting added , xmlreader should used validate instead of separate xmldocument object:

private function validateschema() boolean     try         dim settings xmlreadersettings = new xmlreadersettings()         settings.schemas.add("", "c:\invschema.xsd")         settings.validationtype = validationtype.schema         addhandler settings.validationeventhandler, addressof validationeventhandler         dim reader xmlreader = xmlreader.create(_filename, settings)          while reader.read             'triggers validation'         loop      catch ex exception         throw ex     end try     return _valid end function 

you should set member level boolean (_valid) in event handler. event handler called every schema violation found.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -