Validation ignores fixed attribute

hi @all,

I'm trying to validate a XML against a schema using the example from the 
MSDN:

http://msdn.microsoft.com/en-us/library/system.xml.xmlreadersettings.validationtype.aspx

In my case this seems to validates my file, because the 
ValidationCallBack handler is not called.
But the file is invalid due to a wrong fixed attribute.

I don't know why, so any clue is appreciated.

My GPX (GPS Exchange Format) file:

<?xml version="1.0"?>
<gpx
version="1.0"
creator="Holux Utility"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 
http://www.topografix.com/GPX/1/0/gpx.xsd">

<wpt lat="48.342567" lon="10.865602">
	<ele>137.59</ele>
	<time>2008-09-03T15:17:23Z</time>
	<name><![CDATA[Point 0]]></name>
</wpt>

<wpt lat="48.342548" lon="10.865611">
	<ele>137.72</ele>
	<time>2008-09-03T15:17:24Z</time>
	<name><![CDATA[Point 1]]></name>
</wpt>

</gpx>



My code looks like this (.Net 3.5, dlgFileOpen.FileName points to the 
file above):

XmlSchemaSet sc = new XmlSchemaSet();
sc.Add("http://www.topografix.com/GPX/1/1", "Resources\\gpx-1.1.xsd");

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

XmlReader reader = XmlReader.Create(dlgFileOpen.FileName, settings);
while (reader.Read()) ;

mfG
--> stefan <--
0
9/4/2008 2:13:50 PM
dotnet.xml 7266 articles. 0 followers. Follow

4 Replies
576 Views

Similar Articles

[PageSpeed] 31

Stefan Hoffmann wrote:

> <gpx
> version="1.0"
> creator="Holux Utility"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns="http://www.topografix.com/GPX/1/0"

So here the namespace URI is http://www.topografix.com/GPX/1/0
while later on you add a schema for

> XmlSchemaSet sc = new XmlSchemaSet();
> sc.Add("http://www.topografix.com/GPX/1/1", "Resources\\gpx-1.1.xsd");

http://www.topografix.com/GPX/1/1 which is different. Make sure you add 
a schema for the namespace your XML instance document uses, otherwise 
validation will only emit some warnings that no matching schema is found 
and your code

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

will not even so those warnings as you do not have the ValidationFlags 
set on your settings object to ReportValidationWarnings.

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
9/4/2008 2:28:07 PM
hi Martin,

Martin Honnen wrote:
> will not even so those warnings as you do not have the ValidationFlags 
> set on your settings object to ReportValidationWarnings.
Thanks.

btw, is there any idiom to detect the necessary schema for a XML file? 
In my GPX case there are two schemas.

I'm considering using this for the XmlReaderSettings.Schemas:

XmlSchemaSet sc = new XmlSchemaSet();
sc.Add("http://www.topografix.com/GPX/1/0", "Resources\\gpx-1.0.xsd");
sc.Add("http://www.topografix.com/GPX/1/1", "Resources\\gpx-1.1.xsd");

So when the validation handler is not called, then one schema applies to 
the file.

Is this correct?

mfG
--> stefan <--
0
9/4/2008 4:46:47 PM
Stefan Hoffmann wrote:

> btw, is there any idiom to detect the necessary schema for a XML file? 
> In my GPX case there are two schemas.
> 
> I'm considering using this for the XmlReaderSettings.Schemas:
> 
> XmlSchemaSet sc = new XmlSchemaSet();
> sc.Add("http://www.topografix.com/GPX/1/0", "Resources\\gpx-1.0.xsd");
> sc.Add("http://www.topografix.com/GPX/1/1", "Resources\\gpx-1.1.xsd");
> 
> So when the validation handler is not called, then one schema applies to 
> the file.

The validating parser will look at the namespace of the root element of 
the XML document to be validated and then check for a schema with a 
matching targetNamespace in its XmlSchemaSet. If it does not find a 
matching schema then a warning is issued. If a matching schema is found 
the parser checks whether there is a top level defintion for the root 
element and validates against that definition, reporting errors as 
needed to the handler. If there is no top level definition for the root 
element then this is also an error. So the above should work.

Note that you can shorten the code, there is no need to explicitly 
create and assing an XmlSchemaSet, you can simply call 
settings.Schemas.Add. And passing in the schema URI to the Add method is 
not necessary, if you pass in null for that parameter then it simply 
uses the targetNamespace of the schema passed in as the second argument.
-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
9/4/2008 5:18:58 PM
hi Martin,

