Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML/XSD intellisense not working in Visual Studio 2010

I am working on xml and xsd files in VS 2010 but intellisense isn't working. Intellisense is working for the same files in VS 2008, however.

When I type '<xs:' options like "attribute", "complexType", "simpleType", or "element" do not appear.

Is there some difference between the VS 2008 and VS 2010 that I'm missing?

I add an xsd file to my solution. All the proper namespaces are generated automatically as such:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="XMLSchema2"
    targetNamespace="http://tempuri.org/XMLSchema2.xsd"
    elementFormDefault="qualified"
    xmlns="http://tempuri.org/XMLSchema2.xsd"
    xmlns:mstns="http://tempuri.org/XMLSchema2.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

</xs:schema>

The "xsdschema.xsd" is in the "C:\Program Files\Microsoft Visual Studio 10.0\xml\Schemas" directory.

There is a check mark in the "Use" column in the XML Schemas dialog box.

like image 358
Jason Avatar asked Jun 06 '10 23:06

Jason


People also ask

How do I view XSD files in Visual Studio?

You can access the XML Schema Explorer from a . vb file that has a Visual Basic XML literal associated with an . xsd file. To see the schema set in the XML Schema Explorer, right-click an XML node in an XML literal or an XML namespace import and select the Show in Schema Explorer command.

How connect XML to XSD?

Reference the XSD schema in the XML document using XML schema instance attributes such as either xsi:schemaLocation or xsi:noNamespaceSchemaLocation. Add the XSD schema file to a schema cache and then connect that cache to the DOM document or SAX reader, prior to loading or parsing the XML document.

How do I add an XML Schema in Visual Studio?

In Visual Studio, open the File menu and select New > File. Or, use the Ctrl+N keyboard shortcut. In the New File dialog box, select XML Schema and then select Open. A new file is created.


2 Answers

I discovered what happened. Visual Studio 2010 imported the schemas from Visual Studio 2008. This caused duplication warnings like the one below:

Warning The global attribute 'http://www.w3.org/XML/1998/namespace:lang' has already been declared. C:\Program Files\Microsoft Visual Studio 10.0\xml\Schemas\xml.xsd   

In the XML Schemas dialog, I removed the old ones from the schema cache. You'll have to restart Visual Studio.

like image 192
Jason Avatar answered Oct 13 '22 02:10

Jason


The intellisense and schema validation will disappear if there are warnings not been resolved; like having duplicate complex types defines in different files withing the same schema namespace.

like image 24
Daniel Marzan Avatar answered Oct 13 '22 01:10

Daniel Marzan