<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dw="https://www.dreamwidth.org">
  <id>tag:dreamwidth.org,2009-05-05:290754</id>
  <title>The Lair of the SlowFox</title>
  <subtitle>slowfox</subtitle>
  <author>
    <name>slowfox</name>
  </author>
  <link rel="alternate" type="text/html" href="https://slowfox.dreamwidth.org/"/>
  <link rel="self" type="text/xml" href="https://slowfox.dreamwidth.org/data/atom"/>
  <updated>2010-01-07T10:26:03Z</updated>
  <dw:journal username="slowfox" type="personal"/>
  <entry>
    <id>tag:dreamwidth.org,2009-05-05:290754:89763</id>
    <link rel="alternate" type="text/html" href="https://slowfox.dreamwidth.org/89763.html"/>
    <link rel="self" type="text/xml" href="https://slowfox.dreamwidth.org/data/atom/?itemid=89763"/>
    <title>xsd.exe and the xs:import element</title>
    <published>2010-01-07T10:25:26Z</published>
    <updated>2010-01-07T10:26:03Z</updated>
    <category term="xsd"/>
    <category term="c#"/>
    <category term="xml"/>
    <category term="visual studio"/>
    <dw:mood>busy</dw:mood>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">I have spent a largely unprofitable hour trying to work out why &lt;b&gt;xsd.exe&lt;/b&gt; couldn't parse a specific .xsd file I was presenting it with.&lt;br /&gt;&lt;br /&gt;If, for example, the parent .xsd has a namespace reference of&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;tt&gt;...xmlns:sf="&lt;a href="http://slowfox.dreamwidth.org/"&gt;http://slowfox.dreamwidth.org/&lt;/a&gt;"...&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;followed by an &lt;t&gt;import&lt;/t&gt; element&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;tt&gt;&amp;lt;xs:import namespace="&lt;a href="http://slowfox.dreamwidth.org/"&gt;http://slowfox.dreamwidth.org/&lt;/a&gt;" schemaLocation="SlowFox.xsd"/&amp;gt;&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;then when running the xsd tool from the Visual Studio command prompt, you get the following error message:&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;Warning: Schema could not be validated. Class generation may fail or may produce incorrect results.&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;The answer, which I learnt courtesy of &lt;a href="http://www.hanselman.com/blog/XSDexeIsKickingMyButtManredux.aspx"&gt;Scott Hanselman&lt;/a&gt;'s blog is to provide all the dependent files on the command line, in addition to the parent .xsd.&lt;br /&gt;&lt;br /&gt;So you'd run&lt;br /&gt;&lt;br /&gt;&lt;b&gt;xsd.exe /c MainSchemaDefinition.xsd SlowFox.xsd&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;which produces the desired result (C# classes generated automagically from the .xsd).&lt;br /&gt;&lt;br /&gt;The issue, apparently, is that the xsd tool can't handle the xs:import element (despite the fact that you've given it an exact file name to match against the specified namespace), but if you provide all the consituent files as part of the command's argument, xsd.exe knows where to try and look for the various dependencies it stumbles across.&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=slowfox&amp;ditemid=89763" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
</feed>
