Category: Template-Toolkit

How to unescape values in templates (i.e. for CDATA section in XML) by using the raw() function

Problem: HTML code should be placed inside a XML document, but the template converts (escapes) the data to XML. <?xml version=”1.0″ encoding=”UTF-8″?> <productRequest> <product> <subtitle>TEST &amp; Co</subtitle> <!– OK –> <productDescription><![CDATA[&lt;br&gt:Aus Aluminium in trendiger Farbgebung. &lt;br&gt;]]></productDescription> <!– Not OK –> </product> </productRequest> Solution: Use the template raw() function to prevent syntax escaping: <subtitle>[% Field1.0 %]</subtitle> […]

Creation of JTT templates with JTT template

Sometimes it is useful to create a template for the use at the ET-Connector with another template. An example is the creation of a fixed length format for the import in SQL-Business. An Excel table with the description of the format (field lengths, text right or left, default values …) is available. The table can […]

Java Template-Toolkit Syntax

Note: From ET-Connector version 8.0.11480 on, this documenation is deprecated and can be found at the local documentation in the install directory. This document is adapted from and snips off those parts, that are currently NOT implemented in Java Template-Toolkit (JTT). Tag Styles By default, template directives are embedded within the character sequences [% […]

How to use a variable to reflect/interpolate to another variable or index in Template-Toolkit

Sometimes it is useful to access variables by their name to reflect to fields dynamically (interpolation). Example for index: [% Document.0.Locations.2.Location.0 %] can be accessed dynamic by [% locationindex = 2 %][% Document.0.Locations.$locationindex.Location.0 %] Example for variable reflection: [% Document.0.Locations.2.Location.0 %] can be accessed dynamic by [% varname = “Locations” %][% Document.0.$varname.2.Location.0 %]

Create an EDIFACT message with a fixed line-length with Template-Toolkit

Problem: Some customers need EDIFACT messages with a line-length (row length) of an exact count (in example 80 characters per line + CRLF). Solution: The following Template Toolkit syntax allows it to create such a message: [%- output = BLOCK -%] UNA:+.? ‘ UNB+UNOA:3+… … UNZ+[% IdUNH %]+[% TID %][% IdAlternativo %]’ [%- IdAlternativo= IdAlternativo […]

Create an EDIFACT message without carriage return/line feed with JTT & Template-Toolkit

Problem: Some customers need an “inline edi message” which means no carriage returns shall occur within the message. Solution for TT: The following Template-Toolkit syntax allows to create such a message: [%- output = BLOCK -%] [%# Start of message %] UNA:+.? ‘ UNB+UNOA:3+… … UNZ+[% IdUNH %]+[% TID %][% IdAlternativo %]’ [%- IdAlternativo= IdAlternativo […]

Create binary data in Java Template-Toolkit (JTT)

Problem: A whitespace or unicode character has to be generated in a template. Solution: The following example shows a solution using the Java Template-Toolkit (JTT): Input: CTRL-7: \u0007 EXCLAMATION-MARK: \u0033 Output: CTRL-7: EXCLAMATION-MARK: ! Any unicode data can be inserted by typing “\u” followed by a four digit number (e.g. “\u 0065” -> “A”) Note: […]

Global variables

Global variables can be accessed within workflow items and templates. This article gives you an overview, how to insert global variables. 1) Configuration The following global variables can be used with “insert::” : APPLICATION_VERSION APPLICATION_NAME COMPANY_NAME DAY HOSTNAME HOUR ID (=TRANSACTIONID) MILLISECONDS MINUTE MODE MONTH TIMESTAMP TRANSACTIONID SECONDS SYSTEMID WEEKDAY (1=Monday, 2=Tuesday,…,7=Sunday) WORKFLOWNAME WORKFLOWNAMES (since […]

Arithmetic operations in Java Template-Toolkit (JTT)

Problem: What arithmetic operations are supported by Java Template-ToolKit? Solution: The supported operations are: ADD : [%- a = a + 1 -%] MINUS : [%- a = a – 1 -%] MULTIPLY: [%- a = a * 1 -%] DIVIDE : [%- a = a * 1 -%] MODULO : [%- a = a […]

Chunk text for XML or EDIFACT with Template-Toolkit

Problem: Chunking text data for XML or EDIFACT can cause syntax problems, as text maybe truncated at escape sequences. There are several EDIFACT fields that must be separated at a certain length, in example the address in a NAD segment Free text in FTX or IMD segment For example, something like “MY_ADDRESS_IS_LOCATED_IN_THIS_STREET_NOT_IN_THAT” must become MY_ADDRESS_IS_LOCATED_IN_THIS_STREE:T_NOT_IN_THAT […]

© 2017 SCHAEFER B.S. GmbH / Erich-Steinfurth-Str. 6 - 10243 Berlin / +49 (0)30 9700386 - 0 /