views:

229

answers:

2

I have defined a xml schema as below

<?xml version="1.0" encoding="utf-8"?>

<xs:schema id="PacketTemplate"
targetNamespace="http://tempuri.org/PacketTemplate.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/PacketTemplate.xsd"
xmlns:mstns="http://tempuri.org/PacketTemplate.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;

<xs:group name="packetTemplate">
  <xs:sequence id="packetTemplateSequence" >

   <xs:element name="packetType" maxOccurs="1" minOccurs="1" nillable="false" >
    <xs:complexType >
      <xs:attribute name="packetCode" type="xs:string" use="required"></xs:attribute>
      <xs:attribute name="packetTypeIncoming" type="xs:boolean" use="required"></xs:attribute>    
    </xs:complexType>
  </xs:element>
  <xs:element name="packetFieldInfo" minOccurs="1" maxOccurs="unbounded">
    <xs:complexType>
      <xs:attribute name="fieldName" type="xs:Name" use="required"></xs:attribute>
      <xs:attribute name="fieldNumber" type="xs:integer" use="required"></xs:attribute>
      <xs:attribute name="conversionCode" type="xs:integer" use="required"></xs:attribute>
      <xs:attribute name="fieldInUse" type="xs:boolean" use="required"></xs:attribute>

     </xs:complexType>
  </xs:element>
</xs:sequence>

now when i write xml file corresponding to this schema i am not able to use intellisense features like it should show all of possible tags in my file?

Beside that what should i do so that this xml file refer the schema file i have defined? Xml file is as below.

    <?xml version="1.0" encoding="utf-8" ?>
    <packetTemplate>
       <packetType packetCode="601" packetTypeIncoming="123" fieldInUse="true">
       </packetType>
    </packetTemplate>
A: 

In Visual Studio you can open the *.xml file and in the properties window you can specify the schema file in the property Schemas.

That way Visual Studio should provide Intellisense, assuming the provided schema is valid.

You can check the W3Schools examples in how to create a XML schema.

João Angelo
intellisense is still not working
Maddy.Shik
Is your schema valid?
João Angelo
+1  A: 

Another way to validate your XML with your XSD is to specify the XSD when you use msxml, and then you don't have to mark up your XML. I don't know if there is a real advantage going one way or the other.

Dave