views:

32

answers:

1

I know I have done this before, but it isn't working today, nor can I find anywhere that explains how to do it. It could be my lack of sleep, but I suspect gremlins.

I have an XML document and a directory full of XSD's that define it. How do I set the Visual IDE up to notify me of validation failures, and then provide an intellisense list of valid tags and attributes in a given context?

What I have tried:

  • I've added the XSD's to the project with the XML document.
  • I've added the XSD's to the XML Schema list (under XML / Schemas... menu item.)
  • I've even included the schemaLocation and noNamespaceSchemaLocation attributes to the XML document.

Visual Studio still isn't giving up any useful debugging or editing information. I tried both 2010 and 2008 (I've done it before in 2008 I thought)

Update: I had another developer try this and it failed for him too. He knows he has done it with other XML documents and had it work. I then downloaded Oxygen XML editor and it worked fine on the same XML and XSD files, so the files seem to be fine (or Oxygen is more forgiving / flexible . . . )

+3  A: 

Jim,

You need to associate the XML document in Visual Studio with the XSD file you have - you should see something like this in your Properties window of the XML document:

alt text

In the XML schema set editor (opens when you click on the (...) ellipsis in the "Schemas" textbox in your Properties window) you need to make sure you have your schema present. Also, make sure the Use column for that schema is enabled - if not, click on it - you'll get a drop-down list of options, pick the Use one with the green checkmark:

alt text

Once all of that is in place, the Visual Studio XML editor should highlight problems with your XML in the editor using blue squigglies:

alt text

marc_s
Thanks, that is a great detailed explanation, but mine still isn't working. I didn't know you could get to the schemas list from properties like that.
Jim McKeeth
@Jim McKeeth: what if you modify your XML and save it again? Sometimes the XML validation needs a trigger to kick in...
marc_s
I've accepted your answer even though it didn't work for me. I am guessing my system was just hosed, but I have moved to a new computer and everything works fine now.
Jim McKeeth