c# - Queries about validating xml with XmlReader -


My experience with the XmlReader class is mixed now, with validation of Xml data using the XmlReader class I have I want to clarify some basic doubts.

  1. I know that to set up some settings to use the XmlReaderSettings class, whether setting up the validity type, etc. and / or create a XmlReader with the XML object.
  2. I also know that you need to use all your schema files in the verification XmlSchemaSet class unless the schema is present inside the XML document (inline schema)

    XmlSchemaValidationFlags is a property in the class called XmlSchemaValidationFlags.ProcessSchemaLocation

    , so if the xml file contains the location of the specified xsd file, do I have to add the xsd file to the XmlSchemaSet class? I have placed the XDD file in the same diary as the XML file.

      & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Value_tables xmlns = "blur: value-schema" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schema location = "vase: value-schema value .xsd" & gt; & Lt; Table name = "Calibrated" & gt; & Lt; Value num = "0" & ​​gt; No & lt; / Value & gt; & Lt; Value num = "1" & gt; Yes & lt; / Value & gt; & Lt; / Table & gt; & Lt; / Value_tables & gt;   

    Question 2 Also, is it possible to retrieve the name of this file from xml document instead of hardcoding?

    You usually need to supply a Google EntityResolver that tells Parser Where to find outer referenced documents, you can pick the location of the resolver directly from the namespace URI (but it is not recommended; I think I remember that some XBRL taxonomies use this approach IIRC).

    EntityResolver implementation that performs simple things (like: look in a directory or download URI as a http URL), but in my experience I always had to code EntityResolve one way or another This is not too much work anyway

Comments