title: How do you generate xsd namespace prefixes in the resulting output file?
body: <p>I've gone over multiple topics and solutions that talk specifically about this issue. None have worked or I fail to understand what I am doing wrong.</p>
  
  <p>I would like for the namespace prefixes to accompany the element names in the resulting xml output file.</p>
  
  <p>I'm am using the XSD command with Visual Studio 2008 from the VS Command Prompt</p>
  
  <p>Here's my xsd schema for <strong>Trial.xsd</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xs:schema id="Junk"
         targetNamespace="http://www.opengis.net/kml/2.2"
         xmlns="http://www.opengis.net/kml/2.2"
         xmlns:gx="http://www.google.com/kml/ext/2.2"
         xmlns:kml="http://www.opengis.net/kml/2.2"
         xmlns:xs="http://www.w3.org/2001/XMLSchema"
         elementFormDefault="qualified"&gt;
  
  &lt;xs:import namespace="http://www.google.com/kml/ext/2.2" schemaLocation="TestSchema.xsd" /&gt;
  
  &lt;!-- Start LookType --&gt;
  &lt;xs:complexType name="LookType"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element ref="gx:TimeSpan" minOccurs="0" /&gt;
      &lt;xs:element name="longitude" type="xs:string" /&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  &lt;!-- End LookType --&gt;
  
  &lt;xs:element name="Te" type="LookType" /&gt;
  
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>Here's my xsd schema for <strong>TestSchema.xsd</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xs:schema id="TestSchema"
  targetNamespace="http://www.google.com/kml/ext/2.2"
         xmlns="http://www.google.com/kml/ext/2.2"
         xmlns:gx="http://www.google.com/kml/ext/2.2"
         xmlns:xs="http://www.w3.org/2001/XMLSchema"
         elementFormDefault="qualified"&gt;
  
  &lt;xs:element name="TimeSpan" type="gx:GXTimeSpanType" /&gt;
  
  &lt;!-- Start GXTimeSpanType --&gt;
  &lt;xs:complexType name="GXTimeSpanType"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="begin" type="xs:string" /&gt;
      &lt;xs:element name="end" type="xs:string" /&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  &lt;!-- End GXTimeSpanType --&gt;
  
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>I´m generating the resulting class file <code>Trial.cs</code> by using <code>xsd TestSchema.xsd ./Trial.xsd /c /l:cs /n:T</code></p>
  
  <p>In a program I assign these junk values and write them to file using <code>XmlDocument</code>, <code>XmlSerializer</code> and <code>FileStream</code></p>
  
  <pre><code>T.LookType te = new T.LookType();
  te.longitude = "34.444";
  te.TimeSpan = new T.GXTimeSpanType();
  te.TimeSpan.begin = "2010-02-26T20:22:00Z";
  te.TimeSpan.end = "2010-02-26T20:23:42Z";
  </code></pre>
  
  <p>I've excluded the method that saves out the file using <code>XmlDocument</code>, <code>XmlSerializer</code> and <code>FileStream</code> as it is a little thicker then I'd like to post unless that is part of the problem.</p>
  
  <p>This is what I get in the resulting file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-16"?&gt;
  &lt;Te xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns="http://www.opengis.net/kml/2.2"&gt;
  
    &lt;TimeSpan xmlns="http://www.google.com/kml/ext/2.2"&gt;
      &lt;begin&gt;2010-02-26T20:22:00Z&lt;/begin&gt;
      &lt;end&gt;2010-02-26T20:23:42Z&lt;/end&gt;
    &lt;/TimeSpan&gt;
    &lt;longitude&gt;34.444&lt;/longitude&gt;
  &lt;/Te&gt;
  </code></pre>
  
  <p>This is what I want in the resulting file. Notice the <code>gx:TimeSpan</code> element and the <code>xmlns:gx</code> namespace definition being added to the main <code>Te</code> element.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-16"?&gt;
  &lt;Te xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns="http://www.opengis.net/kml/2.2"
  xmlns:gx="http://www.google.com/kml/ext/2.2"&gt;
    &lt;gx:TimeSpan&gt;
      &lt;begin&gt;2010-02-26T20:22:00Z&lt;/begin&gt;
      &lt;end&gt;2010-02-26T20:23:42Z&lt;/end&gt;
    &lt;/gx:TimeSpan&gt;
    &lt;longitude&gt;34.444&lt;/longitude&gt;
  &lt;/Te&gt;
  </code></pre>