Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I get LinqToXSD to properly output namespace prefix declarations?
    primarykey
    data
    text
    <p>I am experimenting creating XML data binding classes with <a href="http://linqtoxsd.codeplex.com/">LinqToXSD</a> and an XML Schema containing a number of imported schemas. All of the schemas are <strong><a href="http://www.spiraltechinc.com/Tmats/">located here.</a></strong> </p> <p>To accomplish this, I used the following root schema document:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:TmatsG="http://www.spiraltechinc.com/tmats/106-13/TmatsG" elementFormDefault="unqualified"&gt; &lt;xs:import namespace="http://www.spiraltechinc.com/tmats/106-13/TmatsCommon" schemaLocation="TmatsCommonTypes.xsd"/&gt; &lt;xs:import namespace="http://www.spiraltechinc.com/tmats/106-13/TmatsC" schemaLocation="TmatsCGroup.xsd"/&gt; &lt;xs:import namespace="http://www.spiraltechinc.com/tmats/106-13/TmatsD" schemaLocation="TmatsDGroup.xsd"/&gt; &lt;xs:import namespace="http://www.spiraltechinc.com/tmats/106-13/TmatsG" schemaLocation="TmatsGGroup.xsd"/&gt; &lt;xs:import namespace="http://www.spiraltechinc.com/tmats/106-13/TmatsH" schemaLocation="TmatsHGroup.xsd"/&gt; &lt;xs:import namespace="http://www.spiraltechinc.com/tmats/106-13/TmatsM" schemaLocation="TmatsMGroup.xsd"/&gt; &lt;xs:import namespace="http://www.spiraltechinc.com/tmats/106-13/TmatsP" schemaLocation="TmatsPGroup.xsd"/&gt; &lt;xs:import namespace="http://www.spiraltechinc.com/tmats/106-13/TmatsR" schemaLocation="TmatsRGroup.xsd"/&gt; &lt;xs:import namespace="http://www.spiraltechinc.com/tmats/106-13/TmatsS" schemaLocation="TmatsSGroup.xsd"/&gt; &lt;xs:import namespace="http://www.spiraltechinc.com/tmats/106-13/TmatsT" schemaLocation="TmatsTGroup.xsd"/&gt; &lt;xs:import namespace="http://www.spiraltechinc.com/tmats/106-13/TmatsV" schemaLocation="TmatsVGroup.xsd"/&gt; &lt;xs:element name="Tmats" type="TmatsG:Tmats"&gt; &lt;xs:annotation&gt; &lt;xs:documentation&gt;Tmats Root&lt;/xs:documentation&gt; &lt;/xs:annotation&gt; &lt;/xs:element&gt; &lt;/xs:schema&gt; </code></pre> <p>I created classes using Linq to XSD. I then wrote the following test: </p> <pre><code>[TestMethod()] public void TmatsXmlExample4() { Tmats tmats = new Tmats { ProgramName = "My Program", OriginationDate = DateTime.Now, }; tmats.PointOfContact.Add(new PointOfContactType { Address = "12345 Anywhere Street", Agency = "My Agency", Name = "Robert Harvey", Telephone = "111-222-3333" }); Debug.Print(tmats.ToString()); } </code></pre> <p>I expected output that looked something like this:</p> <pre><code>&lt;Tmats&gt; &lt;TmatsG:ProgramName&gt;My Program&lt;/TmatsG:ProgramName&gt; &lt;TmatsG:OriginationDate&gt;2012-05-09-07:00&lt;/TmatsG:OriginationDate&gt; &lt;TmatsG:PointOfContact&gt; &lt;TmatsCommon:Name&gt;Robert Harvey&lt;/TmatsCommon:Name&gt; &lt;TmatsCommon:Agency&gt;My Agency&lt;/TmatsCommon:Agency&gt; &lt;TmatsCommon:Address&gt;12345 Anywhere Street&lt;/TmatsCommon:Address&gt; &lt;TmatsCommon:Telephone&gt;111-222-3333&lt;/TmatsCommon:Telephone&gt; &lt;/TmatsG:PointOfContact&gt; &lt;/Tmats&gt; </code></pre> <p>Instead, what I got was this:</p> <pre><code>&lt;Tmats&gt; &lt;ProgramName xmlns="http://www.spiraltechinc.com/tmats/106-13/TmatsG"&gt;My Program&lt;/ProgramName&gt; &lt;OriginationDate xmlns="http://www.spiraltechinc.com/tmats/106-13/TmatsG"&gt;2012-05-09-07:00&lt;/OriginationDate&gt; &lt;PointOfContact xmlns="http://www.spiraltechinc.com/tmats/106-13/TmatsG"&gt; &lt;Name xmlns="http://www.spiraltechinc.com/tmats/106-13/TmatsCommon"&gt;Robert Harvey&lt;/Name&gt; &lt;Agency xmlns="http://www.spiraltechinc.com/tmats/106-13/TmatsCommon"&gt;My Agency&lt;/Agency&gt; &lt;Address xmlns="http://www.spiraltechinc.com/tmats/106-13/TmatsCommon"&gt;12345 Anywhere Street&lt;/Address&gt; &lt;Telephone xmlns="http://www.spiraltechinc.com/tmats/106-13/TmatsCommon"&gt;111-222-3333&lt;/Telephone&gt; &lt;/PointOfContact&gt; &lt;/Tmats&gt; </code></pre> <p>Is there a way to get LinqToXSD to produce the expected output? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload