XML Converters

A great deal of useful data is found in plain-text formats, not as XML. With DataDirect XML Converters, you can convert many formats to XML on the fly, so they can be queried with DataDirect XQuery. Converters are available for EDI messages (X12, EDIFACT, EANCOM, IATA, HL7, and SEF), along with other flat file formats like tab delimited, comma separated value, JSON, dBase files, and many more.

For instance, there are literally thousands of versions and subversions of EDI formats, and no standard way to query or process them. XML Converters allow you to read any of these formats as XML without writing code to parse them. Consider the following EDI message:

UNA:+.? 'UNB+UNOA:4+STYLUSSTUDIO:1+DATADIRECT:1+20051107:1159+600
2'UNH+SSDD1+ORDERS:D:03B:UN:EAN008'BGM+220+BKOD99+9'DTM+137:20051
107:102'NAD+BY+5412345000176::9'NAD+SU+4012345000094::9'LIN+1+1+0
764569104:IB'QTY+1:25'FTX+AFM+1++XPath 2.0 Programmer?'s Referenc
e'LIN+2+1+0764569090:IB'QTY+1:25'FTX+AFM+1++XSLT 2.0 Programmer?'
s Reference'LIN+3+1+1861004656:IB'QTY+1:16'FTX+AFM+1++Java Server 
Programming'LIN+4+1+0596006756:IB'QTY+1:10'FTX+AFM+1++Enterprise 
Service Bus'UNS+S'CNT+2:4'UNT+22+SSDD1'UNZ+1+6002'

When this is read using an XML Adaptor, it is converted to the following XML (for brevity, only the first few lines are given):

<?xml version="1.0" encoding="utf-8"?>
<EDIFACT>
  <UNB>
    <UNB01>
      <UNB0101><!--0001: Syntax identifier-->UNOA</UNB0101>
      <UNB0102><!--0002: Syntax version number-->4</UNB0102>
    </UNB01>
    <UNB02>
      <UNB0201><!--0004: Interchange sender identification-->STYLUSSTUDIO</UNB0201>
      <UNB0202><!--0007: Identification code qualifier-->1</UNB0202>
    </UNB02>
    <UNB03>
      <UNB0301><!--0010: Interchange recipient identification-->DATADIRECT</UNB0301>
      <UNB0302><!--0007: Identification code qualifier-->1</UNB0302>
    </UNB03>
    <UNB04>
      <UNB0401><!--0017: Date-->20051107</UNB0401>
      <UNB0402><!--0019: Time-->1159</UNB0402>
    </UNB04>
    <UNB05><!--0020: INTERCHANGE CONTROL REFERENCE-->6002</UNB05>
  </UNB>

  <!-- !!! SNIP !!! -->

</EDIFACT>

An XML Converter is invoked using the doc() function. The following XQuery extracts the sender, recipient, time, and date from the EDI message. Note that the query need not understand anything about the complex EDI format, it uses the XML structure produced by the XML Converter.

let $msg := doc("convereter://EDI?transaction.edi")/EDIFACT/UNB
return
  <transaction-summary>
    <sender>{ $msg/UNB02/UNB0201/text() }</sender>
    <recipient>{$msg/UNB03/UNB0301/text()}</recipient>
    <date>{$msg/UNB04/UNB0401/text()}</date>
    <time>{$msg/UNB04/UNB0402/text()}</time>
  </transaction-summary>

Here is the output of the above query.

<transaction-summary>
  <sender>STYLUSSTUDIO</sender>
  <recipient>DATADIRECT</recipient>
  <date>20051107</date>
  <time>1159</time>
</transaction-summary>

Prev Next
Custom URI Resolvers Making SOAP Requests from DataDirect XQuery™