XML XSLT

An XML XSLT Feed will parse XML data, and bring in a tabular dataset.  The feed with be designated as an “XML XSLT” feed in the data pipeline (example below).

Step 1:  Base Configuration #

Property Name
Description
Poll Interval (seconds)
This value determines how often the server will refresh the data via the connection.
Enable Server Subscription If set, 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.

Step 2:  XML XSLT Parser #

The XML XSLT Parser step contains one panel with three tabs and the option to download the raw XML:

Option
Description
Raw Data Tab This tab shows what the Raw XML data looks like inside the source XML file. Use this tab as a reference when writing the XSLT code.
XSLT Tab This tab contains a code editor in which to place the XSLT code. See below for specific details regarding how to format the XSLT code.
XSLT Results This tab shows the resulting XML data after parsing it with the supplied XSLT code. To update, press the “Test” button in the XSLT panel, then toggle back and forth between “Raw’ and “Results” to validate your XSLT code.
Download Raw This button allows the administrator 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.

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"?>
  <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.