473,414 Members | 1,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

How to dynamically load schema from a file and then assign to xmldocument and validat

I am creating in memory xmldocument.Previously I were validating my file against a dtd file and then by the help of GetElementByID read my needed node.
i.e.

Expand|Select|Wrap|Line Numbers
  1. XmlDocumentType doctype = null; 
  2. doctype = statementsDocument.CreateDocumentType("queries", null,statementsPath +"\\Validation.dtd", null); 
  3. statementsDocument.AppendChild(doctype); 
  4. nodeElem = statementsDocument.CreateElement("queries"); 
  5. statementsDocument.AppendChild(nodeElem); 
  6. .... 
Now I have created validate.xsd.I don't know how to validate through xsd file
Sometime Later I want's validate from this validate.xsd then read my element by Get element ByID()



MY validate.dtd were

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <!--DTD generated by XMLSpy v2006 sp2 U (http://www.altova.com)--> 
  3. <!ELEMENT queries (query+)> 
  4. <!ELEMENT query (statement)> 
  5. <!ATTLIST query 
  6. type CDATA #REQUIRED 
  7. id ID #REQUIRED 
  8. <!ELEMENT statement (#PCDATA)> 
and now my validate.xsd is

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?> 
  2. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> 
  3. <xs:import namespace="http://www.w3.org/XML/1998/namespace"/> 
  4. <xs:element name="queries"> 
  5. <xs:complexType> 
  6. <xs:sequence> 
  7. <xs:element ref="query" maxOccurs="unbounded"/> 
  8. </xs:sequence> 
  9. </xs:complexType> 
  10. </xs:element> 
  11. <xs:element name="query"> 
  12. <xs:complexType> 
  13. <xs:sequence> 
  14. <xs:element ref="statement"/> 
  15. </xs:sequence> 
  16. <xs:attribute name="type" type="xs:string" use="required"/> 
  17. <xs:attribute name="id" type="xs:ID" use="required"/> 
  18. </xs:complexType> 
  19. </xs:element> 
  20. <xs:element name="statement"> 
  21. <xs:complexType mixed="true"> 
  22. <xs:choice minOccurs="0" maxOccurs="unbounded"/> 
  23. </xs:complexType> 
  24. </xs:element> 
  25. </xs:schema>
May 7 '06 #1
0 2606

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Winston | last post by:
Hi, I want to use the Webbrowser Control (the Internet Explorer Control) to display an XML-structure within a C# WinForm. The way the IE displays a XML-file in its native form is exactly what I...
3
by: caroline.fryer | last post by:
I have an xml document which I only want to load part of depending on the element 'Name'. The structure of my xml document looks like this: <FileDefaults> <File> <Name>Name 1</Name>...
3
by: Emily John | last post by:
I am using xml serialization to generate my xml document. I am getting the data as stream of memory and then converting it to xml document object without saving it to the file system. How do I...
1
by: Chris Fink | last post by:
I am receiving xml documents from a customer without a reference to a doctype. I know what the Doctype DTD should be need to insert the declaration as follows <?xml version="1.0"...
2
by: comic_rage | last post by:
how do you add a comment line/section to an xml schema xsd file? like this <!-- =============================================================== --> <!-- =================== My comment line ...
7
by: Mac | last post by:
Hi all I have a asp.net application which calls a web service via a wdsl file which retrieves an XML String. The XML String is from a adodb recordset saved as via a stream. Dim oRS as New...
1
by: Jeff Smith | last post by:
Can I load custom web user controls dynamically and access the properties and methods without having to explicitly define custom control types (example 2 below). I have custom web control named...
0
by: delphiconsultingguy | last post by:
Hi all, Spent WAAAYYY too much time trying to figure this out because there's not many good examples out there, so in the interest of sparing y'all from suff'rin same, I've pasted it into...
4
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... We've got a lot of places in our code where we read relatively small xml user preference blocks. Currently that's creating a new XmlDocument in every spot. I was thinking we might see...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.