Re: How to split a flat file using Document and Envelope Schemas

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: David Downing [MSFT] (ddowning_at_online.microsoft.com)
Date: 07/02/04


Date: Fri, 2 Jul 2004 12:43:38 -0700

The example in the SDK directory that demonstrates how to split a flat file
can easily be modified to split an XML document. Do the following:

Run the sample and save the output xml file for later use.
Modify your saved file to include multiple documents.
Add a new Receive Pipeline with an XML Disassembler with the envelope and
document specified.
Undeploy the SDK assembly.
Rebuild your project.
Deploy your updated project.
Modify the existing Receive Location EnvelopeProcessing_RL to use your new
Receive Pipeline (from above).
Change the Address of the Receive Location to have a file mask of *.* rather
than *.txt.
Drop the modified file from above into the EnvInput directory.
You should see the XML Document broken-up into individual documents.

For your reference here is a modified XML Message that contains 4 enveloped
documents:

<ns0:XmlEnvelope xmlns:ns0="http://EnvelopeProcessing.XmlEnvelope">
 <ns0:Source>Northwind Shipping</ns0:Source>
 <ns0:Document>
  <purchaseOrder orderDate="1999-10-20"
xmlns="http://EnvelopeProcessing.PO">
   <shipTo country="US" xmlns="">
    <name>Alice Smith</name>
    <street>123 Maple Street</street>
    <city>Mill Valley</city>
    <state>CA</state>
    <zip>90952</zip>
   </shipTo>
   <billTo country="US" xmlns="">
    <name>Robert Smith</name>
    <street>8 Oak Avenue</street>
    <city>Old Town</city>
    <state>PA</state>
    <zip>95819</zip>
   </billTo>
   <comment>Hurry, my lawn is going wild!</comment>
   <items xmlns="">
    <item partNum="872-AA">
     <productName>Lawnmower</productName>
     <quantity>1</quantity>
     <USPrice>148.95</USPrice>
     <comment xmlns="http://EnvelopeProcessing.PO">Confirm this is
electric</comment>
    </item>
    <item partNum="926-AA">
     <productName>Baby Monitor</productName>
     <quantity>1</quantity>
     <USPrice>39.98</USPrice>
     <comment xmlns="http://EnvelopeProcessing.PO">Confirm this is
electric</comment>
     <shipDate>1999-10-21</shipDate>
    </item>
   </items>
  </purchaseOrder>
 </ns0:Document>
 <ns0:Document>
  <purchaseOrder orderDate="1999-10-20"
xmlns="http://EnvelopeProcessing.PO">
   <shipTo country="US" xmlns="">
    <name>Alice Smith</name>
    <street>123 Maple Street</street>
    <city>Mill Valley</city>
    <state>CA</state>
    <zip>90952</zip>
   </shipTo>
   <billTo country="US" xmlns="">
    <name>Robert Smith</name>
    <street>8 Oak Avenue</street>
    <city>Old Town</city>
    <state>PA</state>
    <zip>95819</zip>
   </billTo>
   <comment>Hurry, my lawn is going wild!</comment>
   <items xmlns="">
    <item partNum="872-AA">
     <productName>Lawnmower</productName>
     <quantity>1</quantity>
     <USPrice>148.95</USPrice>
     <comment xmlns="http://EnvelopeProcessing.PO">Confirm this is
electric</comment>
    </item>
    <item partNum="926-AA">
     <productName>Baby Monitor</productName>
     <quantity>1</quantity>
     <USPrice>39.98</USPrice>
     <comment xmlns="http://EnvelopeProcessing.PO">Confirm this is
electric</comment>
     <shipDate>1999-10-21</shipDate>
    </item>
   </items>
  </purchaseOrder>
 </ns0:Document>
 <ns0:Document>
  <purchaseOrder orderDate="1999-10-20"
