5 DataDirect XML Converters® Properties : EDI XML Converter Properties

EDI XML Converter Properties
You can use the Electronic Data Exchange (EDI) XML Converter to convert EDI files to XML and vice versa.
Properties are the same for most supported EDI dialects; however, some properties are dialect-specific (cexpand and hexpand, for example).
TIP: DataDirect XML Converters supports the Standard Exchange Format (SEF) standard, which allows you to define extensions to an EDI standard. See “Handling Proprietary EDI Formats” for more information.
The following table lists properties for the EDI XML Converter.
XML Converter Name in URI
EDI
See “Autofilling Segments and Elements” for a list of which segments and elements are autofilled
REPLACE – replaces invalid characters with the character specified by the invalid property. An underscore ("_") is used if the invalid property is not specified. If REPLACE is not specified, the converter throws an error.
See “Using Special Characters for Separators” for information about how to specify values for this property.
See “Using Special Characters for Separators” for information about how to specify values for this property.
no – code list table values are not output as XML:
<ISA15><!--I14: Interchange Usage Indicator-->P</ISA15>
comment – adds the description as a comment. For example, <!--Production Data--> in the following code:
<ISA15><!--I14: Interchange Usage Indicator-->P<!--Production Data--></ISA15>
attribute – adds the description as an attribute:
<ISA15 decode="Production Data"><!--I14: Interchange Usage Indicator-->P</ISA15>
text – adds the code as an attribute, and the description as an element value:
<ISA15 value="P">Production Data</ISA15>

