Creating an XML integration Follow
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've played with it, feel free to follow the same steps with your own data and labels to create an XML integration to suit your needs.
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>.
<BRAND>Seagull Pet Snacks</BRAND>
<TAGLINE>Delicious snacks for kitty</TAGLINE>
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 save your file
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
- 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.
- 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.
- On the Print Options tab, check the box next to "Use data source" and leave the dropdown option as "Integration Input Data"
- 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:
<BRAND>Seagull Pet Snacks</BRAND>
<TAGLINE>Crunchy snacks for your best friend!</TAGLINE>
- 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.