xmlns="http://EnvelopeProcessing.PO">
   <shipTo country="US" xmlns="">
    <name>Alice Smith</name>
    <street>123 Maple Street</street>
    <city>Mill Valley</city>
    <state>CA</state>
    <zip>90952</zip>
   </shipTo>
   <billTo country="US" xmlns="">
    <name>Robert Smith</name>
    <street>8 Oak Avenue</street>
    <city>Old Town</city>
    <state>PA</state>
    <zip>95819</zip>
   </billTo>
   <comment>Hurry, my lawn is going wild!</comment>
   <items xmlns="">
    <item partNum="872-AA">
     <productName>Lawnmower</productName>
     <quantity>1</quantity>
     <USPrice>148.95</USPrice>
     <comment xmlns="http://EnvelopeProcessing.PO">Confirm this is
electric</comment>
    </item>
    <item partNum="926-AA">
     <productName>Baby Monitor</productName>
     <quantity>1</quantity>
     <USPrice>39.98</USPrice>
     <comment xmlns="http://EnvelopeProcessing.PO">Confirm this is
electric</comment>
     <shipDate>1999-10-21</shipDate>
    </item>
   </items>
  </purchaseOrder>
 </ns0:Document>
 <ns0:Document>
  <purchaseOrder orderDate="1999-10-20"
xmlns="http://EnvelopeProcessing.PO">
   <shipTo country="US" xmlns="">
    <name>Alice Smith</name>
    <street>123 Maple Street</street>
    <city>Mill Valley</city>
    <state>CA</state>
    <zip>90952</zip>
   </shipTo>
   <billTo country="US" xmlns="">
    <name>Robert Smith</name>
    <street>8 Oak Avenue</street>
    <city>Old Town</city>
    <state>PA</state>
    <zip>95819</zip>
   </billTo>
   <comment>Hurry, my lawn is going wild!</comment>
   <items xmlns="">
    <item partNum="872-AA">
     <productName>Lawnmower</productName>
     <quantity>1</quantity>
     <USPrice>148.95</USPrice>
     <comment xmlns="http://EnvelopeProcessing.PO">Confirm this is
electric</comment>
    </item>
    <item partNum="926-AA">
     <productName>Baby Monitor</productName>
     <quantity>1</quantity>
     <USPrice>39.98</USPrice>
     <comment xmlns="http://EnvelopeProcessing.PO">Confirm this is
electric</comment>
     <shipDate>1999-10-21</shipDate>
    </item>
   </items>
  </purchaseOrder>
 </ns0:Document>
</ns0:XmlEnvelope>

-- 
Dave
This posting is provided "AS IS" with no warranties, and confers no rights.
"Live_Love_Laugh" <OnlineSubscribe@yahoo.com> wrote in message
news:eEY1XZGYEHA.4092@TK2MSFTNGP11.phx.gbl...
> Could you tell me how to split xml messages using XML disassembler. I have
a
> xml file Employees which I have to split into individual Employee
messages.
> I defined schema for Employees and Employee separately. Do I have to drive
> this through any orchestration to split individual messages? There are
> samples regarding flat file disassembler but there is no sample for XML
> disassembler. Any help is appeciated.
>
> Thanks,
> Live_Love_Laugh
>
> "Kristof Verschaetse" <kristof.verschaetse@belgacom.net> wrote in message
> news:40d7e50b$0$8399$a0ced6e1@news.skynet.be...
> > This is something I keep on struggling with.
> > Splitting an XML message works fine but how to split a flat file ?
> > One of the approaches I took was using a flat file disassembler followed
> by
> > an XML disassembler in a receive pipeline. In the flat file
disassembler,
> I
> > specified the envelope schema (which also contains the imported document
> > schema) somehow hoping that the flat file disassembler would take the
> > complete schema into account, while in the XML disassembler I specified
> both
> > (the envelope schema as envelope and the other schema as document).
> > The problem however is that the flat file disassembler doesn't seem to
> know
> > the root element of my document scheme ("the namespace:rootelement"
> element
> > is not declared" error message appears when trying to use the ffdasm
> > utility).
> > This somehow seems logical - after all, an envelope is an envelope - but
> > what is the solution then ?
> > Another approach I took was to use 3 schemas (the complete schema, the
> > envelope and the document - the complete schema being the combination of
> the
> > envelope and the document) but with this approach I ran into problems
> using
> > the same namespace twice.
> >
> > Any help is highly appreciated.
> >
> > Kristof
> >
> >
> >
>
>


Relevant Pages