473,466 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How can I get a XmlDataDocument.Load to ignore a placeholder "record" in XML?

All,

I am trying to read an XML of a set of records (an "order") from one machine
and then turn it into a set of records on another machine. But some of the
order's dependent records are optional, and I'd like to continue to bypass
them when the original user bypassed them.

This set spans four tables. One is the header table and the other three are
all subject to it. These three are misc charge, instruction, and detail. For
any given order, the misc charge and instruction data are "optional" - the
order can go without records in them - but an order must have at least one
detail record.

Say someone sends the simplest possible valid order.

=================================================
The XML we get is:

<OrderDump>
<order_header order_number="B948124C-8C42-7714-91B5-05E4A8F84DC3">
<order_name>My Order</order_name>
<order_miscellaneous_charge />
<order_instruction />
<order_detail>
<upc>1094723</upc>
</order_detail>
</order_header>
</OrderDump>

=================================================
Here is the schema (XSD):

<?xml version="1.0" encoding="utf-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop">
<xsd:element name="OrderDump">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="order_header" sql:relation="order_header">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="order_name" type="xsd:string" minOccurs="1" />
<xsd:element name="order_miscellaneous_charge"
sql:relation="order_miscellaneous_charge" nillable="true">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="transaction_code" type="xsd:string"
minOccurs="0" />
<xsd:element name="amount" type="xsd:float" minOccurs="0" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="order_instruction"
sql:relation="order_instruction" nillable="true">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="instruction_type" type="xsd:string"
minOccurs="0" />
<xsd:element name="message_text" type="xsd:string" minOccurs="0"
/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="order_detail" sql:relation="order_detail">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="supc" type="xsd:string" minOccurs="1"
maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="order_number" type="xsd:string" />
</xsd:complexType>
<xsd:key name="order_headerKey1" msdata:PrimaryKey="true">
<xsd:selector xpath="." />
<xsd:field xpath="@order_number" />
</xsd:key>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>

=================================================
Here is my code (C# 1.1.4322):

string xmlFilename = @"C:\OrderDump.XML";
DataSet orderDumpDataSet = new DataSet();
orderDumpDataSet.ReadXmlSchema(@"C:\OrderDump.xsd" );
XmlTextReader reader = new XmlTextReader(xmlFilename);
XmlDataDocument document = new XmlDataDocument(orderDumpDataSet);
document.Load(reader);

=================================================

This code treats the XML's placeholders in _misc_charge and _instruction
(<order_miscellaneous_charge /> and <order_instruction />, respectively) as
valid records, and inserts a bogus row for each (with mostly NULL values)
into orderDumpDataSet.Tables[1] and [2]. This is Bad.

It'd be nice if we could apply a setting to the XSD, orderDumpDataSet, or
XmlDataDocument - informing the object's consumers that when the XML gives
nothing but a placeholder for these tables, then (for this instance) the
DataSet should record no DataRow in their respective DataTables.

Is this possible? Or am I going to have to search through the DataTables and
weed out the null values later? (Which is certainly possible, but a pain.)

--
zimriel sbc dot
at global net
..
http://pages.sbcglobal.net/zimriel/
*new improved shorter .sig*
Feb 21 '06 #1
0 1186

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

Similar topics

0
by: William Wisnieski | last post by:
Hello Everyone: I'm having a very strange problem occurring with my Access 2000 database. I call it the "mystery record." Here's the story: I have a query by form that returns a record set...
4
by: Tim | last post by:
I have used a graphic 'next record' button on a form. How can I stop it from going past the last existing record? In other words, I don't want it to take the user to a blank record. Thanks Tim
3
by: Lee-Anne Waters via AccessMonster.com | last post by:
Hello, i have just upgraded my database from access 97 to access 2000 and updated all the jet paks. however when i use my import functions to import orders (.csv) one order will appear as a group...
1
by: me | last post by:
I'm building a multi user app where many admins will be making calls to people in one table. I want to keep things simple and find a way to prevent 2 or more admins from working on the same record...
3
by: vanvee | last post by:
Hi I am trying to program a VB.Net Windows application (in a client server environment with multiple users) and am seeking some help about a possible technique to handle concurreny issues. I am...
3
by: domcatanzarite | last post by:
How would one create a button that on click advances the form to the next "non recurring record" as opposed to the next record. The field the button needs to que from has groups of duplicate...
1
by: AA Arens | last post by:
I my form I have put record navigation buttons. When I choose just before the last record, the "Go to next record" button, access automatically start with a new record instead of a message that...
2
by: Simon | last post by:
Dear reader, Same times a form pops up with the following message "Other user has updated the record" and I can save my update or store it on the clipboard for update later. I am the only...
25
by: tekctrl | last post by:
Anyone: I have a simple MSAccess DB which was created from an old ASCII flatfile. It works fine except for something that just started happening. I'll enter info in a record, save the record,...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.