?
Solved

Problems of noNamespaceSchemaLocation in VB.NET

Posted on 2003-03-24
4
Medium Priority
?
876 Views
Last Modified: 2013-11-19
Hi,

I want to learn XML, and copy the sample schema and XML data into VB.NET environment to validate.
the sample is simple, mainly copied form "professional XML" textbook.

The two files are named: noNs.xsd and noNs.xml, and put into same directory. and when I validate
the xml data file, there will be some errors.

I donot know where is the problem, is it because the VB environment does not support this kind
noNamespaceSchemaLocation usage? or we need do some changes to files or to VB setting?

(and if I let the schema has its targetNamespace,and without noNamespaceSchemaLocation, it works.)
Below is some related info:

1. When validate schema, no validation errors were found.
2. When validate XML data, there are 6 build errors:
   1. to 5. The element: customerList, customerName, FirstName, MiddleInitial,LastName, not declared.
   6. Visual Studio could not locate a schema for this document. Validation can only ensure this is a
      well formed XML document and cannot validate the data against a schema.
3. the schema and xml data file attached here:

noNs.xsd:
---------
<?xml version="1.0" encoding="utf-8" ?>
<schema id="noNs" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="customerList">
     <complexType>
     <sequence>
          <element name="customerName" minOccurs="0" maxOccurs="3">
               <complexType>
               <sequence>
                    <element name="FirstName" type="string"></element>
                    <element name="MiddleInitial" type="string"></element>
                    <element name="LastName" type="string"></element>
               </sequence>
               </complexType>
          </element>
     </sequence>
     </complexType>
</element>
</schema>
---------

noNs.xml:
---------
<?xml version="1.0" encoding="utf-8" ?>
<customerList xmlns:xsi="http://wwwv.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="noNs.xsd">
     <customerName>
          <FirstName>Raymond</FirstName>
          <MiddleInitial>G</MiddleInitial>
          <LastName>Bayliss</LastName>
     </customerName>
</customerList>
---------
ps: I also tried the absolute path and file for noNamespaceSchemaLocation, it has the same errors.

Thanks,
Gary
0
Comment
Question by:garyge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 6

Expert Comment

by:Wayne Bradney
ID: 8247438
garyge,

I think your problem is probably due to a typo in your xsi namespace prefix declaration:

http://wwwv.w3.org/2001/XMLSchema-instance

should be

http://www.w3.org/2001/XMLSchema-instance

Your schema is correctly referenced, but the validating parser won't recognise the grammars within it because it's in the wrong namespace.

Regards,
WMB
0
 

Author Comment

by:garyge
ID: 8254698
Hi WMB,
Thanks for your reply.
I have made a mistake in typewriting,(actually I copied it to post and maybe copied from wrong place). In my visual studio environment, I checked the namespace which is correct, without 'v', but same errors still existed.
0
 
LVL 6

Accepted Solution

by:
Wayne Bradney earned 100 total points
ID: 8255540
garyge,

It would appear that VS.NET doesn't honour the schemaLocation/noNamespaceSchemaLocation attributes. According to the XML Schema spec, it doesn't have to honour those attributes: they're just a hint.

I don't use VS.NET to validate documents, but I did a little digging and found the following link:

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q307379&ID=kb;en-us;Q307379&SD=MSDN

Maybe you'll need to write a small application to load the document and the schema in order to validate.

Regards,
WMB
0
 

Author Comment

by:garyge
ID: 8258540
Hi WMB,
Thank you very much, I will check the link and write some code to validate it. Thanks for your direction.
0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question