Using BTXML Script with Integration Builder

You can use BTXML script with Integration Builder to automate your printing processes.

ClosedUsing Integration Variables

The following example shows a BTXML script that uses variables to work with a file integration. In this example, the Document1.btw document is placed in the same folder that contains the integration file, and the trigger file is used as the file source of the text database in Document1.btw.

<?xml version="1.0" encoding="utf-8"?>

<XMLScript Version="2.0">

<Command Name="Job1">

<Print>

<Format>%IntegrationFileFolder%Document1.btw</Format>

<RecordSetType="btTextFile">

<FileName>%FilePath%</FileName>

</RecordSet>

</Print>

</Command>

</XMLScript>

ClosedUsing XSL Transforms

In Integration Builder, the "Transform XML using XSLT" action uses an Extensible Stylesheet Language (XSL) stylesheet to transform another application's output XML from its original XML format into another XML format. The following example shows how an XSL transform is used to convert XML to BTXML.

Suppose that your XML resembles the following.

<MyPrintJob Name="Job1">

<FileToPrint>Document1.btw</FileToPrint>

<Data>

<Record>

<FirstName>Angela</FirstName>

<LastName>Davis</LastName>

<City>Bellevue</City>

<ZipCode>98008</ZipCode>

</Record>

<Record>

<FirstName>John</FirstName>

<LastName>Lewis</LastName>

<City>Kirkland</City>

<ZipCode>98298</ZipCode>

</Record>

</Data>

</MyPrintJob>

You can use the following XSL to transform this code to BTXML.

<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheetversion="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:outputcdata-section-elements="TextData"/>

<xsl:templatematch="/">

<XMLScriptVersion="2.0">

<Command Name="{MyPrintJob/@name}">

<Print>

<Format><xsl:value-of select="//FileToPrint"</Format>

<RecordSet Type="btTextFile">

<TextData>

<xsl:for-eachselect="//Record[1]/child::*">

<xsl:iftest="position() != last()">"<xsl:value-ofselect="normalize-space(name())"/>",</xsl:if>

<xsl:iftest="position() = last()">"<xsl:value-ofselect="normalize-space(name())"/>"<xsl:text>&#xD;</xsl:text></xsl:if>

</xsl:for-each>

<xsl:for-eachselect="//Data/Record">

<xsl:for-eachselect="./child::*">

<xsl:iftest="position() != last()">"<xsl:value-ofselect="normalize-space(.)"/>",</xsl:if>

<xsl:iftest="position() = last()">"<xsl:value-ofselect="normalize-space(.)"/>"<xsl:text>&#xD;</xsl:text></xsl:if>

</xsl:for-each>

</xsl:for-each>

</TextData>

</RecordSet>

</Print>

</Command>

</XMLScript>

</xsl:template>

</xsl:stylesheet>

The resulting BTXML resembles the following.

<XMLScript Version="2.0">

<Command Name="Job1">

<Print>

<Format>Document1.btw</Format>

<RecordSet Type="btTextFile">

<TextData>

<![CDATA["FirstName","LastName","City","ZipCode"

"Angela","Davis","Bellevue","98008"

"John","Lewis","Kirkland","98298"]]>

</TextData>

</RecordSet>

</Print>

</Command>

</XMLScript>

Related Topics