![]() |
Consumption Analytics Documentation |
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.
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.
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.
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
'.
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>
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
<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>
(c) Copyright 2017-2020 Hewlett Packard Enterprise Development LP