XML Validation #4

Hi folks,
I got the following code to validate a custom XML against a given
schema:

XmlSchemaSet sc = new XmlSchemaSet();
sc.Add(schema);
sc.Compile();

XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
settings.Schemas = sc;
settings.ValidationEventHandler += new
ValidationEventHandler(settings_ValidationEventHandler);

XmlReader reader = XmlReader.Create("c:\\1.xml", settings);
while (reader.Read()) ;

However, the validation seems to be OK. Here's the schema:

<?xml version="1.0" encoding="Windows-1252"?>
<xs:schema elementFormDefault="qualified"
targetNamespace="http://www.w3.org/2001/XMLSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="WebServiceAccessPoint">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="1" maxOccurs="1" name="Uri"
type="xs:string" />
        <xs:element minOccurs="1" maxOccurs="1" name="Username"
type="xs:string" />
        <xs:element minOccurs="1" maxOccurs="1" name="Password"
type="xs:string" />
        <xs:element minOccurs="0" maxOccurs="1" name="Domain"
nillable="true" type="xs:string" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

and here's the content of the file:

<?xml version="1.0" encoding="utf-8"?>
<WebServiceAccessPoint>
  <Uri2 />
  <Username>Jack</Username>
  <Password></Password>
  <Domain></Domain>
</WebServiceAccessPoint>


How this could be possible???? The schema even does not contain the
Uri2 element!!!

Any help would be highly appreciated,

Cheers,
Mehdi

0
12/19/2006 4:54:09 PM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
156 Views

Similar Articles

[PageSpeed] 45

mehdi wrote:

> <xs:schema elementFormDefault="qualified"
> targetNamespace="http://www.w3.org/2001/XMLSchema"
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Unless you are trying to define a schema for schemas the targetNamespace 
of your schema should certainly not be http://www.w3.org/2001/XMLSchema.
With that XML

> <WebServiceAccessPoint>
>   <Uri2 />
>   <Username>Jack</Username>
>   <Password></Password>
>   <Domain></Domain>
> </WebServiceAccessPoint>

you don't want a target namespace at all as the elements are in no 
namespace. So use e.g.

<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema">

and your schema defines elements in no namespace.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
12/19/2006 5:02:40 PM
Hi martin,
I really don't get the point. Would you please describe the solution
more? What does it have to do with the validation?

TIA,
Mehdi

Martin Honnen wrote:
> mehdi wrote:
>
> > <xs:schema elementFormDefault="qualified"
> > targetNamespace="http://www.w3.org/2001/XMLSchema"
>    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Unless you are trying to define a schema for schemas the targetNamespace
> of your schema should certainly not be http://www.w3.org/2001/XMLSchema.
> With that XML
>
> > <WebServiceAccessPoint>
> >   <Uri2 />
> >   <Username>Jack</Username>
> >   <Password></Password>
> >   <Domain></Domain>
> > </WebServiceAccessPoint>
>
> you don't want a target namespace at all as the elements are in no
> namespace. So use e.g.
>
> <xs:schema
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> and your schema defines elements in no namespace.
> 
> 
> -- 
> 	Martin Honnen --- MVP XML
> 	http://JavaScript.FAQTs.com/

0
12/19/2006 6:10:05 PM
mehdi wrote:

> I really don't get the point. Would you please describe the solution
> more? What does it have to do with the validation?

Read <http://www.w3.org/TR/xmlschema-0/#NS> to find out more about XML 
schemas and namespaces, what the target namespace is for.

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
12/19/2006 6:28:46 PM
Reply:

Similar Artilces:

after 4.0 upgrade emails are no longer being associated with cases
We have a workflow rule that automatically fires whenever a new case is created to send an email with the case number, owner, etc. to the customer. When we were running MSCRM 3.0, the automated email would be automatically associated with the case. That is, the Emails regarding field would automatically be filled in with the associated case. After a recent upgrade to 4.0, the workflow rules still fire and emails still get automatically created when a case is created, but the regarding field is blank. Our support reps now have to go into the Contact record, find the automated email, a...

