473,698 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using .xsd files

My message concerns a sample application that I took verbatim from the book
titled "SAMS Teach Yourself Visual Basic.NET Web Programming in 21 days".
It consists of a web page that takes the names of an XML file and
corresponding XML schema (XSD) file as input (via text boxes) and is
supposed to perform a
validation on the XML file. When I run it, I get the following error
message after entering the file names and clicking on the "Validate" button:

Run-time exception thrown : System.Xml.XmlE xception - The 'xsd:element'
start tag on line '7' doesn't match the end tag of 'xsd:schema' in file
'file:///C:/Inetpub/wwwroot/Practice/simple.xsd'. Line 17, position 3.

Can anyone explain why I get this error?

(I am getting errors also with other sample XML schema-related applications
with this book, so I may have follow-up messages.)

Bob Rosen
Here is the .aspx file that I am executing:

-----------------------------------------------------------

<%@ Page Language="vb" debug="true"%>
<%@ Import Namespace="Syst em.Xml.Schema" %>
<%@ Import Namespace="Syst em.Xml" %>
<HTML>
<script runat="server">
sub CheckXML(Sender as Object, e as EventArgs)

Dim sourceXML as String = Server.MapPath( xmlFileName.Tex t)
Dim sourceXSD as String = Server.MapPath( xsdFileName.Tex t)

errorMessage.Te xt = "Successful ly validated " & xmlFileName.Tex t & _
" using " & xsdFileName.Tex t
Dim validatingReade r as XmlValidatingRe ader
Dim xmlReader as XmlTextReader
Dim xsdReader as XmlTextReader
Dim testSchemaColle ction as new XmlSchemaCollec tion()
try
xsdReader = new XmlTextReader(s ourceXSD)
testSchemaColle ction.Add(xsdFi leName.Text, xsdReader)
xmlReader = new XmlTextReader(s ourceXML)
validatingReade r = new XmlValidatingRe ader(xmlReader)
validatingReade r.Schemas.Add(t estSchemaCollec tion)
validatingReade r.ValidationTyp e = ValidationType. Schema
AddHandler validatingReade r.ValidationEve ntHandler, _
AddressOf Me.ValidationCa llback

while (validatingRead er.Read())
end while
catch ex as Exception
errorMessage.Te xt = "XXX" & ex.ToString()
finally
if not xmlReader is nothing then xmlReader.Close ()
if not xsdReader is nothing then xsdReader.Close ()
if not validatingReade r is nothing then validatingReade r.Close()
end try
End Sub

sub ValidationCallb ack(sender as object, args as ValidationEvent Args)

if args.Severity = XmlSeverityType .Warning then
errorMessage.Te xt = "Warning: "
end if
if args.Severity = XmlSeverityType .Error then
errorMessage.Te xt = "Error: "
end if
if not args.Exception is nothing then
errorMessage.Te xt &= args.Message & " at line " & _
args.Exception. LineNumber & _
" position " & args.Exception. LinePosition & ControlChars.Cr Lf
end if
End Sub
</script>
<body>
<font face="arial">
<form runat="server">
<h3>XML validation using XSD</h3>
Source XML File:
<asp:TextBox id="xmlFileName " runat="server" /><br>
Source XSD Schema:
<asp:TextBox id="xsdFileName " runat="server" /><br>
<asp:Button Text="Validate" OnClick="CheckX ML" runat="server"
id="Button1" />
<br>
<asp:Label id="errorMessag e" runat="server" />
</form>
</font>
</body>
</HTML>

-----------------------------------------------------------

Here is the .XML file that I am using as input:

-----------------------------------------------------------

<?xml version="1.0" ?>
<computer xmlns="simple.x sd">
<name>Bob's Computer</name>
<os>Windows XP</os>
<speed>800</speed>
<memory>256</memory>
</Computer>

-----------------------------------------------------------

and here is the .XSD file (simple.xsd) that I am using as input:

-----------------------------------------------------------

<?xml version="1.0" ?>
<xsd:schema xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns="simple.x sd"
targetNamespace ="simple.xsd "
elementFormDefa ult="qualified" >

<xsd:element name="computer" >
<xsd:complexTyp e name="computerT ype">
<xsd:sequence >
<xsd:element name="name" type="xsd:strin g" />
<xsd:element name="os" type="xsd:strin g" />
<xsd:element name="speed" type="xsd:decim al" />
<xsd:element name="memory" type="xsd:decim al" />
</xsd:sequence>
</xsd:complexType >
</xsd:computer>
</xsd:schema>


Jul 19 '05 #1
0 5659

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

121
10080
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
1
2757
by: Xiangliang Meng | last post by:
Hi, all. Recently, I find there is a way in our project to maintain a global set in many files by using preprocessing directives. I'm wondering if we could find a better method for this. Many colors are referred in different subsystems in our projects. They are defined as enumeration constants and a single color must be the same value all across our projects.
3
2047
by: Dan Kjaergaard | last post by:
Hi I created a program using C#, which iterates files and displays these in a listview. However I would like to filter the files, so files won't be displayed if the current user hasn't "read access" any clever way to do that in the .NET Framework using C#? thanks
1
1842
by: Asha | last post by:
greetings, i need to upload an .xls file using a secure connection. so i though of using https... can i know how this can be done?
5
6770
by: Michael Sperlle | last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems to need changes to the kernel before it can be installed, and I have no intention of going through whatever hell that would cause. If I could create a large file that could be encrypted, and maybe add files to it by appending them and putting in some kind of delimiter between files, maybe a homemade version of truecrypt could be constructed. Any idea what it...
1
1926
by: ligong.yang | last post by:
Hi all, I got tortured by a very weird problem when I was using k. wilder's random generator class in my program. PS: wilder's generator class can be found at http://oldmill.uchicago.edu/~wilder/Code/random/. Firstly, I got the notorious "fatal error C1010: unexpected end of file while looking for precompiled header directive" error when I tried to compile 'randtest.c' provided by wilder.
1
2640
by: ansc1 | last post by:
Hello, I'm new to using php coding. I need help with the following: 1. There is a submit button on the form and is saves information to my database. After clicking on "Save Measurement" it redirects me to another page in my site. What I would like to do is change what page directs it to. Currently the submit button redirects me to page /measure/men_measure. I would like to be able to change this. Please see below my page below:...
21
34412
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
221
367516
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application needs to store entire files, the preferred method is to save the file onto the server’s file-system, and store the physical location of the file in your database. This is generally considered to be the easiest and fastest way to store files. ...
0
2191
by: rajasankar | last post by:
Hi, I am using Jython based application and trying to use inspect.py in the python files. Here is my code import inspect,os,sys,pprint,imp def handle_stackframe_without_leak(getframe): frame = inspect.currentframe() try: function = inspect.getframeinfo(getframe)
0
8676
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9164
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7734
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3051
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.