An XML XSLT Feed will parse XML data and bring in a tabular dataset. The feed will be designated as an XML XSLT feed in the data pipeline, as seen in the following screenshot.
Configuring XML XSLT Feed
Step 1: Create a Connection
Perform the following steps to connect to a data directory on the local server:
- Click .
The Connections page is displayed. - Click + in the lower-left corner to create a new connection.
A pop-up for choosing a connection type is displayed. - In the pop-up, select File / Server Filesystem connection type.
- Click Use Selected.
A new page is displayed. - In Connection Name, enter a name for the connection.
- Make sure the Enable Connection toggle is on.
- In Server Path, provide a relative path from the installation folder of edgeCore.
- Click Next.
You are taken to the Test Connection tab where the confirmation message Connection test was successful is displayed. - Click Save and Close.
The newly created connection is displayed in the list of Connections.
Step 2: Create an XML XSLT Feed
Now that you have established a connection to a directory of files, you can create a Feed from a specific XML file and transform its data via XSLT.
Perform the following steps to create a Feed:
- Click .
The connection you created is displayed in the Pipeline. - Click the gear icon button in the connection box and select + .
A pop-up for choosing a Feed Type is displayed. - In the pop-up, select XML XSLT.
A new page is displayed. - On the Base Configuration tab, do the following:
a) In Feed Name, enter a name for the feed.
b) (Optional) Provide a description.
c) In File Name, select the .xml file. In order for the .xml file to appear in this dropdown, it needs to be located in the data folder of the edgeCore build.
d) Enable or disable the Preserve Data Types toggle switch. If enabled, data types defined in the data source will be preserved. If disabled, all values will be interpreted as strings.
e) (Optional) Enable the Advanced Update Scheduling toggle switch if you want to define an advanced schedule for updates.
f) In Poll Interval, specify how often you can access the data for a feed and also how often the data changes (in seconds). If a server subscription is active (another user is using that node or a server job is making it active), the current data retrieved will be returned. It will not refresh until all server-side subscriptions are closed and a new one is open. If you set the poll interval to 0, that means the data is very static, and you do not expect it to change.
g) (Optional) Turn on the Enable Server Subscription toggle switch in order for data for this feed to be continually fetched, updated, and cached based on the Poll Interval. If enabled, the server will subscribe to the feed, just as a client widget would. This means that the data and any resources that would otherwise be allocated “on-demand” for the first user to view a Visualization that leverages the data produced by this feed are allocated when the server is started and maintained as long as this feed is configured.
h) (Optional) Enable the Persist toggle switch to use persistent table store.
i) (Optional) Enable the Publish Dataset via REST API toggle switch to allow other edgeCore servers or third-party software to connect to this server’s pipeline.
j) Click Next. You are taken to the XML XSLT Parser tab. - The XML XSLT Parser tab consists of the following:
a) Raw Data: shows what the Raw XML data looks like inside the source XML file. Use this tab as a reference when writing the XSLT code.
Example:<?xml version="1.0" encoding="UTF-8"?> <menu> <meal mealno="1"> <entree>Cheese</entree> <drink>Lemonade</drink> <side1>Fries</side1> <side2>Broccoli</side2> <price>5.00</price> </meal> <meal mealno="2"> <entree>Falafel</entree> <drink>Beer</drink> <side1>Mashed Potatoes</side1> <side2>Green Beans</side2> <price>6.50</price> </meal> <meal mealno="3"> <entree>Salad</entree> <drink>Water</drink> <side1>Fruit</side1> <side2>Tofu</side2> <price>4.50</price> </meal> </menu>
b) XSLT: contains a code editor in which to place the XSLT code. See below for specific details regarding how to format the XSLT code.
Example:<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0"> <xsl:output method="xml" indent="yes" encoding="UTF-8"/> <xsl:template match="menu"> <result xmlns="https://docs.edgeti.com/xml-data"> <entity name="menu"> <attributes> <attribute primaryKey="true">Meal Number</attribute> <attribute>Entree</attribute> <attribute>Drink</attribute> <attribute>Side 1</attribute> <attribute>Side 2</attribute> <attribute type="number">Price</attribute> </attributes> <xsl:for-each select="meal"> <xsl:element name="record"> <value name="Meal Number"> <xsl:value-of select="@mealno"/> </value> <xsl:apply-templates select="."/> </xsl:element> </xsl:for-each> </entity> </result> </xsl:template> <xsl:template match="entree"> <value name="Entree"> <xsl:value-of select="."/> </value> </xsl:template> <xsl:template match="drink"> <value name="Drink"> <xsl:value-of select="."/> </value> </xsl:template> <xsl:template match="side1"> <value name="Side 1"> <xsl:value-of select="."/> </value> </xsl:template> <xsl:template match="side2"> <value name="Side 2"> <xsl:value-of select="."/> </value> </xsl:template> <xsl:template match="price"> <value name="Price"> <xsl:value-of select="."/> </value> </xsl:template> </xsl:stylesheet>
c) XSLT Results: shows the resulting XML data after parsing it with the supplied XSLT code. To update, click the Apply XSLT Changes button on the XSLT tab, then toggle back and forth between Raw Data and Results to validate your XSLT code.
Example:<?xml version="1.0" encoding="UTF-8"?><result xmlns="https://docs.edgeti.com/xml-data"> <entity name="menu"> <attributes> <attribute primaryKey="true">Meal Number</attribute> <attribute>Entree</attribute> <attribute>Drink</attribute> <attribute>Side 1</attribute> <attribute>Side 2</attribute> <attribute type="number">Price</attribute> </attributes> <record> <value name="Meal Number">1</value> <value xmlns="http://www.w3.org/1999/xhtml" name="Entree">Cheese</value> <value xmlns="http://www.w3.org/1999/xhtml" name="Drink">Lemonade</value> <value xmlns="http://www.w3.org/1999/xhtml" name="Side 1">Fries</value> <value xmlns="http://www.w3.org/1999/xhtml" name="Side 2">Broccoli</value> <value xmlns="http://www.w3.org/1999/xhtml" name="Price">5.00</value> </record> <record> <value name="Meal Number">2</value> <value xmlns="http://www.w3.org/1999/xhtml" name="Entree">Falafel</value> <value xmlns="http://www.w3.org/1999/xhtml" name="Drink">Beer</value> <value xmlns="http://www.w3.org/1999/xhtml" name="Side 1">Mashed Potatoes</value> <value xmlns="http://www.w3.org/1999/xhtml" name="Side 2">Green Beans</value> <value xmlns="http://www.w3.org/1999/xhtml" name="Price">6.50</value> </record> <record> <value name="Meal Number">3</value> <value xmlns="http://www.w3.org/1999/xhtml" name="Entree">Salad</value> <value xmlns="http://www.w3.org/1999/xhtml" name="Drink">Water</value> <value xmlns="http://www.w3.org/1999/xhtml" name="Side 1">Fruit</value> <value xmlns="http://www.w3.org/1999/xhtml" name="Side 2">Tofu</value> <value xmlns="http://www.w3.org/1999/xhtml" name="Price">4.50</value> </record> </entity> </result>
d) Indexing: enhances the performance of some queries; To enable indexing, select the check box next to the name of the attribute. Each selected attribute will have an index created for that specific attribute.
e) Download Raw: enables you to save a copy of the raw data as an XML file. The file will be downloaded directly to the local machine, similar to any other file that one would download from the browser.
f) Click Next. You are taken to Tabular Data Preview where you can observe the data preview of your XML XSLT Feed. - Click Save and Close.
The newly created feed is displayed in the Pipeline.
XSLT Code
Although the specific details of the XSLT code are left up to the user, the XSLT code should generally adhere to the following pattern:
<?xml version="1.0" encoding="UTF-8"?> <!-- The xsl tag can, of course, include other namespace references --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0"> <xsl:output method="xml" indent="yes" encoding="UTF-8"/> <xsl:template match="SampleData"> <result xmlns="http://www.sample.com/sample-namespace"> <entity name="SampleEntity"> <attributes> <!-- Attributes can vary according to the user's data --> <!-- Supported types include STRING, INT, LONG, NUMBER, BOOLEAN, DATE --> <attribute type="string" primaryKey="true">ID</attribute> <attribute type="boolean">IsOnline</attribute> <attribute type="number">JobsCompleted</attribute> <attribute type="number">JobsFailed</attribute> <attribute type="number">TotalJobsRun</attribute> <!-- "date" types can be either formatted strings or epoch time in seconds or milliseconds --> <attribute type="date" format="yyyy.MM.dd HH:mm:ss">LastUpdated</attribute> <attribute type="date" units="seconds">LastUpdatedSeconds</attribute> <attribute type="date" units="millis">LastUpdatedMilliseconds</attribute> </attributes> <xsl:for-each select="TargetXMLElement"> <!-- the server will expect "record" elements -- DO NOT CHANGE --> <xsl:element name="record"> <value name="ID"><xsl:value-of select="@id"/></value> <xsl:apply-templates select="."/> </xsl:element> </xsl:for-each> </entity> </result> </xsl:template> <xsl:template match="IsOnline|JobsCompleted|JobsFailed|TotalJobsRun|LastUpdated|LastUpdatedSeconds|LastUpdatedMilliseconds"> <value name="{name()}"><xsl:value-of select="."/></value> </xsl:template> </xsl:stylesheet>
If the above XSLT pattern is followed, the server should parse the raw XML and return results that can be converted to tabular data. When processing the XSLT results, the server expects that, at a minimum, the XML has a top-level <result> element that contains an <entity>. If multiple <result> elements exist, the first one with an <entity> will be used. Similarly, multiple entities are not currently supported, so the first <entity> within a <result> will be used. Within an <entity> element, there will be <attributes> and <record> elements. Generally, the output should look like this:
<?xml version="1.0" encoding="UTF-8"?> <result xmlns="http://www.sample.com/sample-namespace"> <entity name="SampleEntity"> <attributes> <attribute type="string" primaryKey="true">ID</attribute> <attribute type="boolean">IsOnline</attribute> <attribute type="number">JobsCompleted</attribute> <attribute type="number">JobsFailed</attribute> <attribute type="number">TotalJobsRun</attribute> <attribute type="date" format="yyyy.MM.dd HH:mm:ss">LastUpdated</attribute> <attribute type="date" units="seconds">LastUpdatedSeconds</attribute> <attribute type="date" units="millis">LastUpdatedMilliseconds</attribute> </attributes> <record> <value name="ID">Node_0</value> <value name="IsOnline">true</value> <value name="JobsCompleted">10</value> <value name="JobsFailed">2</value> <value name="TotalJobsRun">12</value> <value xmlns="http://www.w3.org/1999/xhtml" name="LastUpdated">2017.04.30 02:10:02</value> <value xmlns="http://www.w3.org/1999/xhtml" name="LastUpdatedSeconds">1493532602</value> <value xmlns="http://www.w3.org/1999/xhtml" name="LastUpdatedMilliseconds">1493532602000</value> </record> <record> <value name="ID">Node_1</value> <value name="IsOnline">false</value> <value name="JobsCompleted">12</value> <value name="JobsFailed">4</value> <value name="TotalJobsRun">16</value> <value xmlns="http://www.w3.org/1999/xhtml" name="LastUpdated">2017.04.30 02:10:02</value> <value xmlns="http://www.w3.org/1999/xhtml" name="LastUpdatedSeconds">1493532602</value> <value xmlns="http://www.w3.org/1999/xhtml" name="LastUpdatedMilliseconds">1493532602000</value> </record> <!-- record elements continue for as long as there is data to create the elements --> </entity> </result>
Note about date format strings:
Java 8 seems oddly particular with regard to the characters used in the date format strings (e.g. yyyy vs YYYY, and dd vs DD). If the dates do not look exactly right in the tabular data preview, be sure to check the date format that is being specified in the user-provided XSLT code.
Uploading XML Files through the User Interface
edgeCore version: 4.3.7
To upload XML files to feeds without having to access the server, click + next to File Name.
Make sure the file extension matches the feed type (in this case, the extension needs to be .xml).
Once you upload the XML file, you can select it from the File Name dropdown.