I have an XML schema and I am trying to validate any XML document sent
against it.
Here's some of the code:
XmlReaderSettin gs xmlReaderSettin gs = new
XmlReaderSettin gs();
xmlReaderSettin gs.Schemas.Add( @"http://myschema/myschema.xsd",
"myschema.xsd") ;
xmlReaderSettin gs.ValidationEv entHandler += new
ValidationEvent Handler(Validat ionEvent);
xmlReaderSettin gs.ValidationTy pe = ValidationType. Schema;
xmlReaderSettin gs.ValidationFl ags =
xmlReaderSettin gs.ValidationFl ags |
XmlSchemaValida tionFlags.Repor tValidationWarn ings;
XmlReader xmlReader = XmlReader.Creat e(myXmlDocument ,
xmlReaderSettin gs);
while(xmlReader .Read());
Now, my problem is, if I specify an XML document which breaks the
schema with a <Root xmlns='http://myschema/myschema.xsd'> it throws an
XmlSchemaValida tionException - which is good.
However, if I, or the client of my service omits the xmlns tag then
there is no error thrown. If I add an ValidationEvent Handler I find
that the difference is that when the schema is specified it is an
XmlSeverityType .Error where as if no xmlns is given it is only an
XmlSeverityType .Warning.
Why? Why? Why? Why? Why? The XML document is wrong, it doesn't
validate. I have told it to validate against the schema the idea being
that if my client(s) send it incorrectly it fails. Yet they can now
get around the validation by not declaring the schema in the XML
document. To me this is stupid, stupid, stupid. Surely one of the
main ideas of the schema is that we do not wholly trust the originator
of the XML to be correct so we wish to check?
Basically - is there anyway around this? 1 2852
If the root of the XML document can not be strictly validated, because of
either
1. lack of element declaration of that item
2. lack of type present based on the xsi:type attribute on that element.
then LAX validation is performed as if the type of that element is
xs:anyType. You will get a validation warning in such cases, not errors. You
should filter for Warnings as well as Errors while accepting these XML
documents.
You can look up the XSD spec which specifies this behavior at: http://www.w3.org/TR/2004/PER-xmlsch...cvc-assess-elt
Thanks,
Zafar
<pe********@gma il.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.com... I have an XML schema and I am trying to validate any XML document sent against it.
Here's some of the code: XmlReaderSettin gs xmlReaderSettin gs = new XmlReaderSettin gs();
xmlReaderSettin gs.Schemas.Add( @"http://myschema/myschema.xsd", "myschema.xsd") ; xmlReaderSettin gs.ValidationEv entHandler += new ValidationEvent Handler(Validat ionEvent);
xmlReaderSettin gs.ValidationTy pe = ValidationType. Schema;
xmlReaderSettin gs.ValidationFl ags = xmlReaderSettin gs.ValidationFl ags |
XmlSchemaValida tionFlags.Repor tValidationWarn ings;
XmlReader xmlReader = XmlReader.Creat e(myXmlDocument , xmlReaderSettin gs);
while(xmlReader .Read());
Now, my problem is, if I specify an XML document which breaks the schema with a <Root xmlns='http://myschema/myschema.xsd'> it throws an XmlSchemaValida tionException - which is good.
However, if I, or the client of my service omits the xmlns tag then there is no error thrown. If I add an ValidationEvent Handler I find that the difference is that when the schema is specified it is an XmlSeverityType .Error where as if no xmlns is given it is only an XmlSeverityType .Warning.
Why? Why? Why? Why? Why? The XML document is wrong, it doesn't validate. I have told it to validate against the schema the idea being that if my client(s) send it incorrectly it fails. Yet they can now get around the validation by not declaring the schema in the XML document. To me this is stupid, stupid, stupid. Surely one of the main ideas of the schema is that we do not wholly trust the originator of the XML to be correct so we wish to check?
Basically - is there anyway around this? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: kyancy |
last post by:
Hello All.
We have several XML schemas to describe common component document
parts. We then create new XML schemas as necessary that use "xsd:import
schemaLocation=whateverLocation.." to include the common type
definitions from 1 or more of the component XML schemas rather than
just explicitly adding the common definitions in every XML schema we
create.
This works great from a definition and validation point of view, but I
|
by: btober |
last post by:
Whenever I create a temporary table, with something like
CREATE TEMPORARY TABLE temptable1 AS SELECT * FROM paid.ad_hoc_query;
New schemas appear, with names like "pg_temp_1". I guess the appearance
of these schemas with "temp" in the name indicates that they are
"temporary" schemas and related to the temporary table creation, but the
schemas persist even after the end of the session in which the temporary
table was created.
|
by: Roderick A. Anderson |
last post by:
I'm looking for some input on a configuration I'm implementing. The long
term goal is to providing hosting for companies and organizations with a
basic/generic set of applications that use PostgreSQL.
Most of these applications want to be installed in their own database.
Given I'm looking at 6 or so already this would be 6+ databases per
company. Not my idea of an easy to admin situation.
My plan is to make one database (per...
|
by: anonymous |
last post by:
When I use the schema collection to apply many schemas to
one XML instance document, I get an error if I do not
qualify every element with the appropriate namespace.
Both the W3C site and this article
(http://www.xfront.com/ZeroOneOrManyNamespaces.html) imply
that I can submit an XML instance without having to
qualify each element.
How do I accomplish this while still using .Net & the
|
by: John Jenkins |
last post by:
Hi,
I have a lot of schemas to load into a schema collection. I load them in
by reading each one into a XMLTextReader from disk and add them into a
schema collection. I have a couple of issues to contend with.
1. The targetnamespace on all the schemas (except ones which define generic
types) are the same.
2. The DefaultNamespace is the same as the Targetnamespace (I think this
should be ok)
3. Some of the schemas import other sschemas...
| |
by: CSN |
last post by:
I have two machines between which I exchange dumps a
lot. On the first (Windows/cygwin), pgsql was set up
with "Administrator" as the main superuser - who owns
all schemas in template0 and template1. On the second
machine (Linux), "postgres" is pgsql's main superuser.
On whatever machines I do "createdb", the owner of the
schemas in template0/1 is copied over to the schemas
in the new database, even when specifying the owner
parameter...
|
by: Dennis Gearon |
last post by:
This post is as much about getting some questions answered as leaving
the following definitions in the archives for the next person.
After a quick perview of the web, I came up with the following:
tablespaces are a hardware issue, and totally transparent to SQL
execution. It is for optimization for IO, recovery, and separating user
and application usage amongst disks even in the same databases.
schemas are a logical issue, and NOT...
|
by: Net Virtual Mailing Lists |
last post by:
I've been spending the last few days converting many databases into a
single schema and have completed the process, but now I'm at somewhat of
an impasse as to the best way to proceed forward....
It is important for me to explain that each of these databases has a
rather different structure, going forward I'm using more of an
inheritance model for each new schema, but that was simply was not
possible back in the day and I hope one day to...
|
by: Sami Marzouki |
last post by:
Hi,
What I'm trying to do is:
- To write a Web.config with custom sections. (Done)
- To write a xsd schema for this custom sections.(Done)
- Tell the Web.config to take the two schemas.
When i specify the two schemas in the schemas property of the
web.config, it seems that only one is token.
|
by: vihrao |
last post by:
I am designing wsdl that uses multiple schemas. I can do this in two
ways: 1) use multiple schema imports in one wsdl or 2) use multiple
schema imports in to one common schema and then import a single common
schema in the wsdl. The issue is complicated because I have several
wsdls with several common and unique schemas. As an example
serviceA_Ports.wsdl imports a commonServiceTypes.Xml,
commonFaultTypes.xml, and
serviceA.xml
...
|
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...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |