This article will cover how to connect to an XML data source. For more information, see the article on the new Connection Editor here.
What you will need to establish this connection
- An XML Data Source (file or URL)
- A good network connection to your file or URL. (Please note, if you are inside a corporate network and you cannot access the cloud-hosted demo data source, your firewall may be blocking you from access. Please consult with your systems or network administrator for assistance.)
High level outline of the process
- Open MS-Word/Excel/PowerPoint (For this example, we will be using MS-Word)
- Go to the AutoTag Manager tab on the ribbon
- Click on the Data Sources icon (the Connection Editor Pops up)
- Fill in the appropriate information in the Datasource Connector dialog box and click OK
- Your Data Source is now connected to your template
Connecting Your Template to an XML Data Source
You do not need to install any connector to access XML files, this code is all included in AutoTag.
From MS Word, Excel or PowerPoint, navigate to the AutoTag Manager tab. Once on the AutoTag Manager tab, click on the upper half of the Data Sources button. This will open the data source Connection Editor.
Note that if you click on the bottom half, you will get a dropdown menu which lists data sources that are already connected; this may be blank.
Enter your organization's information as shown in the image and text below.
1. In the Connection Editor window, in the New tab, click on XML under Web data sources. The Details pane will change to prompt you for your data source details.
2. Enter a Nickname for your data source connection. It is best practice to always assign a nickname to your data source in the Name field. This will make your life much easier down the road when working with templates or tracking down any issues.
3. Enter the file (including directory) or URL to retrieve the XML file.
4. (Optional) Choose your authentication type and fill in your credentials. For additional information, see our article on Authentication Protocols.
Protocol -- You can set this to one of three protocols used to read the XML file:
- REST - This will pass credentials using the BASIC credentials on the first request and set the ContentType to XML. Many REST sources will work with Standard but some require this special setting. (This is needed when a REST source returns HTML instead of an error for missing credentials and returns HTML instead of XML if the ContentType is not set.)
5. (Optional) Schema -- A schema provides the structure of your XML file. This provides significant additional information of use to AutoTag: All possible nodes (the XML file just gives us the nodes used), the data type of each node, and a description for each node (which we then display as a tooltip in the data source schema tree). You can set this to:
- No schema - You have no schema file.
- Use xsi:schemaLocation - The XML file lists the schema using an xsi node. Sometimes (not always) the schema file is on the web at that location. With this setting it will read the file from that location. Again, many times there is no file at the specified location and the URL is just a name.
- File / URL - Provide a local copy of the schema file.
6. Click Connect, and then Test your connection. If all parameters and credentials are correct and a connection is made, you will receive a successful notification. Clicking Close will save your information.
Note: Root Directory -- This is used to specify a base directory that is used for imported files that have a relative path. This must be set in AutoTag and also in the code when creating the data source provider before applying it in the engine.
When you set all the properties for XML you will get a connection string in the form
If you define the schema, it will have a 2nd connection string for the schema. As shown below, the null 2nd parameter is the connection string for the schema.
|.NET Code||Java Code|
|new SaxonDataSourceImpl (“Url=C:\test\SouthWind.xml;AccessProvider=FileSystem;”, null );||new SaxonDataSource (“Url=C:\test\SouthWind.xml;AccessProvider=FileSystem;”, null );|