Validating Xml document with !DOCTYPE in it?

Hi there

I have a schema (xsd) that I can figure out to validate Xml docs against.

The documents however, also contain a DOCTYPE declaration. I would like for
my XmlReader to _ignore_ the DOCTYPE declaration. Currently, it throws. If
I enabled the Dtd support (ProhibitDtd = false), it tries to retrieve the
URL. I have given it an XmlSecureResolver without any URL, and then it
throws... 

So, it seems I can: 

- have the validating XmLReader throw when it encounters an DOCTYPE
or
- have it try to fetch the URL of the DOCTYPE

I just want it to ignore it...

Any advice?

Regards

Mads

-- 
Med venlig hilsen/Regards

Systemudvikler/Systemsdeveloper cand.scient.dat, Ph.d., Mads Bondo
Dydensborg
Dansk BiblioteksCenter A/S, Tempovej 7-11, 2750 Ballerup, Tlf. +45 44 86 77
34 
0
mbd5160 (6)
12/13/2007 2:25:43 PM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
554 Views

Similar Articles

[PageSpeed] 52

Mads Bondo Dydensborg wrote:
> Hi there
> 
> I have a schema (xsd) that I can figure out to validate Xml docs against.
> 
> The documents however, also contain a DOCTYPE declaration. I would like for
> my XmlReader to _ignore_ the DOCTYPE declaration. Currently, it throws. If
> I enabled the Dtd support (ProhibitDtd = false), it tries to retrieve the
> URL. I have given it an XmlSecureResolver without any URL, and then it
> throws... 
> 
> So, it seems I can: 
> 
> - have the validating XmLReader throw when it encounters an DOCTYPE
> or
> - have it try to fetch the URL of the DOCTYPE
> 
> I just want it to ignore it...
> 
> Any advice?

Please try to use XmlReaderSettings with XmlResolver set to null and 
ProhibitDtd set to false, that should not load the DTD.

If you need the resolver for your schemas then you will have to subclass 
XmlUrlResolver and override the methods to make sure the DTD is not loaded.

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
12/13/2007 3:42:12 PM
Mads Bondo Dydensborg wrote:

> I have a schema (xsd) that I can figure out to validate Xml docs against.
> 
> The documents however, also contain a DOCTYPE declaration. I would like
> for my XmlReader to _ignore_ the DOCTYPE declaration. Currently, it
> throws. If I enabled the Dtd support (ProhibitDtd = false), it tries to
> retrieve the URL. I have given it an XmlSecureResolver without any URL,
> and then it throws...

Seems using a null XmlResolver actually works - I thought from reading the
docs, that one would always have to supply a resolver, when the ProhibitDtd
was false. 

Oh well - works for now.

Regards,

Mads

-- 
Med venlig hilsen/Regards

Systemudvikler/Systemsdeveloper cand.scient.dat, Ph.d., Mads Bondo
Dydensborg
Dansk BiblioteksCenter A/S, Tempovej 7-11, 2750 Ballerup, Tlf. +45 44 86 77
34 
0
mbd5160 (6)
12/13/2007 3:48:45 PM
Martin Honnen wrote:

>> I just want it to ignore it...
>> 
>> Any advice?
> 
> Please try to use XmlReaderSettings with XmlResolver set to null and
> ProhibitDtd set to false, that should not load the DTD.

Thanks. I (mis)read the docs - it was my understanding that one needed a
non-null XmlResolver when ProhibitDtd was set to false.

Thanks again

Mads

-- 
Med venlig hilsen/Regards

Systemudvikler/Systemsdeveloper cand.scient.dat, Ph.d., Mads Bondo
Dydensborg
Dansk BiblioteksCenter A/S, Tempovej 7-11, 2750 Ballerup, Tlf. +45 44 86 77
34 
0
mbd5160 (6)
12/13/2007 7:15:46 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...

Parsing XML in string variable?
I have a method that returns a string that contains XML, and I need to parse that string (ie. find specific keys). How can I do this? I found one that searches a Stream, but I don't know how to convert from string to stream. Thanks. hi vmi, you could use the System.Xml.XmlDocument class, simply make a new instance and use the LoadXml-Method (does not properly load string with encoding markers). You could also use the .NET 3.5 System.Xml.Linq.XElement. There are several utility classes to read from strings and streams and vice versa, e.g. System.IO.StringReader &am...

