Using DataDirect XQuery™ with EDI

Organizations often need to be able to handle not only XML ACORD standards, but also older non-XML standards, like ACORD EDI, or even X12 EDI messages. Because EDI does not use XML grammars, it can be difficult to access using XQuery or other XML query languages. But thanks to the integration with DataDirect XML Converters, even EDI messages can be easily accessed using DataDirect XQuery™. DataDirect XQuery's™ integration with DataDirect XML Converters allows organizations to handle difficult data integration scenarios, such as those in which some business partners are dealing with XML grammars, but others still rely on EDI formats.

Using DataDirect XQuery™ to access EDI messages can be achieved at the API level (by converting an EDI message into XML and then binding the resulting stream to an XQuery external variable), or by using the fn:doc() function and the proper URL format supported by DataDirect XML Converters™.

As an example, suppose we receive a X12 Insurance Plan Description message (click here to see the X12 message), and we need to extract information about the referenced party from our database. The following XQuery (click here to open the XQuery document) does that:

import module namespace example = "http://www.datadirect.com/xquery/examples" at "acord_verbs.xquery";

declare namespace tx="http://ACORD.org/Standards/Life/2";
declare option ddtek:detect-XPST0005 "no";

let $request:= doc("converter:EDI:long=yes? 100.x12")
let $person := example:x12-to-party($request, "Party_1")
return
    example:insert-186 (
        <tx:TXLifeRequest> {
            <tx:OLifE> {
                $person
            }
            </tx:OLifE>
        }
        </tx:TXLifeRequest>
    )

The fn:doc() function references the custom DataDirect XML Converters™ URL scheme, which triggers the on-the-fly conversion of the X12 message to XML; then, information about the referenced person and address is extracted and wrapped in a tx:Party element. This tx:Party element is then used to add to our database — the same way we do in the example Managing Complex Update Requests, which shows insertion of new items described in ACORD tc=186 messages. Similarly, the ability to reuse XQuery functions is clearly another good reason for using XQuery modules in your code.

Integration of DataDirect XML Converters™ with DataDirect XQuery™ allows organizations to handle difficult scenarios in which not all business partners are dealing with XML grammars; the underlying streaming architecture of XML Converters perfectly fits the streaming processing capabilities of DataDirect XQuery™ to ensure performance and scalability even when dealing with non-XML messages.


What's Next

Our next topic, Using DataDirect XQuery™ to Generate PDF describes how to use DataDirect XQuery™ to create reports based on the results of a database search.

DataDirect XQuery FAQ

This informative DataDirect XQuery® FAQ answers frequently-asked questions about DataDirect XQuery® , including questions about performance, scalability, use-cases, resources, and more.

If you're more of a hands-on learner, then download a free copy and start exploring DataDirect XQuery® today!

New Case Study

Gevity produces sales proposals in real time using DataDirect XQuery® . See how Gevity uses DataDirect XQuery® to combine Web service data from SalesForce.com with relational data in Oracle in a pricing engine for HR management.