NOTE: The value property must also be set to attribute to generate this output.
Turn off this and Comment element types (field ) to disable all comment generation.
See “XML Schema Generation” for more information about how this property affects XML Schema generation. See “HTML/XHTML Documentation Generation” for information about how this property affect HTML/XHTML documentation generation.
See “Using Special Characters for Separators” for information about how to specify values for this property.
quotes – if the field has quotes, it is treated as empty (null value). For example, ’""’ is recognized as a marker for an empty field; otherwise, it is treated as missing, that is, there is no value in the data stream (use for HL7 2.3 and later).
Turn off this and Comment code list (decode) to disable all comment generation.
See “Using Special Characters for Separators” for information about how to specify values for this property.
Allows you to specify which errors, if any, to ignore during XML conversion. The syntax for this field is ignore=n1,n2,n3.... For example, ignore=3,4,47 ignores errors 3, 4, and 47.
This property can be used with the opt property to allow processing to continue even when the data stream is missing mandatory segments and data elements.
This property is used only for schema generation. See “XML Schema Generation” for information on how this property affects XML Schema generation. See “HTML/XHTML Documentation Generation” for information about how this property affects HTML/XHTML documentation generation.
Used with the chr =REPLACE property to specify which character is used to replace invalid characters. This property affects EDI-to-XML conversion and vice versa.
See “Using Special Characters for Separators” for more information about how to specify values for this property.
Controls how the converter manages the L value (traditionally means "local system" in HL7) if it is passed as a date, time, datetime, or timestamp.
header – The L value is replaced with the value of the MSH-7 element from the header.
current – The L value is replaced with the date and/or time that the message processing started.
error – The L value is treated as a syntax error.
pass – The L value is passed through unchanged.
Allows you to prefix the name of a GROUP_no tag with the message name it appeared in. For example, <INVOIC>…<GROUP_1> becomes
< INVOIC >…< INVOIC _GROUP_1>
.
See “XML Schema Generation” for information about how this property affects XML Schema generation. See “HTML/XHTML Documentation Generation” for information about how this property affects HTML/XHTML documentation generation.
Used when converting EDI to XML, and XML to EDI when the Add linefeeds between segments on write property (eol) is set to yes. See “Line Separator Values” for a list of commonly used values.
See “Autofilling Segments and Elements” for a list of which segments and elements are autofilled
NOTE: You can use opt=no with the ignore property to ignore errors for missing mandatory segments (errors 39 and 9), missing mandatory data elements (error 4), or both. For example, opt=no and ignore=39,9 allows processing to continue even if the data stream is missing mandatory segments.
See “Using Special Characters for Separators” for information about how to specify values for this property.
See “Using Special Characters for Separators” for information about how to specify values for this property.
You can also use this property to add additional spaces or padding:
See “Using Special Characters for Separators” for information about how to specify values for this property.
See “Using Special Characters for Separators” for information about how to specify values for this property.
Determines whether an upper threshold is enforced on maxOccurs. For example, if unbounded=50, all occurrences of maxOccurs in an XML schema that have a value of 50 or higher are changed to unbounded.
text – outputs the coded data value (here, 00) in the text node:
<BGN01><!--353: Transaction Set Purpose Code-->00</BGN01>
attribute – outputs the coded data value as an attribute:
<BGN01 value="00"><!--353: Transaction Set Purpose Code--></BGN01>
See “XML Schema Generation” for more information about how this property affects XML Schema generation. See “HTML/XHTML Documentation Generation” for more information about how this property affects HTML/XHTML documentation generation.
NOTE: If you specify xr=999, make sure that the version of X12 being used supports the 999 response message, which was introduced in version 005010. This property is HIPAA-aware; therefore, for version 0050x0, it writes the 005010X231 version of 999, and for 0060x0, it writes the 006010X290 version.
FINNISH Character Set Overrides
You can use the Character repertoire override property (see “chr”) to change the meaning of certain characters for the Finnish character set for UNOA (UNOY) and UNOB (UNOZ). The following table shows which characters are changed based on the character set in use.
Explicit Character Overrides
In addition to the modifiers you can specify using the Character repertoire override property (see “chr”), you can instruct the DataDirect XML Converters to take character encodings from the URI, instead of from the EDIFACT-style UNB or UIB 001 element. If you choose to do this, you can use the encodings described in the following table:
These can also be combined with other chr= options. For example, an EDI file might specify an UNOA encoding, but with lower-case text, because the sending system sent inconsistent data. Using chr=UNOB+REPLACE, the data could be consumed, and any non-UNOB characters would turn into '_' characters, allowing processing to continue.
The DataDirect XML Converters do not perform character checking for UNOX; rather it depends on the native platform converter or the application to ensure that the characters are valid. This is because there are too many implementation-specific details, subsets, and proprietary and local extensions, and it is not possible to account for them all.
Using Special Characters for Separators
Most special characters or symbols cannot be entered directly into a URL. For example, you cannot specify that the colon (:) is the element separator character by entering converter:EDI:element=::auto=both. Instead, you must escape special characters using the appropriate decimal or hexadecimal value. To specify a colon as an element separator character, you would use converter:EDI:element=\u3A:auto=both.
NOTE: The special characters that are supported vary depending on the specified EDI dialect.
See Table 5-12, “Common Separator Characters” for a complete list of separator characters and their decimal and hexadecimal values.
Which Properties Specify Separators?
The following properties can be used to specify separators for the EDI XML Converter:
Restrictions for Separator Characters
The following restrictions apply for using separator characters.
Commonly Used Separator Characters
Commonly used separator characters and their escape values (in decimal and hexadecimal) are shown in the following table.
Control Characters
You can also use the non-printable control characters shown in the following table as separators.
Table 5-13. Control Characters
EDI Processing Instructions
You can specify EDI processing instruction (PI) values in the EDI XML Converter URI as described in the following table.
Leave these values blank to assume the default values. DataDirect XML Converters generates an error if a PI and URI switch have conflicting values, or if either value conflicts with one of the values encoded in a segment for these values.
The syntax of an EDI processing instruction is <?, followed by processing instruction name (edi_segment, for example), followed by a space, and then the new special character.
Example
Suppose an X12 document had to be written so that the segment terminator was a carriage return, the element separator was an asterisk, and the component separator was the greater-than symbol. The start of the file might look like this:
<?xml version="1.0" encoding="utf-8"?>
<?edi_segment \r?>
<?edi_element *?>
<X12>
   <ISA>
      <ISA01><!--I01: Authorization Information Qualifier-->00</ISA01>
      <ISA02><!--I02: Authorization Information--></ISA02>
      <ISA03><!--I03: Security Information Qualifier-->00</ISA03>
      <ISA04><!--I04: Security Information--></ISA04>
      <ISA05><!--I05: Interchange ID Qualifier-->01</ISA05>
      <ISA06><!--I06: Interchange Sender ID-->1515151515</ISA06>
      <ISA07><!--I05: Interchange ID Qualifier-->01</ISA07>
      <ISA08><!--I07: Interchange Receiver ID-->5151515151</ISA08>
      <ISA09><!--I08: Interchange Date-->041201<!--2004-12-01--></ISA09>
      <ISA10><!--I09: Interchange Time-->1217</ISA10>
      <ISA11><!--I65: Repetition Separator-->U</ISA11>
      <ISA12><!--I11: Interchange Control Version-->00403</ISA12>
      <ISA13><!--I12: Interchange Control Number-->000032123</ISA13>
      <ISA14><!--I13: Acknowledgment Requested-->0</ISA14>
      <ISA15><!--I14: Usage Indicator-->P</ISA15>
      <ISA16><!--I15: Component Element Separator-->></ISA16>
   </ISA>
...
Stopping a Conversion If the Input Does Not Match What is Expected
You may want to terminate the input if the input contains an incorrect message. If the auto-detection feature incorrectly identifies the message type from the incoming data, you can use the message= URI property to force the incoming message to act in a different way.
To quickly terminate the input, a "detector" program can be used. The following program reads a sufficient amount of data from an EDI file. It determines if the file matches the given specifications, and if the file does not, the conversion is quickly terminated.
Example
The program uses the XML Converters library and the listener interface. It works because the XML Converters are designed to stream data. When the converters see input, they immediately write the output. The program reads data and looks for the dialect, version, and message properties, and terminates the conversion as soon as these properties are seen. The system then discards the output obtained from the conversion process.
import java.io.IOException;
import java.io.Writer;
 
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
 
