Advertisement

03.29.2008 at 09:20AM PDT, ID: 23279534
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.5

VS2005  Linking XML document to XSD file

Asked by FJRMill in .NET, Microsoft Visual Basic.Net

Tags:

Dear experts

I need to handle xml data using visual basic in a windows forms project in Visual Studio 2005. My intention is to create an XML file, linked to an .XSD file to represent a small collection of database tables. I am designing an application to read in data from the XML file, append new records, amend records, and display selected records.

New to this, work has quickly ground to a halt because the guidance I am following suggests that once a schema file has been created, it is very simple to add a new XML document to the VS project and link this to the schema.

I have replicated the .XSD file provided as an example
See code snippet:



However, when I add a new .xml document to the project, by default, the new document contains only a single line:
<?xml version="1.0" encoding="utf-8" ?>

VS2005 shows an error (red wiggly) at the end of the line. Hovering the cursor over the red wiggly displays following error text:
XML document must contain a root level element


Please look at the LearnVisualStudio video here:
http://gmilner.myzen.co.uk/2502.wmv


In this video, at about 1 minute 20 seconds, the trainer demonstrates the creation of an xml document within Visual Studio .. but he does not get the root element error I am experiencing.  OK, it is likely that he is using a different version of VS,  also, the video refers to the TargetSchema property, where XML documents in VS2005 have a Schemas property.

I have hooked the Schemas property of  my new XML document to my XSD file but this appears to have no effect in the XML document.


My question:
In VS 2005, how do we associate an XML document with an XSD schema file, so that when the xml document is opened in Data view in Visual Studio, the XSD structure is applied?

Linked question:
http://www.experts-exchange.com/Database/Miscellaneous/Q_23266426.html
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="EmplyeesSchema" targetNamespace="http://tempuri.org/EmplyeesSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/EmplyeesSchema.xsd" xmlns:mstns="http://tempuri.org/EmplyeesSchema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:simpleType name="ZipCode">
    <xs:restriction base="xs:positiveInteger">
      <xs:pattern value="\d{5}" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="Address">
    <xs:sequence>
      <xs:element name="Name" type="xs:string" />
      <xs:element name="Street" type="xs:string" />
      <xs:element name="State" type="xs:string" />
      <xs:element name="Zip" type="ZipCode" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="EmployeeList">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Employee">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Email" type="xs:string" />
              <xs:element name="Password" type="xs:string" />
              <xs:element name="HomeAddress" type="Address" />
              <xs:element name="OtherAddress" type="Address" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
 
 
[+][-]03.30.2008 at 05:24AM PDT, ID: 21240448

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.31.2008 at 02:44AM PDT, ID: 21244152

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.31.2008 at 05:46AM PDT, ID: 21244828

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.31.2008 at 06:54AM PDT, ID: 21245343

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.31.2008 at 07:13AM PDT, ID: 21245519

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.31.2008 at 12:16PM PDT, ID: 21248207

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.31.2008 at 12:35PM PDT, ID: 21248377

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET, Microsoft Visual Basic.Net
Tags: Visual Basic (Visual Studio 2005, Windows Forms)
Sign Up Now!
Solution Provided By: TheLearnedOne
Participating Experts: 1
Solution Grade: B
 
 
[+][-]04.01.2008 at 01:40PM PDT, ID: 21257893

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.01.2008 at 06:30PM PDT, ID: 21259486

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-42 / EE_QW_2_20070628