Home > Cloud Cruiser 3 > Batch XML Reference > Universal collectors > XML > XmlFeedConfig

XmlFeedConfig

Table of contents
No headers

XmlFeedConfig is a data mapping configuration bean to support data collection from XML sources.

Elements from the XML document can be mapped to CC-Record fields as output at any level in the document. Initial input is the document node or root element. A set of child elements can be mapped to output by providing an XPath expression for the nodes of interest. Each matching node is then processed according to output mappings specific to the expression results. By default, identifiers accumulate in the record, but resources do not.

Recursive Processing

The parent output record is cloned and resources dropped before processing each child node. The recursive nature of the document is supported by the XPathOutputMapping , which is also recursive and supports nesting expressions and mappings. In this way, identifiers can be accumulated for the context of a node containing usage data for one or more resources.

Variables

Input can be mapped to a mutable variable instead of an output field. These variables may then be specified in place of a literal input field where necessary. To specify a variable as input, set the input name to '#' followed by the variable name.

Mapping Output

Outputs correspond to a CC-Record field and typically name an element as the input. Input names can employ a dot notation to pull nested element data. This is convenient in many cases, but limited to the first match and not intended to satisfy recursive processing needs. For example, " company.name " as an input would pull the value of a ' name ' element contained in a ' customer ' child element of the current node.

When using expressions to match nodes, the inputs are relative to the matching nodes. This presents a special case where the value of the matching node is needed as input and there is no attribute or child element name to provide as input. In these cases, specify " / " as the input. This will pull the current nodes value. To specify an attribute value as input, prefix the attribute name with ' @ ' as the input. For example, " company.@name " as an input would pull the value of an attribute called 'name' from a child element called ' company '.

Data Sample

In the following example, the customer data can be mapped into identifiers that are included on all output records for the document. The service node and children can be mapped recursively such that the vmName identifier appears in all records having service resources.

<subscription>
  <customer>
    <name>ABC Corp</name>
  </customer>
  <service>
    <vmName>9283479</vmName>
    <compute>
      <osType>Windows 2008 R2</osType>
      <ramGB>4</ramGB>
      <cpuCount>2</cpuCount>
    </compute>
    <disks>
      <disk>
        <name>Disk-1</name>
        <sizeGB>400</sizeGB>
      </disk>
      <disk>
        <name>Disk-2</name>
        <sizeGB>2000</sizeGB>
      </disk>
    </disks>
  </service>
</subscription>

Output Sample:

The following CSV represents typical output from mapping the above data sample as prescribed:

,,,,3,customer,ABC Corp,vmName,9283479,osType,Windows 2008 R2,2,ramGB,4,cpuCount,2
 ,,,,3,customer,ABC Corp,vmName,9283479,diskName,Disk-1,1,diskGB,400
 ,,,,3,customer,ABC Corp,vmName,9283479,diskName,Disk-2,1,diskGB,2000

XmlFeedConfig Properties

<property name="variables">

Sets a list of element to variable mappings. The output variables may then be specified as input for subsequent output mappings. To specify a variable as input, set the input to ' # ' followed by the variable name. For example, setting an input of #serviceId would populate the output from an output variable named ' serviceId '.

<property name="xpathOutputs">

Sets a list of child node mappings for recursive processing.

Spring Batch Example

<bean id="feedConfig" class="com.cloudcruiser.batch.collect.XmlFeedConfig">
  <property name="outputs">
    <list>
      <bean class="com.cloudcruiser.batch.collect.OutputField">
        <property name="cctype" value="IDENTIFIER" />
        <property name="input" value="customer.name" />
        <property name="label" value="customer" />
    </bean>
    </list>
  </property>
  <property name="xpathOutputs">
    <list>
      <bean class="com.cloudcruiser.batch.collect.XPathOutputMapping">
        <property name="xpathExpression" value="service[compute]" />
        <property name="outputs">
          <list>
            <bean class="com.cloudcruiser.batch.collect.OutputField">
              <property name="cctype" value="IDENTIFIER" />
               <property name="input" value="vmName" />
            </bean>
          </list>
        </property>
        <property name="xpathOutputs">
          <list>
            <bean class="com.cloudcruiser.batch.collect.XPathOutputMapping">
              <property name="xpathExpression" value="compute" />
              <property name="outputs">
                <list>
                  <bean class="com.cloudcruiser.batch.collect.OutputField">
                    <property name="cctype" value="IDENTIFIER" />
                    <property name="input" value="osType" />
                  </bean>
                  <bean class="com.cloudcruiser.batch.collect.OutputField">
                    <property name="cctype" value="RESOURCE" />
                    <property name="input" value="ramGB" />
                  </bean>
                  <bean class="com.cloudcruiser.batch.collect.OutputField">
                    <property name="cctype" value="RESOURCE" />
                    <property name="input" value="cpuCount" />
                  </bean>
                </list>
              </property>
            </bean>
            <bean class="com.cloudcruiser.batch.collect.XPathOutputMapping">
              <property name="xpathExpression" value="disks/disk" />
              <property name="outputs">
                <list>
                  <bean class="com.cloudcruiser.batch.collect.OutputField">
                    <property name="cctype" value="IDENTIFIER" />
                    <property name="input" value="name" />
                    <property name="label" value="diskName" />
                  </bean>
                  <bean class="com.cloudcruiser.batch.collect.OutputField">
                    <property name="cctype" value="RESOURCE" />
                    <property name="input" value="sizeGB" />
                    <property name="label" value="diskGB" />
                  </bean>
                </list>
              </property>
            </bean>
          </list>
        </property>
      </bean>
    </list>
  </property>
</bean>
Last modified

Tags

This page has no custom tags.

Classifications

This page has no classifications.
© Copyright 2018 Hewlett Packard Enterprise Development LP