How to validate an XML Fragment against a schema using XmlValidatingReader class


I need to validate an XML fragment against a schema, the issue i got
is that the fragment  i want to  validate his root element if defined
in the schema as  part of a complex type.. so if i dont have that root
element part of my XML fragment it wont validate, it simply said that
it cannot find any of the element. Is there anyway for me to say to
that XML fragment that is part of a complex type ??

the xml fragment xpath is : "//Company/Person"
that return me each Person element and his content, so far so
validate it... it doesnt work since i dont have the Company Element
part of the xpath result, result looks more like :

<Person Manager="false" Degree="MA" Programmer="true" >

Can i tell to the validator that element Person is a complex type
inside Company complex type.... so it does validate it.. or i have to
add a root element(Company in this case) to each xpath result ???

i even try to add : xmlns="http://toto:Company"to each Person element
but it didnt change anything... plz help me im a bit confuse and not
sure what should i do from there.

XML In using:

<Company xmlns:http://toto>
	<Person Manager="false" Degree="MA" Programmer="true" >
	<Person Manager="true" Degree="BA" Programmer="false" >
	<Person Manager="true" Degree="Ph.D" Programmer="false" >

SCHEMA im using :

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2007 sp2 ( by STM
(Societe De Transport de Serv.) -->
<xs:schema xmlns:xs="" xmlns="http://
toto" targetNamespace="http://toto" elementFormDefault="qualified"
	<xs:element name="Company">
			<xs:documentation>Root element</xs:documentation>
				<xs:element name="Person" maxOccurs="unbounded">
							<xs:element name="First" type="xs:string"/>
							<xs:element name="Last" type="xs:string"/>
							<xs:element name="Title" type="xs:string" minOccurs="0"/>
							<xs:element name="PhoneExt">
									<xs:restriction base="xs:integer">
										<xs:maxInclusive value="99"/>
							<xs:element name="Email" type="xs:string"/>
						<xs:attribute name="Manager" type="xs:boolean" use="required"/>
						<xs:attribute name="Programmer" type="xs:boolean" use="optional"/
						<xs:attribute name="Degree">
								<xs:restriction base="xs:string">
									<xs:enumeration value="BA"/>
									<xs:enumeration value="MA"/>
									<xs:enumeration value="Ph.D"/>

7/30/2007 5:13:16 PM
dotnet.xml 7266 articles. 0 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 54


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

how to copy data in folder to ThumbDriv and use in other computer
I've tried to copy data in outlook folders (from office computer unit) to thumbdrive in order to re-paste to another computer (at home) and can read the data again? Please kindly advice/ suggest Answered daily. The file you need is your Personal Folders file (*.pst) It's where all the mail, calendar, contacts etc are stored. Take a look at these pages for info on Outlook data backup or transfer: -- Russ V...

Inter-branch connection using internet access
Hi guys, I'M new in great plains. Now i'm facing the problem is: 1. My main branch at Singapore and have many branches in Malaysia. - Great Plains Database server at Singapore - All branches need to using great plains to access main branch great plains server. Question is: How to make a link or vpn to access to my main branch server via internet access. Thanks Use Windows 2000 Terminal Services or Citrix to access GP Application Regards Ani "Jim" <> wrote in message >...

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

Deleting Custom Fields created in SQL Schema
Hi, I read in another thread that you cannot delete custom fields created in SQL Schemas. Will this be something available in the next version of SQL or CRM 5.0 or how or when can this be done. Concerned as we will have to create a large number of custom fields for an upcoming conversion and if we need to delete any then we are "hooped". Also, what is the limit to the number of custom fields you can add? Thanks! Shauna I am not sure on the next version of CRM if it will allow that or not. Currently there is no way to delete fields. The limit is not really a limit of CRM...

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

Using Sheet instead of tab name
Actually I have two topics. #1. Is there a way to ref. in a formula the sheet name rather than the tab name. Example: sheet4 has a tab name of 08-01-2009 and I want the value from cell a5, but the tab name changes from time to time. So I am looking to get the information from "Sheet4" (a5). not "08-01-2009"(a5) And #2. Is a hard one. I would like to copy a sheet to up to 31 sheets (the number of days in the month) starting again with sheet4 and the sheet name may not be sheet4 every time but it would be starting at the next sheet. Hope I explained properly what I am t...

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

using USB ports
Greetings. I need to receive and send data using USB port. I don't know exactly how to start... Is there an MFC class for me to use? any example code? Thanks in advance John > I need to receive and send data using USB port. > I don't know exactly how to start... Is there an MFC class for me to use? > any example code? USB is a connective bus technology. Saying you want to send/receive with a USB port is like saying you want to send/receive on the PCI bus or a hard drive controller. USB devices are controlled by a driver that exposes either an API (a wacom tablet...

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

Can I use two criteria in the SUMIF worksheet function?
Would appreciate knowing if anyone knows how to do this, and if so what is the syntax. Thanks. No, but you can use multiple criteria with SUMPRODUCT. Example =SUMPRODUCT(--(A1:A100="Jack"),--(B1:B100="Car"),C1:C100=5, D1:D100) will sum d1:d100 cells provides corresponding A cell has Jack, B cell has Cars and C cells equals 5 See also -- Bernard V Liengme remove caps from email "Patricia" <> wrote in message news:35CF94C4-2129-4217-A975-...

[ANN] Liquid XML Studio Released
Announcing the release of Liquid XML Studio 2008 a Freeware XML Development Environment. Download available from 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...

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

Save last row to use in another set of code
I run this bit of code to find the address of the the last cell in column K. Sub test() Dim x As Range Worksheets("NCSA_ISS_ITEM_BOM").Activate Set x = Cells(Rows.Count, "K").End(xlDown) MsgBox x.Address End Sub I would like to save the resulting row address as a variable to run as part of another set of code. How would I go about doing this? If you move your Dim statement outside of the subroutine (that is, move it into the General/Declarations section of the code module you are in), then any code within that code module will be ab...

how do i create an html email using word
MY company would like a simple Word html newletter email that can be updated by various subsidaries. Ideally we'd like to "lock" formatting and some graphics and have editible regions. Any Help? Word is a poor html creation application. I doubt that Word's implementation will enable you to provide the elements you require - however set the web view to view the formatting and save as a web page.Better still use a proper html creation tool to create the page or create it as an attachment as a Word document form or (if you have the full version of Acrobat) a p...

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

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

using SetWindowPos for buttons and edit controls
I havd used the SetWindowPos function for moving and resizing windows with success, but when i try using it with edit controls and buttons i get debug assertions about the first parameter being null. I am using an single doc app with a CFormView derived view. Any ides? If you tell us what kind of assertion and where maybe everybody would have good idea what is going on. For now: most frequent error is to call function that require valid window handle; that means MFC object is attached to window handle. It probably asserts ::IsWindow call indicating above case. Form view (dialog) has ...

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