Understanding Separator Characters

EDI files consist of tokens separated by special characters. Separators typically include the following:

  • Segment terminators
  • Element separators
  • Component separators
  • An optional secondary component separator
  • A release (or, escape) character
  • A decimal symbol
  • A repeat symbol

Values for some of these separators are set explicitly in the EDI data stream. For example, in X12, the component separator is the value of the ISA16 field - the "I15: Component Element Separator." In EDIFACT, separator values can be set using the contents of the UNA segment.

How Stylus Studio Sets Separator Characters

When writing XML to EDI, Stylus Studio overwrites separator values using a set of processing instructions (PIs). As long as the character has not been emitted to the output stream, it can be changed. For example, the segment terminator can be changed using the PI only before the first segment is written.

Note

 

In X12, since the I15 element contains the component separator, it cannot be set by a PI as one value would conflict with the other.

Invalid Separator Characters

You cannot use any of the following characters as EDI separators:

  • Spaces
  • Alphabetical characters
  • Numeric characters

Setting Processing Instruction

Stylus Studio uses the following naming convention and default values for XML processing instructions used to set values for separator characters:

Name
Default Value
edi_segment
'
edi_release
?
edi_element
+
edi_component
:
edi_repeat
~
edi_decimal
,
Note that the decimal character is read from the underlying platform default. If no default is set, the EDIFACT standard specifies a comma.
edi_tertiary
&
Table 23. Processing Instructions for Separator Characters

If a PI is used to set the value for one separator (say, A) to a default value being used by another separator (B), a new value will be chosen for the B separator unless one has already been specified.

Syntax

The syntax of the PI is just "<?" followed by the name, followed by a space, and then the new special character before a closing "?>" tag. Consider a few examples:

<?edi_segment \n?>
               
<?edi_release \\?>
               
<?edi_element $?>
               
<?edi_component \x0001?>
               
<?edi_decimal .?>
               

            

Here is another example, showing PIs used in context. In this example, an X12 document needed to be written to meet the following requirements: the segment terminator needed to be a carriage return; the element separator needed to be an asterisk; and the component separator needed to be a greater-than symbol. The two PIs and the Component Element Separator are shown in bold for clarity:

<?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>
               
...
               

            

If the segment terminator (edi_segment) is set to \r or \n, consider disabling the default value (specified in the URI) of adding end-of-line characters to each segment. Otherwise, the EDI output will have double endings. To do this, change eol=yes to eol=no in the URI. For more information, see Adapter Properties.

Ways to Specify Control Characters

In addition to literal characters, you can also specify control characters using a backslash syntax, as shown here.

Control Character
Backslash Syntax
Hex Value
Backspace
\b
0x08
Formfeed
\f
0x0C
Linefeed
\n
0x0A
Carriage return
\r
0x0D
Tab
\t
0x09
Specify character in octal
\[0-7]
n/a
Specify character in decimal
\#[0-9]
n/a
Specify character in hexadecimal
\x[0-9A-F]
n/a
Table 24. Backslash Syntax for Control Characters

 
Free Stylus Studio XML Training:
W3C Member