473,801 Members | 2,309 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XMLValidatingRe ader - How to disable range checking

MT
Hi,

I am currently validating an XML file against a Schema using
XMLValidatingRe ader. The schema actually contains ranges for particular
elements and I have been using it to detect range errors before it gets to
my program. The way the rangechecking works is that every element that needs
range checking is defined as an element with a particular type in the XSD.
For example,
<xs:element name="Row" maxOccurs="48">

<xs:complexType >

<xs:sequence>

<xs:element name="Price" type="PriceType " default="0"
minOccurs="0" />

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

The type has the range embedded within it:

<xs:simpleTyp e name="PriceType ">

<xs:restricti on base="xs:double ">

<xs:minInclusiv e value="0" />

<xs:maxInclusiv e value="0.002" />

</xs:restriction>

</xs:simpleType>

So, now when I validate my XML file against a schema using the
XMLValidatingRe ader, it will tell me if the value entered in the XML file is
valid or not.

However, I want to disable the rangechecking on my data for certain
operations. Is there any way I can do this?

I still want to detect if the user entered an invalid type or if the user
did not put in the correct xml tag. I just don't want the
XMLValidatingRe ader performing the rangechecking. If anybody knows how do do
this, please post a response.

Thanks,

MT


Nov 12 '05 #1
2 1851
The only way to customize the hehavior of the XmlValidatingRe ader is to
customize the schema itself.

"MT" <no****@nospam. com> wrote in message
news:u3******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

I am currently validating an XML file against a Schema using
XMLValidatingRe ader. The schema actually contains ranges for particular
elements and I have been using it to detect range errors before it gets to
my program. The way the rangechecking works is that every element that needs range checking is defined as an element with a particular type in the XSD.
For example,
<xs:element name="Row" maxOccurs="48">

<xs:complexType >

<xs:sequence>

<xs:element name="Price" type="PriceType " default="0"
minOccurs="0" />

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

The type has the range embedded within it:

<xs:simpleTyp e name="PriceType ">

<xs:restricti on base="xs:double ">

<xs:minInclusiv e value="0" />

<xs:maxInclusiv e value="0.002" />

</xs:restriction>

</xs:simpleType>

So, now when I validate my XML file against a schema using the
XMLValidatingRe ader, it will tell me if the value entered in the XML file is valid or not.

However, I want to disable the rangechecking on my data for certain
operations. Is there any way I can do this?

I still want to detect if the user entered an invalid type or if the user
did not put in the correct xml tag. I just don't want the
XMLValidatingRe ader performing the rangechecking. If anybody knows how do do this, please post a response.

Thanks,

MT

Nov 12 '05 #2
MT wrote:
I still want to detect if the user entered an invalid type or if the user
did not put in the correct xml tag. I just don't want the
XMLValidatingRe ader performing the rangechecking. If anybody knows how do do
this, please post a response.

XmlValidatingRe ader doesn't perform rangechecking, it validates instance
document against schema. So you can have second "more lax" schema, which
imports first one but redefines appropriate definitions to lift the
range constraints.
--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog

Nov 12 '05 #3

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

Similar topics

0
1628
by: Larry | last post by:
I believe the .Net XmlValidatingReader should fail when validating XML that contains a ComplexType element with white space when the ComplexType element has the mixed attribute set to false in the XSD used for validation. XSD fragment: <xs:element name="TRSellerBuyerData"> <xs:complexType mixed="false"> <xs:sequence>
18
5572
by: Vlad | last post by:
I have the following code: I have a local copy of the DTD that I need to validate incoming XML documents against. The XML document has the <!DOCTYPE myname SYSTEM "myfile.dtd"> define. When the following code is executed the XML gets resolved through the XMLResolver and gets correctly validated against the locally stored DTD file. The problem occurs when the incoming XML contains no DOCTYPE attribute. The resolver code never gets called...
0
4684
by: Harold Putman | last post by:
The XmlValidatingReader seems to have changed drastically in .Net Frameworks 1.0 SP3 and beyond with regards to validating XML files that are XML Schemas. Consider the following code: --- class ValidatingSchema { static void Main(string args)
9
1942
by: jason | last post by:
how do you use the XmlValidatingReader to validate an XML document that is passed into the XmlValidatingReader constructor? it looks like the normal process is to use an underlying reader, as follows (C#): XmlValidatingReader oMyVReader = new XmlValidatingReader(oMyReader); oMyVReader.Schemas.Add(oMySchemaCollection); oMyVReader.ValidationType = ValidationType.Schema;
5
1414
by: Geoff | last post by:
I am using an XMLValidatingReader to validate an XML file received via a web service. I want to verify that the incoming file matches the XML schema. When testing the validation routine, the XMLValidatingReader correctly flags mis-matched tags such as <abc>some content</xyz> but does not catch other errors. For example, it doesn't catch tags that are not part of the schema, doesn't catch missing tags where the schema has minoccurs="1", and...
1
2115
by: Bernhard Felkel | last post by:
I have troubles validating XML files with key/keyref constraints. Here´s my schema: <?xml version="1.0" encoding="utf-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:transNS="http://Festo.Common.Translation" xmlns="http://Festo.Common.Translation" targetNamespace="http://Festo.Common.Translation" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0.1">
1
1848
by: Plop69 | last post by:
need some help on following: xml file 1 <TEST xmlns="http://test" > <OK>mlkddflmkj</OK> </TEST> xml file 2
12
8569
by: Plop69 | last post by:
need some help on following: xml file 1 <TEST xmlns="http://test" > <OK>mlkddflmkj</OK> </TEST>
1
3224
by: JoeZ | last post by:
Hi all, I have a question about using XMLValidatingReader. I have a schema files (xsd), and a xml data file. In the xml data file, if I don't specify the schema file path, XMLValidatingReader always complains. If schema file path is included, then it doesn't complain. Is there any way to tell XMLValidatingReader where the schema file is, or am
0
9698
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
10516
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...
1
10262
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10052
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7589
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6829
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
5479
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...
2
3773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2959
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.