Excel Spreadsheet #4
How do i change a spreadsheet to an A3 size? It's in the printer settings -- Regards, Peo Sjoblom "teletubby" <teletubby@discussions.microsoft.com> wrote in message news:0366922A-B1C3-48B4-843F-EF649F76E7F0@microsoft.com... > How do i change a spreadsheet to an A3 size? ...

Excel #4
I wish to type a series of numbers in a column, such as invoice numbers example: 3-1900, 3-1901 etc. However, whenver I do this, I get the date Mar-00. Any advice? Format the cells as text before entering the invoice number. Janet wrote: > > I wish to type a series of numbers in a column, such as > invoice numbers example: 3-1900, 3-1901 etc. However, > whenver I do this, I get the date Mar-00. Any advice? You can try either formatting the cells as text before you enter your data, or preceed your data with an apostrophe (as in '3-1900). Ed "Janet" <e...

duplicate messages #4
when a user emails a distribution list that the user is a member of, he/she receives the email. is there a way to prevent sending the user the email when he/she sends it to a distribution list that he/she is a member of? Hi I would request you to use RULE option under TOOLS tab menu in Microsoft Outlook. For more information you can get in touch with me at arorarahul2000@hotmail.com "noone" wrote: > when a user emails a distribution list that the user is a member of, he/she > receives the email. > > is there a way to prevent sending the user the email when...

Trying to modify XML X-REPORT
Following code segment looks good but the <IF> equates to true always and all departments print... What am I doing wrong? <ROW> "Non-Taxable Sales:" </ROW> <SET name="NonTaxableTotal" type="vbCurrency"> 0 </SET> <SET name="TATTOO" type="vbString"> "TATTOO" </SET> <SET name="BODYPIERCING" type="vbString"> "BODY PIERCING" </SET> <FOR each="ReportDepartment"> <IF> <CONDITION> Report.Department.Name = TAT...

Duplicate detection #4
Hi, I've created a duplicate detection rule with to criteria : Exact last name And first 20 Character of Company name I thought it would be a AND, so the rule will detect only the Lead that has both criteria but it seems to be a OR. How can I change it to make what I want to do? Thanks, Hi, the only way to do this is create another duplication rule for the second condition... Everything in one rule == AND different rules == OR "Val" wrote: > Hi, > > I've created a duplicate detection rule with to criteria : > Exact last name > And first 20 Character ...

access to microsoft.public.dotnet.xml is at www.ugroups.com
This is a monthly reminder that via the web you can easily access microsoft.public.dotnet.xml without a newsreader at http://www.ugroups.com/Computers/viewforum.php?f=18 This message from www.ugroups.com is intended for those who might be interested in free web based access to the newsgroups. Please add to your kill file to avoid future inconvenience. Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** ---------------------------------------------------------- ...

Looking for XML Template Reference Docs
I need to make some changes to the Receipt Templates and Statement formats. In RMS, these templates are designed in XML. Can somebody point me to a reference doc that will assist me in customizing these templates? I am most interested in seeing a list of possible variables that can be included in reports/receipts/statements. Thanks, Paul Arenson Anderson Plywood Sales Culver City, CA ...

Insert XML string into XML File: Part 2
Thanks to some good help from a previous post, I have been able to create well formed xml as part of a report logger app. However, I still have a small problem. When I add new xml to the log file, the new nodes are appended to the original file. What I really want is for the log file to grow as "report nodes" are added. Also, I am a bit concerned about performance, particularly as the file grows in size. I must write to an xml file (vs. a database) and am trying to understand the best way to do this. I prefer to not use "temp files" and would like to just modify the ...

XML and XSL translation
Hi, I am trying to do an XML translation. I have not done much with XML apart from generating a few RSS feeds or saving from datasets. I have found numerous example on the net about it, all of them very similar. However, when I use them, they go into response.output rather than a label or literal. I am trying to drop the output into a literal. Here is the code I have... try { XPathDocument _SourceXml = new XPathDocument("http://www.nationalgrid.com/uk/Interconnectors/France/Results/Weekend+Auctions/rss.htm"); // Load the XSL stylesheet XslTransform _Transform ...

Multiple date validation in a single cell
I am trying to do a rather complicated validation (I think it i anyway!) I want to allow ONLY dates of a particular format to be entered int the one cell - i.e. YYYY OR mm/YYYY OR dd/mm/YYYY For example, the same cell can have either one of these format entered, but MUST match one of them to be accepted. 1970 is OK and is captured in the cell as 1970 (not 1/01/1970) 70 is assumed to mean 1970 on entry 05/1970 is OK, captured in the cell as 05/1970 (not 1/05/1970) 5/70 or May-70 is assumed to mean 05/0970 on entry 05/06/2004 is OK 5/6/04 or 5 June 04 is assumed to mean 05/06/2004 on entr...

HTML to XML conversion #2
Hi, I'm trying to create a Learning Object Repository to store learning objects (obviously!). My question is how do I convert HTML pages to XML and then store them in a database and then generate HTML/XHTML pages on the fly and display it to the client from the stored XML files. Help! GeRmIc wrote: > I'm trying to create a Learning Object Repository to store learning objects > (obviously!). My question is how do I convert HTML pages to XML and then > store them in a database and then generate HTML/XHTML pages on the fly and > display it to the client from the st...

SQL to well formatted XML file via .NET
I am trying to create several .xml files, mirrored from my SQL database that are shaped according to an XSD schema. However, I have hit a brick wall! Droving through several materials on how to perform this function has resulted in some slightly jarring results! Basically, I would like to create a dataset.xsd XML map of a stored procedure from the SQL database, and through use of this .xsd pass the resulting correctly formatted .xml to a file (or heck even the /bin!) Here is a code that I have been working with to take the stored procedure view and pass it to an .xml file - to the /bin...

Hyperlinks in Excel #4
Using Excel 2000 is there a way to remove hyperlinks such that the background formatting is not also removed? I have a user who needs to remove hyperlinks from e-mail addresses, in a list, and when she does, all the formatting (font, borders, shading, etc.) is also removed. - Thanks. -- LPS I'm assuming that the user is running a macro that looks essentially like this: Selection.hyperlinks.delete If you really wanted, you could find out all the formatting for each of those cells, remove the hyperlink and then reapply the formatting. Myself? I'd just reapply the formatting tha...

AfxBeginThread failure
In an MFC pgm under VS2005sp1, I am creating a worker thread using AfxBeginThread. Under certain circumstances which I can't quite pin down, AfxBeginThread returns NULL, indicating it has failed. Is there any way I can find out the cause of the failure, such as an error code? I have tried tracing through the code with the debugger, but what is apparently detecting the error condition is in MS code for which I don't have the source. My specific code is CWinThread* pThread=AfxBeginThread(MyControlFunction,&ti,0/*priority*/, 230000000/*stack size*/); and a test for pThread==NULL im...

Outlook shuts down #4
Hi I have Outlook 2003 under XP with Hauri anti virus all updated. I have several spam msgs in the inbox and if I highlight them to delet or move the pgm shuts off immediately every time. Any clues? Thanks ...Lyl ----------------------------------------------- ~~ Message posted from http://www.ExcelTip.com ~~View and post usenet messages directly from http://www.ExcelForum.com ...

CRM 4.0 MSDN
I noticed that 4.0 has been posted on MSDN but has anyone found where to access the install codes? On Jan 15, 5:39=A0pm, dmn8 <d...@discussions.microsoft.com> wrote: > I noticed that 4.0 has been posted on MSDN but has anyone found where to > access the install codes? You can download CRM 4.0 here : http://www.microsoft.com/downloads/results.aspx?DisplayLang=3Den&nr=3D20&fre= etext=3DCRM&sortCriteria=3Ddate If you mean the license keys, then they haven't been released yet :( -- Robert MacLean http://www.sadev.co.za "dmn8" wrote: > I noticed that...

edit xml
I'm developing smaller Websites with Asp.net and C#. For some Contents I want to develop a management system. At the moment a think about managing the contents via xml-files. For example the news section maybe has not more than 4 entries per page. And the complete application has about 30 to 40 Webpages. So that the xml-files has about 150 entries. I want to edit, delete, add new and change the order of the entries. What is the right way to do it? Should I use Dom for editing? Or go the easiest way to use a Dataset and save the dataset back as xml? Or is there a better wa...

Formula?
Hi, I have my data set up the following way - the columns refer to th month and the rows are the different projects I'm tracking. Projec "A" has data in months Jan-Oct (10 values), while Project "B" has dat in months Jan, March, July, August & Sept (5 values)-the missing month are blank. Is there a way get the average of the last 4 values fo each project? Maybe using a count function? thank -- Message posted from http://www.ExcelForum.com Hi if your values are in A1:J1 use the following array formula (entered with CTRL+SHIFT+ENTER) =AVERAGE(OFFSET(J1,0,0,1,-...

validating an e-mail address in excel
what's the formula or reg i should use in excel spreadsheet to validate a e-mail address of the format xxxxxx...@XXXX.XXX I donno how i shud do ti ..cud someone please help? Thanx in advance You could validate it to check to see if the string contains an "@" and contains a "." somewhere after the "@". Try: =IF(AND(ISNUMBER(FIND("@",A1)),ISNUMBER(FIND(".",A1,FIND ("@",A1)+1))),"valid e-mail","no") HTH Jason Atlanta, GA >-----Original Message----- >what's the formula or reg i should use in excel ...

Need some pointers
I just started playing with the XML extensions of the CRL and have a question and have not seen how why what I have here is happening. Now I do know my XML is not complete and the file layout we are starting with is simply a prototype Any way here is a cut out of my xml file <IADSNOTES type='public' count='4'><Note ID='1' app='Readr' csm='0'><File href='C:\IADS\DEMO\DEMO.SGM'/><Frame num='1' id='INTRODUCTION TO IADS' title=''/><User>Guest</User><Pos ScrollPos='0'/><Te...

shared calendars #4
Is there anyway to share a calendar and block out the Personal items? Thanks! Sounds like you're asking if you can share *part* of your Calendar, but not all of it. Unless there is a 3rd Party program, or a Script that would allow this, I don't think it is possible. Give http://www.experts-exchange.com/ a look over. The http://www.theofficeexperts.com/outlook.htm might be able to help too. If the personal items are a question of your integrity, then just get rid of them. GL RW <param@community.nospam> wrote in message news:OW6drXHIGHA.2472@TK2MSFTNGP10.phx.gbl... >...

Cell Validation #3
I'm working on a sheet that needs some validation. For example, in cell C4 they are supposed to enter their initials, but some enter their full name. I need to make sure that they enter (for example) ABC instead of Alex Billy Charlie. Then, they are supposed to enter the week ending date in cell K4. I'm wanting to add a calendar there, so they can select the date. However, I only want my calendar to show week ending Saturdays, or make it so when they select any day in that week, it selects that weeks Saturday. Then, when they enter the date, it will automatically fill in information...

Need Parser that can read attributes of XML document...
Hello guys, I am looking for a parser in PHP that can return all the attributes of XML entities. I know how to read the XML Entities, but I have got a problem with reading attributes. So I will appreciate if you could give a parser that can return all the Entities and Attributes of respective entities as an array. For e.g.: <?xml version="1.0" ?> <Controller> <NumberOfBoards>5</NumberOfBoards> <NumberOfKeypads>1</NumberOfKeypads> <QueueMode>N</QueueMode> <EntranceDelay on="5" off="5" /> <Limits minLength=&...

Government Applications One Focus of XML 2004
XML 2004 to Focus on Government XML Applications Expanded Government Track to Highlight XML Applications in U.S. and Abroad; XML.gov, KM.gov, CIO Council, and SICoP to Co-Host Event Alexandria, Va. – Oct. 6, 2004 – IDEAlliance, a leading industry association dedicated to fostering XML and other information technology standards, today announced that XML Conference and Exposition 2004 will feature a full track of presentations and topics focused on government-related XML applications and solutions. XML 2004 is slated for Nov. 15-19 at the Marriott Wardman Park Hotel in Washington, D.C. Ma...