473,770 Members | 5,925 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing valid XML document based on Schema

Does anyone have a best practices recommendation on writing a valid
XML document based on a 3rd party XML schema?

I have a working solution but I would like to know if anyone has a
better approach.
My solution:
1) Pull the data from the database into datatables (in my case, this
is DB2).
2) Validate all required data columns (I've written a method that
iterates through all the datatables rows and throws an exception if
anything would invalidate the resulting XML file).
3) Using the XmlWriter class, write the XML file.

What complicates the logic is that the source data is spread over
multiple DB2 tables and the resulting XML document can contain
multiple instances of several types.

Regards,
Thomas

May 8 '07 #1
1 2811
"Thomas" <th***@northsta te.netwrote in message
news:11******** **************@ w5g2000hsg.goog legroups.com...
Does anyone have a best practices recommendation on writing a valid
XML document based on a 3rd party XML schema?

I have a working solution but I would like to know if anyone has a
better approach.
My solution:
1) Pull the data from the database into datatables (in my case, this
is DB2).
2) Validate all required data columns (I've written a method that
iterates through all the datatables rows and throws an exception if
anything would invalidate the resulting XML file).
3) Using the XmlWriter class, write the XML file.

What complicates the logic is that the source data is spread over
multiple DB2 tables and the resulting XML document can contain
multiple instances of several types.
How about validating the resulting document against the schema?
--
John Saunders [MVP]
May 8 '07 #2

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

Similar topics

5
2413
by: Greg | last post by:
Hi everybody, so, I would like to use XML files for some parts of my website. I would like to respect W3C XHTML 1.1 recommendation. Then, I have these two docs : o My XML file: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>
4
2943
by: Jari Kujansuu | last post by:
I can successfully parse XML document using SAX or DOM and I can also validate XML document against schema. Problem is that my program should deal with user-defined schemas which means that when I parse some element from XML document I don't know until runtime the type of the element (it depends on the type used in user-defined schema). XML parser obviously validates that the value of the element is correct type but still I receive that...
1
4141
by: dpakpaul | last post by:
Hi, I have an XSD schema where I have attributes that are declared to contain non string values such as integers etc. Take for example, this declaration - <xs:attribute name="IsThisTrue" type="xs:boolean" /> Now, I want to write or modify an XML document using the DOM API (using C#) where this attribute will be given a boolean value. Then the resulting XML document will be validated against the schema
0
906
by: CJJ | last post by:
Hi, I have an xml schema that defines a number of complex structures where the elements are in sequence, though not all elements are required. <ComplexXmlSchema> <Node A>value</Node A> <Node B>value</Node B> <Node C>value</Node C> </ComplexXmlSchema> I am looking for a way to populate this xml document in random order,
5
1516
by: member | last post by:
Hi, I'm looking for tools which can valid an XML document with and XSD schema. I'm using Eclipse and I don't know how to do that and if I can ? Thanks, Laurent Duretz
1
2072
by: GU | last post by:
How can one get a list of enumeration values for a given element in an XML schema? I have been looking at the Schema Object Model, but I'm making very little headway. Can anyone give me a nudge in the right direction? Specifically, I am using Actions Pane to assist in creating a WordML document. For elements with enumerated values, I want to provide the user with the list of valid values from the schema. For example, if I have an...
1
2886
by: Chris Lieb | last post by:
I have an XML Schema file that I know is correct becuase I currently use it in a VB6 program to validate XML documents. Also, if I load an XML file into VS2005 that is not valid against this schema, I get XML errors (blue squigglies) in a few places, which indicates to me that I should get validation errors while validating through code. When I try to validate an invalid document, I never get any validation errors. I have tried many...
2
2192
by: Arpan | last post by:
I came across the following statement at http://windowssdk.msdn.microsoft.com/en-us/library/hdf992b8.aspx: Although an XML document is considered to be well formed if it meets all the syntactical requirements defined by the World Wide Web Consortium (W3C) Extensible Markup Language (XML) 1.0 Recommendation, it is not considered valid unless it is well formed and also conforms to the constraints defined by its DTD or schema. Therefore,...
0
2701
by: Thomas | last post by:
How do you create an XML document based on an XML Schema? I have an XML Schema that defines several primary XML document types (i.e. the top-level element contains 4 complex type child elements in a choice group). I used xsd.exe to generate classes to simplify setting the values in the instance objects. My question is how do I serialize the objects to an XML document based on a specific child element referenced in the XML schema's...
0
9591
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
10228
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...
0
10057
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10002
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
9869
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
7415
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
6676
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
5312
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...
1
3970
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.