Martin Honnen wrote:
>> XmlSchemaSet sc = new XmlSchemaSet();
>> sc.Add("http://www.topografix.com/GPX/1/0", "Resources\\gpx-1.0.xsd");
>> sc.Add("http://www.topografix.com/GPX/1/1", "Resources\\gpx-1.1.xsd");
> Note that you can shorten the code, there is no need to explicitly 
> create and assing an XmlSchemaSet, you can simply call 
> settings.Schemas.Add. And passing in the schema URI to the Add method is 
> not necessary, if you pass in null for that parameter then it simply 
> uses the targetNamespace of the schema passed in as the second argument.
Ah, cool. Thanks a lot.


mfG
--> stefan <--
0
9/4/2008 5:48:11 PM
Reply:

Similar Artilces:

Msgbox entry validation
The following Macro will not loop more than twice the error entries. Will someone help me correct it to loop indefinely? Thanks Sub Entry_validation() Dim Teststring As String Dim Inputstring As String Cells(1, 1) = "ABC" 'as given filename Cells(2, 1) = "DEF" 'as given filename Cells(3, 1) = "GHI" 'as given filename Cells(4, 1) = "JKL" 'as given filename errorloop: Inputstring = InputBox(prompt:="Enter Filename" & vbLf & "Enter abort to abort en...

Data Validation -> Validation list is larger than the cell width
I have a workbook that I've just added data validation to one cell. FWIW, the data validation is based on a named range. Here's the (perceived) problem. When I've set up data validation in the past, the selection is the same width as the cell. In this case, the list starts almost a full cell width to the left. What am I missing? Thanks, Barb Reinhardt Barb, In Excel2003 I can replicate what you describe under the following conditions: 1. the named range contains entries that are wider than the data validation cell 2. The data validation cell is r...

Validating against a DTD
Hello All, I am trying to validate an xml file against a DTD. I went through a lot of examples especially: http://www.xmlforasp.net/codebank/util/srcview.aspx?path=../../codebank/System_Xml/XmlValidatingReader/Validator/validator.src&file=validator.cs&font=3 but its not working in my case. First of all, when i try to add my DTD file in XmlSchemaCollection object, it throws an error saying DocType element is expected. I am using NITF DTD for this and there is no DocType element in it. Any help will be appreciated. Thanks. VD You should not add DTDs to XmlSchemaCollection. XmlSchema...

I need a solution to this problem. How do i fix this ?
MSPUB caused an invalid page fault in module MSPUB.EXE at 017f:0052eda5. Registers: EAX=00022755 CS=017f EIP=0052eda5 EFLGS=00010202 EBX=008df1dc SS=0187 ESP=008df0ac EBP=0000011e ECX=00000015 DS=0187 ESI=006d5f66 FS=5227 EDX=012c02cd ES=0187 EDI=008df0c0 GS=5216 Bytes at CS:EIP: f3 a5 66 a5 5f 5e c2 08 00 90 90 8b 4c 24 04 83 Stack dump: 00000020 0000002f 0052edc2 00001a41 008df0c0 00a2d180 00005168 004f1eb9 008df1dc 006c9624 00000008 008df130 00000002 0000011e 00000008 006ccbac What version Publisher? What are you doing when this error appears? Upgrade your drivers, more than likely it...

Validation dropdown list is not coming visible
Hi, I'm using XP and 2003. I have a problem that I have once found resolution, but now it came again and cannot remember what needs to be done. Here is the problem: There is a column where Validation is specified in right manner with error message in case of error. When selecting the cell - dropdown list is not coming visible. In case I write something wrong it gives error message. If I recall correctly - it was something to do with some kind of list. How can I change this to work properly? I tried to paste new column from another file where the column is working as I want...

Data Validation
Hi all I want to set data validation on a cell so that it will accept the following (and only the following) text strings: (1) "BR" (literally) or (2) "NT" (literally) or (3) "nA" where n is any positive integral numerical value including zero and A may take any of the values "L", "P", "T", "V" or "Y" or (4) "An" where n is any positive integral numerical value including zero and A may take either of the values "K" or "D". Is this possible, please, and if so how? thanks -- Return e...

What value (from a function) would a chart line ignore (like it ignores an empty cell)?
When creating a line chart, I would like to show separate bits of a line (i.e. a discontinous line). The underlying data comes in the form of excel formulas. Neither "" or FALSE does the job (both render a zero-value when charting). I would like to avoid running a macro that deletes the appropriate cells. Is there any solution for this in today's excel version? Many thanks for your help! You can use NA() in the formula, e.g.: =IF(A5=0,NA(),A5) Hansi wrote: > When creating a line chart, I would like to show separate bits of a > line (i.e. a discontinous line). The unde...

reinstall-validation problem
Hardware hit from lightning so new hd and video card and start over. All goes well with install using a slipstreamed XP-Pro SP3 disk but I notice it never asks for the Product Key during install yet it Activates itself during one of the boots and I think little of it until ... During the updates which followed (100+!!!) I notice Windows Defender doesn't seem to run or leave itself installed. As it is running on my laptop figured I just download it. When I run it, it wants to first do the Genuine Advantage bs which I let it, at which time it says "bogus". Ugh, g...

Validation
Julie the same can be achieve without going thru the double drop down boxes. You could do it just using the combobox alone. Thank again Please stay in the ORIGINAL thread. The archives will thank you. -- Don Guillett SalesAid Software donaldb@281.com "JLong" <anonymous@discussions.microsoft.com> wrote in message news:034101c49c3b$889b5020$a501280a@phx.gbl... > Julie the same can be achieve without going thru the > double drop down boxes. You could do it just using the > combobox alone. Thank again ...

Data Validation
I have set up a data form and have data validation rules on the various input cells. I see that there is an option called "Ignore blanks" in the data validation settings, which is supposed to restrict someone from entering past an input cell without entering valid data, if the "Ignore blanks" box is unchecked. I have tried to do this, but it does not seem to work. Please could someone tell me what I am doing wrong? Provide information, or better yet, a screen capture of the Data Validation dialog box with the Setting tab selected (User ALT+PrintScreen to copy the imag...

validating macro
Hi I am sending a spread sheet out to branchs I need them to complete a sheet (common info) before they do anything else on the workbook. I am looking for a macro or code for VBA which who check (common info) see if the cells are complete if not bring up a error screen informing the user to complete the form and then take them straight to the (common info) sheet. and if possible let them go to the tab which they want to go to. Use an extended version of something along these lines: (if there are lots of cells use a 'for row numbers x to y' or 'do until' statment, o...

Adding new attribute
Can we add a attribute(I will be choosing picklist). with more than 1000 entries. I am using CRM 3.0 Hi. Making a picklist with that many options sounds like a bad plan. First you have to add every option and then the user ends up with a VERY long list with no search option. I recommend that you make a new entity and then make a lookup connection between the two entities. This will be more easy to maintain and it gives the user a search option. Need more help let me know. "SyedAbdulbasith" wrote: > Can we add a attribute(I will be choosing picklist). with more than 1000 ...

Reboot Validator
I'm running XP Pro, SP3. Attempting to install a program from Nero. Software keeps failing at startup, despite numerous re-installs. During installs, it keeps attempting to update the 'reboot validator' which it does not seem to be able to do. What is the reboot validator, and how do I update it. Couldn't find anything useful on MS site and Nero Tech support just says its an MS problem. -- Thank you, B. Parker Never heard of it but Nero Support should know about it: Reboot Validator appears to be a Nero component; cf. http://www.brighthub.com/comput...

Conditional validation?
Hello All I have a sheet that is essentially just columns of data (except for the column headings in the first row), and two of the columns are what I would call 'mutually exclusive': i.e. if a value is entered in a row in either column, the user must be prevented from entering any value in the same row of the other column. The two columns already have some basic validation applied (ranges of permissable numerical values), and this validation would need to be applied for any values that are entered. I am sure this can be done, but cannot see how! Hope someone can help. Many thanks L...

REPOST: dynamic validation
I think I wasn't clear that I need the Validation option under the Data menu, List, source values. That is what I am trying to fill with this equation. In other words, range1 and range2 are sets cells which contain values. I want those values to be the dropdown options in the cell based on what the previous cell to the left is selected as. So if Range1 is three cells with Tall, Dark, Handsome and Range2 is Sweet, Pretty, Nice, then based on the selection of F or M in A1, I want the choices for B1 to be one of those lists. I know that quotes are required for the IF. My probl...

Excel 2000 vs 2002 Sheet protection & Validation cells
Hello, I have an Excel spreadsheet built on Excel 2000. I have set sheet protection with password, and I have some unprotected cells with drop down menu (validation with 50 choices) Everything works very well. I sent this file to a friend who has Excel 2002. The same "unprotected" validation cells cannot be modified in his version as the message says that these cells are protected What can be done in order to make it work on his version?? I do have some "very hidden" sheet with password protected VBA properties, if that is an issue. Similarly there are some macros o...

How to use data validation
[NB: I re-structure my question since people got misled from my previous one] What I really wish to ask is: I wish to use data validation for a particular cell. But it doesn't work if I choose "custom" in the "allow" box. 1) In Data | Validation | Settings Tab | Validation Criteria, there is an "Allow" Box. 2) I chose "custom", there is a formula. 3) I type in some formula, eg: =J3 (Just Reference) =J3-J1 (Reference-type formula) =round(J1) (Function-type formula) None of them can activate the validation fu...

Fixed Assets across business lines
Hello everybody - Is it possible to spread fixed asset depreciation across multiple business lines? We have certain assets that need to be depreciated across multiple GL accounts..is this possible? The simplest solution would be to use an allocation account (probably a fixed allocation account) as the depreciation expense account. This would spread the depreciation based on the percentages in the allocation account to multiple accounts. Mark On Sep 27, 4:25=A0pm, modon...@knight.com <mich...@microsoftinstructor.com> wrote: > Hello everybody - > Is it possible ...

Refer to seperate workbook for validation list for drop downs?
Id like to keep my validation data for drop downs in a seperate workbook so that many users/worksheets can reference it. However- data validation doesnt seem to let me reference named ranges in a seperate workbook- any advise out there? -- Dee Visit Debra Dalgleish's site: http://www.contextures.com/xlDataVal05.html But take note that the other workbook has to be open. Dee wrote: > > Id like to keep my validation data for drop downs in a seperate workbook so > that many users/worksheets can reference it. However- data validation doesnt > seem to let me reference named r...

Email Validation
I was testing this email validation rule. Is Null Or ((Like "*?@?*.com") Or (Like "*?@?*.org") Or (Like "*?@?*.net") Or (Like "*?@?*.mil") Or (Like "*?@?*.US") And (Not Like "*[ ,;]*" And Not Like "*.@*")) ...but noticed I was able to input .@any.com ... e.g., I was trying to prevent user typing a .@ [that is a dot@] using the ... And Not Like "*.@*")) .. but it must be getting cancelled out by something previous in the validation string. Any suggestions? You could use a routine such as: P...

Hot FIX KB 822868
How do I get this hot fix? http://support.microsoft.com/?kbid=822868 As the article says, you need to contact Microsoft support. When you call for a patch referenced in a KB article like this, you don't get charged for the support call. -- PATRICK REED [Outlook - MVP]~~~~~~ -Microsoft Certified Professional (MCP) -Have you checked http://www.slipstick.com? -Please post your Outlook version! "Al Reeder" <reederal@yahoo.com> wrote in message news:097a01c365bb$effb2810$a001280a@phx.gbl... > How do I get this hot fix? > http://support.microsoft.com/?kbid=82286...

Data Validation: Validate Specific Day of the Week?
Users will enter a date in cell D6. The date they enter must be a Monday. How can I validate for that? Thanks, -Ted I entered dates in E1:E10. I selected E1 In the Data | Validation dialog, I used Custom and entered =WEEKDAY(E1)=2 I selected all the dates and opened Data | Validation; it offered to apply the validation to all the cells Done best wishes -- Bernard Liengme Microsoft Excel MVP http://people.stfx.ca/bliengme "Ted" <ted.gallagher@gmail.com> wrote in message news:#o$yRC6vKHA.404@TK2MSFTNGP02.phx.gbl... > Users will enter a date in ce...

Data validation for 2 valid values
I want a cell to allow only 2 valid values but not have a drop-down list appear. How do I do that with Data->Validation? Data>validation>allow>list, put the 2 values separated by a comma in the source box, uncheck in cell dropdown -- Regards, Peo Sjoblom "Hall" <hall@garp.org> wrote in message news:ujuB%23w52DHA.2000@TK2MSFTNGP11.phx.gbl... > I want a cell to allow only 2 valid values but not have a drop-down list > appear. > > How do I do that with Data->Validation? > > Using a list, as Peo suggested, will force users to match the ...

Pictures in messages shown with a red cross placemarker. Fix?
In Outlook 2002, some messages I receive (e.g. supermarket catalogue) do not show pictures, but instead have a red cross in a box as a placemarker. This has only happened recently. How do I fix this problem? Clear your OutlookTemp folder and your Temporary Internet Files folder and try again. For instructions on how to clear your OutlookTemp folder see; http://www.howto-outlook.com/faq/securetemp.htm -- Robert Sparnaaij [MVP-Outlook] Coauthor, Configuring Microsoft Outlook 2003 http://www.howto-outlook.com/ Outlook FAQ, HowTo, Downloads, Add-Ins and more http://www.msoutlo...

Validating values of POEMDEV
Hi all, I've written a OEMUI.DLL. The basic code comes from the WINDDK sample. The values from the gui are stored in the POEMDEV. VERBOSE(DLLTEXT("UserName :<%s>.\r\n"), ((POEMDEV)pOEMDM)->szUserName); VERBOSE(DLLTEXT("CostCenter:<%s>.\r\n"), ((POEMDEV)pOEMDM)->szCostCenter); VERBOSE(DLLTEXT("ColorMode :<%s>.\r\n"), ((POEMDEV)pOEMDM)->bColorMode ? L"on" : L"off"); I like to find a place in this DLL, where I can verify the values of POEMDEV. Greetings Kai -- ISO Software Systeme GmbH Nuremb...