Creating an XML integration
Overview
BarTender 2019 introduces new types of text databases including XML databases. With Designer able to read these types of databases natively, you can now use them as trigger files as well without the need of an XLST transform.
This tutorial will walk you through the following:
- Using an XML file as a database
- Setting up an XML file integration
- Testing and deploying your integration
Provided for you is sample data used in the tutorial. Once you're familiar with it, feel free to follow the same steps with your own data and labels to create an XML integration to suit your needs.
Applicable to
BarTender 2019 and later
Information
Creating an XML database
Here is a sample XML database for a fictional pet food company, Seagull Pet Snacks. The database contains a simple header section <HEADER> with a body of data contained in <DETAILS>.
<?xml version="1.0"?>
<LABEL>
<HEADER>
<BRAND>Seagull Pet Snacks</BRAND>
<PACKAGE>Bag</PACKAGE>
<LOCATION>Seattle</LOCATION>
<DETAILS>
<NAME>Kitty Kibble</NAME>
<TAGLINE>Delicious snacks for kitty</TAGLINE>
<FLAVOR>Salmon</FLAVOR>
</DETAILS>
</HEADER>
</LABEL>
To create an XML database
- Open a text editor such as Notepad.
- Paste the above text into your editor.
- Go to File > Save As and change the save type to All Files.
- Set the name as Database.xml, for example, and click Save.
Creating the label file
- Open BarTender Designer and create a new document.
- When you complete the new document wizard, go to File > Database Connection Setup.
- Select Create a new database connection and click Next.
- Select XML File from the list and click Next.
- Use the Browse button to locate the file, database.xml. Select it and click Next.
- For this tutorial, select the first option to Automatically detect schema from XML file and click Next.
- The next screen will allow you to tell BarTender where the data is actually stored in your XML file.
From our database in the section above, we have a header labeled <HEADER> and a section that details each record or label marked as <DETAILS>. As we only want to use the information in the DETAILS section as our database, select it from the list in the top pane as shown in the screenshot below:
Notice how the file preview changes depending on what tag you select. The bottom pane will show you what your data looks like in a table format. If the preview appears as tags, click the Fields tab on the right side to change to a table format. - With the DETAILS tag selected in the top pane click Next.
- This next screen will allow you to uncheck fields if you want to ignore them. For this example, we'll leave all 3 fields checked. Click Finish on the Wizard then OK on the dialog.
- Now that the database is connected, click on the Data Sources tab in your toolbox if it is not already selected.
- Click and drag all three fields onto your label.
Tip: if the TAGLINE is too wide for your label, you can turn on wrapping in the text properties box under the wrapping section. - Save your label. It is now ready for use!
Creating the Integration
- Open Integration Builder.
- From the start screen, select Create New Integration.
- Select File from the dialog and click OK.
- Under File Detection, choose your scan folder location. This is where the Integration will be picking up files.
Note: It is recommended that you choose a folder in a common location such as the C drive. Folders in My Documents or the desktop may require special permissions to access them. - Change the file pattern to *.xml, since we'll be scanning for xml files.
- Click on the Print Document action.
- On the Document tab, use the Browse button to navigate to the document you created in the previous section. Like with the scan folder, it's recommended this document be located in a centralized folder and not in My Documents.
- Configure the Database Override option.
BarTender 2019: On the Print Options tab, under Database Overrides, check the box next to Use data source and leave the dropdown option as Integration Input Data.
BarTender 2021: On the Print Options tab, under Database Overrides, click the blue plus button to add a database override option. Set the Data Source to Variable and the Variable field to "%EventData%".
- Save your file.
Testing and deploying the Integration
Before we deploy the integration, we'll want to test it and create some sample trigger files. The trigger files must match the same structure as the database linked to the label file. Here's some sample data for testing. This has different data than was in the label's database but the structure is the same:
<?xml version="1.0"?>
<LABEL>
<HEADER>
<BRAND>Seagull Pet Snacks</BRAND>
<PACKAGE>Box</PACKAGE>
<LOCATION>Seattle</LOCATION>
<DETAILS>
<NAME>Dog Crunchies</NAME>
<TAGLINE>Crunchy snacks for your best friend!</TAGLINE>
<FLAVOR>Duck</FLAVOR>
</DETAILS>
</HEADER>
</LABEL>
- Create a sample trigger file using the data above. Ensure that the file extension is .XML, as that's what the integration is expecting.
- With the integration open, click on the Test tab.
- Click the green Start button on the top ribbon.
- Drop the file into the scan folder you set in the previous section.
- Integration messages will start appearing, confirming that the integration has picked up the file.
- Once you have a successful print, it's time to deploy.
- Click the Deploy tab then the green Deploy button.
- If you have not saved your file, you will be prompted to do so.
- Click the dropdown menu and select This Computer from the list. Click Next.
- Select Deploy now then click Finish.
- Your integration is now deployed.
Additional Resources
Print Document Using Print Command Script (Video - 9:40)
Building a file integration using Print Command Script (27:58)