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* 


0
zimriel (1)
2/21/2006 11:33:55 PM
dotnet.xml 7266 articles. 0 followers. Follow

0 Replies
395 Views

Similar Articles

[PageSpeed] 37

Reply:

Similar Artilces:

Inserting specific number of records
I have a Data Entry form in which the user have to insert a specific numbrer of record, depending on the type of product he choose. Ej: The product "A" have to have 3 data, so it will need to insert 3 record on the table only, no more. I have created a simple code in VB that I supose to have to restrcit the number of record records, depending on a Textbox value **************************************** CODE **************************************** Private Sub LECTURA_BeforeUpdate(Cancel As Integer) On Error GoTo Err_Lectura Dim Respuesta If Form.CurrentRecord <= Forms...

Delete all records from CRecordset
Hello, How can I delete all recodors from a CRecordset? Is it possible to use a SQL clause like "DELETE * FROM my_table"? Thanks! This may help you get started: http://msdn2.microsoft.com/en-us/library/z5139kz6(VS.80).aspx Tom "Tulio" <Tulio@discussions.microsoft.com> wrote in message news:FEAB1327-8C93-44EF-9527-E1F4DFB56A82@microsoft.com... > Hello, > > How can I delete all recodors from a CRecordset? > Is it possible to use a SQL clause like "DELETE * FROM my_table"? > Thanks! There are two ways: 1. write a loop to step through th...

Need to populate a Report with several records
In short, I have one report containing 5 records from the same table. The individual records are layed out to support proper printing. I need to populate each record with from the same table. I can not give them all the same pointer to the table or I get 5 copies of the same record. How can I populate those 5 records with 5 records from my table? I think you need to have a group by in your report. Thus you will get 1 group of data for each of the 5 that you are refering to as 5 records. "Bill" wrote: > In short, I have one report containing 5 records from the same t...

unable to set a record as private (activities)
Microsoft CRM v3 Customers and prospects are requesting the ability to mark a record (primarily notes and emails) as private such that only the owner and other internal party users on the record are able to open it. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http...

Macro Recorder #2
I have a very basic question( I think). When you are recording a Macro how do you stop and then restart where you left off? For example I have a repetitive task that moves columns from one spreadsheet to another. The problem is that there are about 40 columns I am required to move. As I record the macro can it be stopped and then restarted if I have to close Excel and return later? I can't find the answer to my question documented anywhere. Thank You, Greg You can stop it, but when you start again it will create a new subprocedure, you can go in and copy/paste the second after the firs...

Opening a new record form but allowing searches
I changed the "Data Entry to Yes" to have my forms open for new records, but it seems to have disabled my ability to move from record to record or allow for searches. Is there another way that I could have set it up so that it allows for both? On Thu, 4 Mar 2010 17:54:06 -0800, Fallout <Fallout@discussions.microsoft.com> wrote: >I changed the "Data Entry to Yes" to have my forms open for new records, but >it seems to have disabled my ability to move from record to record or allow >for searches. Is there another way that I could have set it up ...

New records don't display correctly in subforms after save.
Access 2003, XP Pro I have a main form with two separate subforms. I view various records by clicking on some list boxes. To add a new record, I select Records, Data Entry. I then (1) Make a selection in a combo on the main form. (2) Make a selection in a combo and enter some text in a textbox on subform1 (3) Make a selection in a combo on subform2 Subform2 has some code on the After Update event that saves the new record and goes to a previously selected record in cbo1 on the main form (cbo2 has code on the After Update event to go to that record). Here's the cod...

RW records per report body
I modified a packing slip and all I did was change the records per body from 25 to 45. The report had been essentially limiting the number of records and only prinitng 2/3rds down the page. They used to put something like a survey at the bottom. Now, they want the detail to take up the entire page. Since the PF/RFs where very small, I figured that it was the records per report body that was causing this behaviour. Now, I'm wondering, even if I was right.. Should I have changed it to 0 vs 45? Tx Les Les, Typically, the number of records in the report body is controlled by the am...

