XmlValidatingReader unbelievable error

Hi everyone, I am trying now for 4-5 hours to write a simple code to
validate a very simple XML and i still get an error. Here is my Code,
and i always get an error at args.Exception
 
("The 'urn:books:catalog' element is not declared. An error occurred
at file:///c:/inetpub/wwwroot/LakisService/books.xml, (2, 2).")

private void Button2_Click(object sender, System.EventArgs e) {
	XmlTextReader r = new XmlTextReader(Server.MapPath("books.xml"));
	XmlSchema xs = new XmlSchema();
	xs.SourceUri = Server.MapPath("books.xsd");
			
	XmlValidatingReader v = new XmlValidatingReader(r);
	v.Schemas.Add(xs);
	v.ValidationType = ValidationType.Schema;
	v.ValidationEventHandler += new ValidationEventHandler(MyValidation);
			while (v.Read()){
			}
			v.Close();
}

public static void MyValidation(object sender, ValidationEventArgs
args){
string strErr="";
	if (args.Exception != null){
		strErr = args.Message;
	}
}

HERE IS XML FILE
--------------
<?xml version="1.0" encoding="utf-8" ?> 
<x:catalog xmlns:x="urn:books">
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications with
      XML.</description>
   </book>
</x:catalog>

HERE IS XSD FILE
---------------
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="catalog">
	<xsd:complexType>
		<xsd:sequence>
		<xsd:element name="book" minOccurs="0" maxOccurs="unbounded">
			<xsd:complexType>
			<xsd:sequence>
			<xsd:element name="author" type="xsd:string" />
			<xsd:element name="title" type="xsd:string" />
			<xsd:element name="genre" type="xsd:string" />
			<xsd:element name="price" type="xsd:float" />
			<xsd:element name="publish_date" type="xsd:date" />
			<xsd:element name="description" type="xsd:string" />
			</xsd:sequence>
			<xsd:attribute name="id" type="xsd:string" />
				</xsd:complexType>
			</xsd:element>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
</xsd:schema>


Please if anyone knows help!!

Thanks
0
amaretos (1)
7/13/2004 3:25:53 PM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
575 Views

Similar Articles

[PageSpeed] 17


Amar wrote:


> ("The 'urn:books:catalog' element is not declared. An error occurred
> at file:///c:/inetpub/wwwroot/LakisService/books.xml, (2, 2).")

> HERE IS XML FILE
> --------------
> <?xml version="1.0" encoding="utf-8" ?> 
> <x:catalog xmlns:x="urn:books">
>    <book id="bk101">
>       <author>Gambardella, Matthew</author>
>       <title>XML Developer's Guide</title>
>       <genre>Computer</genre>
>       <price>44.95</price>
>       <publish_date>2000-10-01</publish_date>
>       <description>An in-depth look at creating applications with
>       XML.</description>
>    </book>
> </x:catalog>
> 
> HERE IS XSD FILE
> ---------------
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <xsd:element name="catalog">

Well you need to define the element in the right namespace, in your 
schema it has no namespace but in the XML instance it has a namespace. 
However usually you need to have one schema per namespace.


-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/

0
mahotrash (1778)
7/13/2004 3:37:15 PM
Amar wrote:

> <x:catalog xmlns:x="urn:books">
>    <book id="bk101">
>       <author>Gambardella, Matthew</author>
>       <title>XML Developer's Guide</title>
>       <genre>Computer</genre>
>       <price>44.95</price>
>       <publish_date>2000-10-01</publish_date>
>       <description>An in-depth look at creating applications with
>       XML.</description>
>    </book>
> </x:catalog>
> 
> HERE IS XSD FILE
> ---------------
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <xsd:element name="catalog">

Well, you schema doesn't define catalog element in "urn:books" 
namespace. Instead it defines catalog element in no namespace.
So either remove namespace from catalog element in your XML or change 
the schema.
-- 
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
0
Oleg
7/13/2004 4:34:00 PM
Change your schema to the following:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                        xmlns="urn:books" targetNamespace="urn:books">


"Amar" <amaretos@yahoo.com> wrote in message
news:7c627043.0407130725.5d0a9b8c@posting.google.com...
> Hi everyone, I am trying now for 4-5 hours to write a simple code to
> validate a very simple XML and i still get an error. Here is my Code,
> and i always get an error at args.Exception
>
> ("The 'urn:books:catalog' element is not declared. An error occurred
> at file:///c:/inetpub/wwwroot/LakisService/books.xml, (2, 2).")
>
> private void Button2_Click(object sender, System.EventArgs e) {
> XmlTextReader r = new XmlTextReader(Server.MapPath("books.xml"));
> XmlSchema xs = new XmlSchema();
> xs.SourceUri = Server.MapPath("books.xsd");
>
> XmlValidatingReader v = new XmlValidatingReader(r);
> v.Schemas.Add(xs);
> v.ValidationType = ValidationType.Schema;
> v.ValidationEventHandler += new ValidationEventHandler(MyValidation);
> while (v.Read()){
> }
> v.Close();
> }
>
> public static void MyValidation(object sender, ValidationEventArgs
> args){
> string strErr="";
> if (args.Exception != null){
> strErr = args.Message;
> }
> }
>
> HERE IS XML FILE
> --------------
> <?xml version="1.0" encoding="utf-8" ?>
> <x:catalog xmlns:x="urn:books">
>    <book id="bk101">
>       <author>Gambardella, Matthew</author>
>       <title>XML Developer's Guide</title>
>       <genre>Computer</genre>
>       <price>44.95</price>
>       <publish_date>2000-10-01</publish_date>
>       <description>An in-depth look at creating applications with
>       XML.</description>
>    </book>
> </x:catalog>
>
> HERE IS XSD FILE
> ---------------
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <xsd:element name="catalog">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="book" minOccurs="0" maxOccurs="unbounded">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="author" type="xsd:string" />
> <xsd:element name="title" type="xsd:string" />
> <xsd:element name="genre" type="xsd:string" />
> <xsd:element name="price" type="xsd:float" />
> <xsd:element name="publish_date" type="xsd:date" />
> <xsd:element name="description" type="xsd:string" />
> </xsd:sequence>
> <xsd:attribute name="id" type="xsd:string" />
> </xsd:complexType>
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
>
>
> Please if anyone knows help!!
>
> Thanks


0
clovett1 (13)
7/15/2004 3:38:52 PM
Reply:

Similar Artilces:

Excel 2007 Error saving file & error loading dll
To begin, please note that I am a novice Excel user. I cobbled together a template with macros with much help and advice from others. We were using Excel 2000 and the template was working fine. Have now upgraded to 2007 and some users of the template are getting errors when trying to update a previously saved file. I believe I am in over my head in trying to solve this, any help given in SIMPLE terms would be greatly appreciated. Here is the scenario. 1. My computer, on which the template was created, has no problems whatsoever. 2. The template is stored on a network drive where others ...

Password error
Hi, trying to open an Excel 2002 file. forgot the password. I used the Microsoft Advance Cryptographic provider. Can anyone give me a clue,,,,what to do??? ...

#value error #4
I am getting #value error in a formula.comparing a text string(using wildcard) in a column range with a text string(wild card) I want extract row numbers that matches that string in a range as array formula.While checking in formula evaluation,to find where I did wrong,I found results are coming correctly at all steps except final step.At last stage of formula evaluation I find =if(false,false,true,false,# value,false,true,#value) like this.The true values are the results what I desire.Then I used the function if(iserror,.That also didn't work. Any body please help me to how can I ...

how to catch error: cant open ADODB connection
"CreateObject" works, "Open" doesnt how to catch error and see what's wrong (the same code works on my home computer) thanks! Primoz code: set myConn = CreateObject("ADODB.Connection") myConn.open "PROVIDER=SQLOLEDB;DATA SOURCE=" & serverx & ";UID=" & uidx & ";PWD=" & pwdx & ";DATABASE=" & dbx ...

Gurus for XML TextStream vs Response Stream vs XMLValidatingReader
Hi, I try retrieve an XML stream from a webapp using a post "http://webedu.its.uct.ac.za/webct/public/serve_webctdb?OPERATION=homearea_xml&DB=global&WebCT%20ID=rodgersn_its_main&AUTH=ee09aabc77ef593917a60720f167c733" and result = req.GetResponse() ReceiveStream = result.GetResponseStream() from here ..I try read the XML retrieved, but... I've tried XMLStream and XMLValidatingStream..both return "There is invalid data at the root level" Trying a std StreamReader with say .readtoend or sr.Read(read, 0, 256) in a count lo...

VLOOKUP error #NAME
I am trying to VLOOKUP text from a column in a different tab in a workbook but the command continues to return #NAME?. The cells are formated to "GENERAL", not text. The command is below. Does anyone have advice? =VLOOKUP('VAMC Restrooms'!Leebcor Services,'VAMC Restrooms'!A:D,2,FALSE) >Leebcor Services Defined names can't contain space characters. -- Biff Microsoft Excel MVP "bderek95" <bderek95@discussions.microsoft.com> wrote in message news:CAD181E4-C02F-40D0-8370-57B135C6BD81@microsoft.com... >I am trying to VLO...

fatal error LNK1201: error writing to program database
I am using VisualStudio 2003, and writing MFC app. The error occured quite frequently, and I had to restart VisualStudio in order to continue. Any idea why this is happening and how to fix it? Thanks. Michael Could this be your problem? http://support.microsoft.com/default.aspx?scid=kb;en-us;238875 Do a search on "LNK1201: error writing to program database" in msdn.microsoft.com AliR. "Michael" <Michael@discussions.microsoft.com> wrote in message news:B7823EB9-78EE-4FF9-9C29-30723F6C4126@microsoft.com... > I am using VisualStudio 2003, and writing MFC app. ...

Sales for Outlook errors
Hi everyone, I frequently get the error "An error has occurred. For more information, contact your system administrator" Two buttons are displayed - Try Again and Go Back. This error will occur when attempting to save new contacts or activities. The information is saved even after selecting Go Back. Can anyone tell me what would fix this problem or where to look for the fix? Thanks in advance for your assistance. Andy Try checking your error log for more specifics... >-----Original Message----- >Hi everyone, > >I frequently get the error "An error has occ...

EDB Error
List, I get the following error when i try to repair the EDB file, Anyone knows how to fix. Thanks in advance gurunath ***** Repair of database 'priv1.edb' started [ESE98 version 06.00.4417.0005, (RETAIL RTM MBCS)] search for 'ERROR:' to find errors search for 'WARNING:' to find warnings trying for 97684 buffers checking database header streaming file has 166912 pages Creating 8 threads checking SystemRoot SystemRoot (OE) SystemRoot (AE) checking system tables MSysObjects MSysObjectsShadow MSysObjects Name MSysObjects RootObjects rebuilding and comparing indexes ERRO...

CLView Error
I am getting the "CLView can't display Help" error when I try to access "Help" in Word. "Help" works fine in all my other Office programs. The steps below don't seem to help me, as the file path C:\Program Data\Microsoft\Help does not exist. I have a "Microsoft Office" folder inside "Program Data," but it does not have a file called "Help." I don't suppose just reinstalling and choosing to "repair" would solve this? "Sam D" wrote: > 1)Delete Microsoft Help : C\PROGRAM DATA\MICROSOFT...

Validation error
I'm trying to modify validation for adjacent celss on the fly depending on the value of the previous cell. I've got this code but it is throwing an error. ????? If ActiveCell.Offset(0, -1).Value = "D" Then 'Range(Myaddress).Validation.Modify (xlValidateDate, xlValidAlertInformation, _ xlBetween, ="1/1/2010", ="12/31/2020") Endif What I wound up with was: If ActiveCell.Offset(0, -1).Value = "D" Then With Range(Myaddress).Validation .Delete .Add Type:=xlValidateDate, _ AlertStyle:=xlV...

Macro Error Invalid Argument every other run
I have a lovely piece of programming done by one of our MVPs here a couple years back that was working great. After many modifications to keep it current, it is now throwing an error every other run. These are all private sub modules in a UserForm that execute when you push a button. HERE IS THE PIECE THAT ERRORS For i = 1 To lstSiteFields.ListCount ffname = lstSiteFields.List(i - 1, 0) If .Bookmarks.Exists(ffname) Then If Not IsNull(lstSites.List(j, i - 1)) Then ...

Inherited Schema/ XmlValidatingReader problem.
Hi I am encoutering a problem during the validation of an XML document when using 'XmlValidingReader'. My setup is as follows. I have a schema 'Document.xsd' which is imported into a further schema 'DerivedDocument.xsd'. Our xml sample 'Instancedoc.xml' uses 'DerivedDocument.xsd' as its schema. A piece of c# code, which utilises an XmlValidingReader succeeds to validate the xml when NO attributes are used from 'Document.xsd', but fails when these attributes are included. However, we can succesfully import complexTypes from 'Document.xsd&...

error in compiling 2002 code in 2005 #2
Hi i have code build in visual studio 2002 . when i open that code in 2005 it pops up conversion wizard.. it convert successfully . but when i build it gives error is something is missing ? it gives error in "Iterator" keyword? p2 On 24 Apr 2007 01:36:16 -0700, p2 <pradip.patel@einfochips.com> wrote: >Hi > >i have code build in visual studio 2002 . > >when i open that code in 2005 it pops up conversion wizard.. > >it convert successfully . >but when i build it gives error > >is something is missing ? > >it gives error in "It...

Record is too large. (Error 3047)
I have a relatively large amount of data that I've imported into an Access table and since some of it is survey data (with some relatively verbose open-ended responses) I was not shocked to get this error when I tried to make changes to the table. However, I've deleted these open-ended response fields and am still getting the error. Is there an easy way to track down which field is giving me the issue? -- Kevin Smith Research Associate Hezel Associates, LLC Where? Where are you getting this error? What are you attempting to do when this error shows up? Are you ...

Outlook 2007 PST errors
A splash screen comes up saying there are errors on the pst file, run scanpst, from searching for it as I can't get past the splash screen but it finds no errors? When I go back into outlook the same splash screen comes up? "Cannot open default email folder.... Errors have been detected in file. Quite Outlook and all mail enabled applications then use Scanpst" which is what I have done. It does state quit all mail enabled applications what exactly does this mean as I obviously have to do so as I cannot actually get into the Outlook screen! In the Data file within t...

Error: 0x800CCC0E
We are using e-trust firewall and SCM (Secure Content Manager). From yester day we are facing a problem when cheking email via outlook express. In server "smtp for scm" service is inactive. I tried to start the service but failed to start the service. The error message is posted below: The connection to the server has failed. Account: '192.168.0.1', Server: '192.168.0.1', Protocol: POP3, Port: 110, Secure(SSL): No, Socket Error: 10061, Error Number: 0x800CCC0E Suggestion / solution is welcome. This is the Microsoft Outlook newsgroup. The Outlook Express newsgroup...

MS Pub. EXE
Recently upgraded to XP. Now whenever I attempt to do most tasks with Publisher 2002 I get the message "MS Publisher.EXE- Application Error" "The instruction at Ox77f517e2 (this varies) referenced memory at 0x0ooofffe(this varies too). The memory could not be written. Click OK to terminate the program." I have uninstalled and reinstalled several times to no avail. Help please. Dominic This type error is indicative of a driver needing updating, could be the printer or the video driver. Try doing the task in safe mode, if it works then go to the manufacturer's web...

Outlook send and receive error 0x80040154
I just started having a problem connecting to outlook 2002, windows 98se. I get the send and receive error 0x80040154. I spoke to my ISP and all the settings are correct. I checked the microsoft knowledge base and they only have this error associated with other applications, not outlook. Explorer and my dialup connection are still working fine. Can anybody help me? thanks, ron Try doing a "Detect and Repair" on Outlook. If that doesn't work, try reinstalling Outlook - your problem is an installation problem. -- Jeff Stephenson Outlook Development This posting is...

Error message "Ox8007007B
Using windows XP, Publisher, when I open a new document and try to open Clip Organizer I get the following message: "Clip Organizer cannot complete the operation Error Ox8007007B" Can you suggest what I can do to fix the error? What version Publisher? Have you emptied your temporary cache lately? In Internet Explorer, tools, Internet Options, delete, delete files. Compact your Organizer, open your Organizer from start, Microsoft Tools, Microsoft Clip Organizer. When the Organizer opens, tools, compact. There is a detect and repair under the Help menu. You receive a "Cli...

errors while autoarchiving
Hello All! I am trying to archive all messages older than 6 months but it runs for couple of moments and reports a error "Errors occurred while archiving messages. Some of the messages were moved, deleted or there is a permissions problem". outlook actually archived some but not all of them. if I keep doing it, it is archiving but instead of just going, it will be interrupted with these messages. Anyone has any ideas? this is Windows 2000 machine, Office XP SP2 and Exchange 5.5 SP4. George "George" <haubica@hotmail.com> wrote in message news:uxDXShmSEHA.1508@TK...

illegal error
Hi I am using Excel 2000 (Version 9.06 SP3). The excel file is a utility which helps collating data. it keeps crashing and gives a kernel32.dll error Content given below: EXCEL caused an invalid page fault in module KERNEL32.DLL at 017f:bff7b9a6. Registers: EAX=00000000 CS=017f EIP=bff7b9a6 EFLGS=00200246 EBX=00704240 SS=0187 ESP=0062d1a0 EBP=0062d1b4 ECX=00704240 DS=0187 ESI=007042a8 FS=33af EDX=00810ecc ES=0187 EDI=007042a8 GS=0000 Bytes at CS:EIP: ff 76 04 e8 13 89 ff ff 5e c2 04 00 56 8b 74 24 Stack dump: 00704240 708feb88 007042a8 00000000 00810ed0 0062d1f4 708fe28e 00810ed0 0000000d ...

IM-error
IM version 10.00.1384 GP10 version 10.00.1400 I have imported GL-account and new vendors succesfully. When I import Customers, the integration starts and then it comes with this error: Microsoft.Dynamics.GP.IntegrationManager.exe has encountered a problem and needs to close. I was able to preview the import files. Please help! Thanks, -- Toni On Aug 9, 2:51=A0pm, Toni <T...@discussions.microsoft.com> wrote: > IM version 10.00.1384 > GP10 version 10.00.1400 > > I have imported GL-account and new vendors succesfully. When I import > Customers, the ...

Error when accessing HQ manager
my customer gets this error trying to access hq manager: Invalid object name '#Temp'. SELECT * FROM #Temp WHERE [Status] IN (0,1,2,3,4) I tried a solution provide in a KB article that addressed the problem for 1.2 and 1.3, but it did not seem to work for him. Please advise. I have that error too....but..I don't know if there are fix for that... the only thing working was .... type your user id and password....pause for 30 secs then press Enter. Good Luck "Retail Labs Tech" wrote: > my customer gets this error trying to access hq manager: > Invalid obje...

Error 336
Hi, When trying to do anything in Excel 2000 (ie. Copy a cell) the following Error occurs "Microsoft Visual Basic Component not correctly registered" The "Help"option tells me ActiveX component not correctly registered (Error 336) Specifics: The ActiveX component has not been properly registered in the system registry. Have run a repair on Excel, but that did not fix the issue. Anyb Ideas? ...