xsi:schemaLocation is reserved for references to W3C XML Schema describing namespaces and its content is a sequence of alternating values of namespace URIs and corresponding schema paths. An XML documents can be linked with their schemas using the schemaLocation attribute. In order for the XML serialization process to produce this attribute, the following must settings must be set :

In the xsd2code++ settings, you can specify the SchemaLocation. This option can be found in the Serialization, XmlOuput, SchemaLocation section.

Of course it is necessary to enable the generation of XML attributes in the section "Output property settings", XmlAttribute.Enabled=true


referencing a Schema in schemaLocation


The code that will be generated will contain an additional public variable in each of the classes so that the serialization makes the expected attribute:


Sample of code
public partial class MyObject
    {
        
        #region Private fields
        private FileInformation _fileInformation;
        
        private List<MemoryRegion> _memoryRegion;
        
        [XmlAttribute("SchemaLocation", Namespace = XmlSchema.InstanceNamespace)]
        public string SchemaLocation = "http://www.w3.org/2001/XMLSchema-instance";
        
        ...
	}

As you can see the serialization has integrated the xsi:SchemaLocation attribute and the value defined in the xsd2code settings :

XML Output
<?xml version="1.0" encoding="utf-8"?>
<MyObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:SchemaLocation="http://www.w3.org/2001/XMLSchema-instance" xmlns="MyObject.MemoryLayout">
  <FileInformation dateTimeCreated="0001-01-01T00:00:00" dateTimeChanged="0001-01-01T00:00:00" xmlns="AllegroMicro.Common">
    <Description>Test</Description>
  </FileInformation>
</MyObject>