add new record if not found in search
I have a combo box that lists all projects. I want to use it to search the form (which has status records for some of the projects) and if it finds a match position the cursor for the user to start editing the record. That part works swell. If there is no match I want to add a new record, populate a few fields, and position the cursor for the user to start entering data. How do code "if there isn't a match" ? I'm going to assume that you are not adding new entries to the list of projects. That the combo box is not bound and is in the form header of a continuous form...

crm should flag duplicate records when entering records.
auto dupe check should be added in the new version. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Community/NewsGroups/dgbrowser/en-us/default.mspx?mid=3ff472af-3ca8-4c43-9422-5411109cc34f&dg=microsoft.public.crm While I...

User and Records Move to a Child Business Unit
We are unable to move a User from one Business Unit to another Child BU. CRM V3.0 'SQL Server Timeout' error message. User has 56,000 records, incl notes, activities etc Is there another process to follow -- prior to moving Users and assigned contacts to another BU rather than just selecting the option to Change Business Unit? Regards, Mandy Franklin. Hi Mandy, perhaps, you could try to follow the steps outlined in http://support.microsoft.com/kb/918609 to increase SQL Server timeout values? Before doing so I'd backup CRM database and put some SQL monitoring in place t...

VBA needed to delete corrupt records from MsysObjects
I have a form that will not open in normal or design mode and there are 2 Form_~TMPCLP######## objects in my VBA Project window, and there are 2 Objects with the same name in the MsysObjects table of type 32678 which means they are forms. I expect that if I am able to delete these I might be able to salvage my form. However, Nothing I have tried allows me to delete anything from MsysObjects. OH there is one other issue, Not able to run any code from the data base with that form in it. I get a message that the module can't be found... Nothing specific. So I have been ...

2008R2 DNS Manager freezes for glue record deletion..
Hi, Say that my domain is MyDomain.LAN I open the DNS manager and rightclick on the Forward Lookup Zones "LAN" and select Properties / Name Servers. On the list there is one old dns server with IP address 'unknown'. When I select this server for removal and click the OK button I get this error: 'Do you want to delete the glue record olddnsserver.mydomain.lan. 192.168.77.10? Yes/No' The DNS manager has already frozen and I can not confirm Yes nor close the dialog nor the manager. The only way out is to kill it in Task manager. Is thsi a k...

Retrieve all record if check box = 0 (Not checked)
Hello, I would like to see ALL (0 and -1) records if my check box in my form is not checked (0) and if checked (-1) I would like to see only record with -1 (with check mark) This is what I have, but as expected it will return only record with 0 OR -1 SELECT tblSite.Site, tblSite.Lab FROM tblSite WHERE (((tblSite.Lab)=[Forms]![My Sites Groups]![CheckLab])); Thank you, Silvio Try this -- SELECT tblSite.Site, tblSite.Lab FROM tblSite WHERE tblSite.Lab = IIF([Forms]![My Sites Groups]![CheckLab] = 0, Between -1 AND 0, -1); -- Build a little, test a little. "S...

include field on record that tells whether it has a note or not
Hi all, Our user add notes to records. To see whether a record contains notes or not by default you'd first have to open a record and then go the sidetab 'Notes'. I have made a boolean field on the record that tells whether the record has notes or not. Next, I included this field as a column in the list view. This way you can see in advance which records contain notes and don't. My question is if it is possible to create a workflow rule that updates the boolean once a note is created. Or if there's another way to make it easier to find out if a record contains notes. T...

get records from before 6 months ago
Hello everyone, I'm trying to get records BEFORE 6 months ago based on 2 date feilds. Here's the script: if object_id('tempdb.dbo.#hha') > 0 drop table #hha select * into #hha from temp.dbo.op with (nolock) where (Date1 < DATEADD(MONTH, -6, GETDATE()) and Date1 <> '1900-01-01 00:00:00') or (Date2 < DATEADD(MONTH, -6, GETDATE()) and Date2 <> '1900-01-01 00:00:00') *After executing the script and looking the data in the temp table I don't think the logic is correct. What do you guys think? Any help will be gre...

Active Accounts View and Active Contacts view is taking lot of time to show the records
Active Accounts View and Active Contacts view is taking longer time to load for some users. problem: we have role called "Sales Team". this role doesn't have Global(organization) read access for Accounts and contacts, rather it was set to Parent:child Business Units. Initially when we don't have much data in CRM, No user was facing performace related issues. now, the main problem is when the data is growingup in database, we started seeing problems forsome users. Active Accounts view and Active Contacts view is taking for ever to load. some times it is taking more than 17...