Microsoft Word 6.0/95 Documents Not Opening in
Version: 2004 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Two recent strange occurrences: <br><br>1)Older documents originally created with Microsoft Word 6.0/95 are not opening in Microsoft Word 2004 for Mac (ver. 11.5.6) even though within their preview (next column over from actual file/document) it says that the document was modified and last opened when the document attempted to open, but actually never appeared. <br><br>2)Some kind of font formatting within even newer, recently created Microsoft Word 2004 documents has changed. Most docum...

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 ...

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...

XML Tree Structure
Hi Folks, I would like to take a XML document and write its data into a tree structure for a custom tree control. The document has two fields with one called task (a text field) and the other called tree_level (an integer field). Consider the document to be valid and well-formed. The tree_level is an index describing where a node will reside in a tree structure. A partial view of the XML document is as follows: <task>summary task</task> <tree_level>0</tree_level> <task>task1</task> <tree_level>1</tree_level> <task>task2</task&...

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...

[ANN] Liquid XML Studio Released
Announcing the release of Liquid XML Studio 2008 a Freeware XML Development Environment. Download available from www.liquid-technologies.com. Key features include - An Advanced Graphical Schema Editor - XML Editor, with auto-complete, syntax highlighting & validation - Web Service Browser, supports calling Soap services - XPath Expression Builder, visualise XPath expressions - Documentation Generator, HTML Docs from your XML schemas - Code Generation, C++, C#, .Net, Java, VB .Net & VB6 (trial) Liquid XML...XML the smart way! ...

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...

How can I merge 2 documents into one and combine changes?
I have 2 documents. About 75% of the information is identical in both. when I merge them I get a 3rd document that highlights and red-lines changes and shows what has been DELETED. What I want to do is: 1. Have word compare the 2 and delete only duplicate entries 2. Insert additions in one document from other 3. Show me what has been changed 4. Allow me to merge the two and ELIMINATE the correction notations (red text, lines, etc.) Thanks ...

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...

How Do I parse this XML document, most efficiently?
What would be the best way to parse this XML document? I want to avoid using XMLDocument. I don't know if I should use XMLTextReader, or Xpath classes. There is only one element <MessageStore> element in the document, "always" at the end of the document. There will be thousands of <Messages> elements, "always" before <MessageStore> element. 1st Step ===== I need to get the <PR_STORE_ENTRY_ID> data "first". There will always only be one MessageStore element, with one child containing data. 2nd Step ====== I then need all the data from...

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...

XML syntax as string
Hi I am trying to define string xml="<?xml version="1.0"?>"; But it gives error messages. Can any help me define <?xml version="1.0"?> as string... Thanks in advance Rahil string xml="<?xml version=\"1.0\"?>"; I hope it helps. >-----Original Message----- >Hi >I am trying to define >string xml="<?xml version="1.0"?>"; > >But it gives error messages. Can any help me define > ><?xml version="1.0"?> as string... > >Thanks in advance > >...

Generate XML from database and XSD files
Hi all, I have a set of XSD fiels: CSSTypes.xsd EventDetail.xsd E01_Export.xsd E02_Export.xsd E03_Export.xsd E04_Export.xsd E05_Export.xsd etc. I need to provide an exportation system of our database via external web service using sending the XML verified by the previous schemas. Any advise about how to proceed? what about XSD.EXE? is this usefull? Thank you very much, mc. ...

rules, dotnet applications and XML
<xml newbie> Hi all, We are considering using XML to specify rules, policies. This XML file will be used to generate source code in either managed C++ or C#, which will be implemention of API to be used by different applications program (written in .NET language, for this dicussion). You can contribute your ideas. Time for an example. A company or a government body has lot of policies which can be captured in the form of IF-THEN rules. These rules needs to be accomodated in application program(s). o Imagine an application program which processes visa applications, social security etc...

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...

VBA for document formatting
Dear all: I am currently working on a rather large document that I need to format a certain specific way. The document includes nearly 57,000 lines of plain text that need to be indented according to a simple rule so that it can then be imported into an application as a tab- delimited file. My system is a Mac G5 running the latest version of Leopard (not Snow Leopard) which is 10.5.8 and I have Microsoft Office 2004 installed (haven't upgraded to 2008 and will probably wait until next version to upgrade). Below is an example of the type of file I now have: Body Regions;A...

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...