import com.ddtek.xmlconverter.Converter;
import com.ddtek.xmlconverter.ConverterFactory;
import com.ddtek.xmlconverter.adapter.edi.EDIConverterListener;
import com.ddtek.xmlconverter.adapter.edi.EDISegmentDetails;
import com.ddtek.xmlconverter.exception.ConverterException;
 
/**
* This program will accept one or more EDI files as arguments.
* First, it processes them until it sees the first StartMessage event,
* writing the results to null output.
* Next, it throws a benign exception to stop processing and
* checks the dialect, version, and message against what is expected.
* If they match, it restarts processing and transforms the message into an
* XML file with the same base name as the input file.
* If they do not match, it stops processing as if an error were encountered.
*/
public class Stopper {
 
// public static final String DIALECT = "X12";
// public static final String VERSION = "004030";
// public static final String MESSAGE = "831";
   public static final String DIALECT = "HL7";
   public static final String VERSION = "2.1";
   public static final String MESSAGE = "ORU";
 
   public static void main(String[] args) {
      for (String arg : args)
           new Stopper(arg);
   }
 
   public Stopper(String arg) {
      ConverterFactory factory = new ConverterFactory();
      Converter toXml;
         try {
            toXml = factory.newConvertToXML("converter:EDI:tbl=no:opt=yes");
         } catch (ConverterException ce) {
            ce.printStackTrace();
            return;
         }
         EDIConverterListener listener = new MessageListener();
 
         String out = null;
            // yields "xml" if the input has no '.'
         try {
            out = arg.substring(0, arg.indexOf('.') 1) "xml";
 
            Source converterSource;
            Result converterResult;
 
            // the first pass is to check for conformity
            try {
               toXml.getConfiguration().setConverterListener(listener);
               converterSource = new StreamSource(arg);
               converterResult = new StreamResult(new NullWriter());
               toXml.convert(converterSource, converterResult);
               throw new StopException(null);
            // make sure we handle case where EDI contains no message
            } catch (StopException exception) {
               if ( !isSame(DIALECT, exception.dialect)
                      || !isSame(VERSION, exception.version)
                      || !isSame(MESSAGE, exception.message)) {
                      System.out.println("[Stopper] error! " arg " is not a
                      " DIALECT " " VERSION " " MESSAGE);
                      return;
               }
            }
 
            // yes, it's okay to re-use the converter
            toXml.getConfiguration().setConverterListener(null);
            converterSource = new StreamSource(arg);
            converterResult = new StreamResult(out);
            toXml.convert(converterSource, converterResult);
 
            System.out.println("[Stopper] completed: " arg " -> " out);
         } catch (ConverterException exception) {
            System.out.println("[Stopper] failed: " arg " -> " out);
            System.out.println("[Stopper] failed with exception:
            " exception);
         }
 
   }
 
   private boolean isSame(String one, String two) {
      if (one == two)
         return true; // catches both same, or both null
         if (one == null || two == null)
            return false; // catches either null
         return one.replaceAll("[-. ]", "").
         equals(two.replaceAll("[-. ]", ""));
   }
 
   public static class StopException extends ConverterException {
      public String dialect;
      public String version;
      public String message;
      public StopException(EDISegmentDetails details) {
         super("");
         dialect = details == null ? null : details.getDialect();
         version = details == null ? null : details.getMessageVersion();
         message = details == null ? null : details.getTransactionSet();
      }
         private static final long serialVersionUID = -98684742021305872L;
   }
 
   public static class NullWriter extends Writer {
      public void write(char[] cbuf, int off, int len) throws IOException { }
         public void flush() throws IOException { }
         public void close() throws IOException { }
   }
 
   public static class MessageListener implements EDIConverterListener {
      public void error(ConverterException exception) throws ConverterException {
   throw exception; // take this out to make recoverable errors recover
      }
   public void fatalError(ConverterException exception) throws ConverterException {
      // no matter what we do here, an exception is thrown by the caller
      }
      public void warning(ConverterException exception) throws ConverterException {
      System.out.println("[Stopper] warning: " exception.toString());
      }
 
      public void startInterchange(EDISegmentDetails details) throws Exception { }
      public void startGroup(EDISegmentDetails details) throws Exception { }
      public void startMessage(EDISegmentDetails details) throws Exception {
         throw new StopException(details); // we've seen enough, now exit
      }
      public void processSegment(EDISegmentDetails details) throws Exception { }
      public void endMessage(EDISegmentDetails details) throws Exception { }
      public void endGroup(EDISegmentDetails details) throws Exception { }
      public void endInterchange(EDISegmentDetails details) throws Exception { }
      public int invalidCharacter(char chr, String coding) {
      return -1; // let it throw!
      }
         public String unknownCodelistValue(String segment, int pos, int sub, int tri, int rep, String element, String item) {
         return null; // let it throw!
         }
   }
}
Autofilling Segments and Elements
By default, the values of segments and elements are autofilled during the conversion from XML to an EDI format or vice versa. You can change the default behavior by setting the following XML EDI Converter URI properties:
To disable autofilling, use auto=never. When autofilling is enabled, the values of elements that are autofilled depend on the specified dialect as described in Table 5-15.
auto=both:noautofill=UNB*,UNZ*