Visual Studio’s lesser-known Xml Schema features

John Tasler made me write this blog.  There I was quietly responding to various emails when John said to me, he said “hey, that would make a great blog”.  So don’t blame me, it was his idea 🙂

What was the question you ask?  Well Ming wanted to know how do you make Visual Studio automatically apply an xsd schema to a newly created XML file ?

Answer: You have lots of options.

 If your schema lives in %DevEnvDir%\..\..\Xml\Schemas, or anywhere in your currently loaded “Solution”, then all you need to do is reference the target namespace of your schema like this:

 

But if your schema needs to live some place else (like in the cloud) then you can reference it using xsi namespace trick like this:

But for this to work you have to enable downloads in the XML editor tools options miscellaneous tab (it is off by default):
And you should be sure the owner of the site that publishes this schema is happy with you doing that.  Especially if you are going to encourage lots of users to do the same.Lastly if you have a totally ad-hoc XML and schema location elsewhere you can set one or more schemas to use on a per-document basis using the document Properties windows like this:
If you are building a project item wizard then, you could automate this step if you want using VS automation api.
SchemaCatalogs:  But what a lot of people never think to ask is what if I have multiple schemas of different versions that use the same target namespace?
Well for functional completion on this topic, this is where the  SchemaCatalog file comes in:

<?xml version=1.0 encoding=utf-8?>
<SchemaCatalog xmlns=http://schemas.microsoft.com/xsd/catalog>

</SchemaCatalog>

See %DevEnvDir%\..\..\Xml\Schemas\catalog.xml for an example.  It can “associate” schemas from other VS directories using %InstallRoot%, and it can associate by file type with conditional expressions.

AirSim is “live” !

So if you love flying quadrocopters, as I do, then you’ll probably also love flying them in a simulator.  I recently worked on a cool new Simulator with a colleague in Microsoft Research and it was a blast.  The Unreal Game engine is astounding, I love what it can do with rendering reflections, grass blowing in the wind, shadows created by leaves on the trees that also move as the wind blows.  Amazing stuff.

We built the AirSim simulator because we needed a research platform where we could safely test out reinforcement learning algorithms for vision based control of the drone.  Well, obviously we don’t want to have to crash a real drone while it is “learning”, but the problem with existing simulators is they didn’t look real enough.  So we built a new drone simulator using Unreal engine and it works great!