Count records in update query
How can I count the number of records which have been updated by my UPDATE query? I tried using DCount but it said you can't use an action query as an argument. Robert Robert wrote: > How can I count the number of records which have been updated by my UPDATE > query? I tried using DCount but it said you can't use an action query as an > argument. > > Robert > > > I would suggest that you add a column to your table that records the time the record was last updated. Then run a query looking for records updated in the last few seconds (depending ...

Assign Lead record
Hi, I just notice in CRM 3.0. Suppose lead1 is created by user A. Then user A assign lead1 to user B. User A cannot see the lead1 anymore even user A change its view to Active Lead. As i believed in CRM 1.2, when owner assigned the record to new user, the owner was automatically getting shared with the record. So owner still can see the lead when changing it to Active lead. Is it intended behavior in CRM 3.0 that once the record is being assigned, the owner has to be manually added in the sharing field? Carrie Hi Carrie, If you tick "share reassigned entities with original owne...

HELP!!!!!! Please
Hi. I have a emergency!! When I want to save a new lead, I receive an error that says "Can't be inserted a Duplicated Record". The Leads database is empty. I don't know what to do ... Somebody please help me ... Thanks. -- MCP SBS 2003 Have you installed the rollup 2 ? http://www.microsoft.com/downloads/details.aspx?FamilyID=81674da5-ffef-492a-a7b1-7e1f1951b05f&DisplayLang=en /Aamir Yes, I did. -- MCP SBS 2003 "Aamir" wrote: > Have you installed the rollup 2 ? > > > http://www.microsoft.com/downloads/details.aspx?FamilyID=81674da5-...

Uploading Large Files to Contact Record as Note
I am unable to upload a file any larger than 39MB to a contact record. I receive the following error: File Upload Failure There was a problem while attempting to upload the requested file. Check the file path and try again. There is a problem communicating with Microsoft CRM server. The server might be unavailable. If the problem persists, contact your system administrator. I have modified the registry on the CRM Server for maxfileupload and in the web.config to allow up to 88MB files. There will not be a high number of files this large and I have plenty of room in SQL. The SQL Serv...

It takes time to load records in MS CRM Client
HI All, I am facing a serious problem, whenever i access CRM through Client, it takes time to load and after getting records in it, it is not shown properly. Why so??? please help me out. Client is always connected to server, Is there any way to check if it is connected or not. Thanks in Advance. Nitin Verma Nitin, I had the same issue with a client of mine and after working through all of the standard MS suggestions we found that by removing the clients local OST file and recreating it from the exchange server the issue was resolved. MS informed us of 2 items. 1) Having more then 1,000 e...

this record can not be deleted
cant delete test records that ive created,error message its associated with another record. attempted to delete previous associated record, no luck. can i clean out old records? looking for options i have quotes, orders and invoices that are linked together.(test runs) i can't delete some of them via the user interface. I assume this is for history integrity. I would reinstall, except for the pain it took getting my contacts and accounts in. I have the same problem. I added some custom fields into the contact table and now I can't delete it. It tells me the data is part ...

Remittance Check Number on PM History Records
Currently you can't print a history report that will show you what was included on a remittance or check stub from a check that has already been posted and moved to history. If the PM30200 table had a column that showed the Remittance Check Number for every record, then we could print history remittance report. Some customers are trying to print a report at the end of each month to give to their vendors that show all the checks that were paid to them and the detail of what was on each check. If you had a invoice and credit memo for the same amount and applied to each other, there...

Add Record from form into two tables
I have a form (frm_Invoice) that records phone serial # from customers. I want to create a new record in both the tbl_Inventory and tbl_Inventory_Detail when someone scans in a DEC_SN into the frm_Invoice. The issue I am running across is that the tbl_Inventory_Details has a child relationship to the tbl_Inventory. I chose this set up because most of the inventory is manually entered from shipments received from a warehouse. I created a form and sub form for the inventory tying the SN_ID from each table on a one to many relationship. I do not know how to update both tables at ...