Main Menu
Latest News
EDIReader Overview
HL7 and ACH
FAQs - EDIReader
FAQs - EDIWriter
Download Open Source Version
Custom Transformation Services
Contact Us
Using EDIReader with J2SE 5.0 XPath Evaluation
Saturday, 03 February 2007
The XPath Evaluation API, new in Java 2 SE 5.0, may be used to query EDI content with EDIReader. This provides an alternative to XSLT or JDom/Jaxen approaches which are still available. To use the XPath Evaluation API, you use EDIReader as a SAX parser to build a W3C DOM by means of a Transformer. XPath queries can then be performed against the EDI data as illustrated in the program portion shown below.

import com.berryworks.edireader.EDIReaderFactory;
import ...

public class QueryEDIwithXPath {
    InputSource inputSource =
        new InputSource( new FileReader( "edi.dat" ));
    String query =

    public String query() throws Exception {
            XMLReader ediReader =
               EDIReaderFactory.createEDIReader( inputSource );

            DOMResult dom = new DOMResult();
            Transformer transformer =
                new SAXSource( ediReader, inputSource), dom );

            return XPathFactory.newInstance().newXPath().
                        evaluate( query, dom.getNode() );

< Prev   Next >