Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Section


Column

The XslHandler is a special /wiki/spaces/DOC3/pages/2033253 with any given form. It provides the ability to publish data collected by AssetTrack into text files with a custom format.  This can be handy when designing AssetTrack integration with other systems. For example, the XslHander can generate custom CSV or XML files that would be consumed by a customer script.

The customization of these output files is done by applying an XSL style sheet to an XML representation of the data. To understand how the XslHandler functions, consider the following flow of data from an AssetTrack form to the output file:


Column
width450px


Panel

On this page:

Table of Contents



...

  1. A section for defining a variable specifying the document delimiter you would like to use. *
    1. The setting of this variable is optional, but it is required to properly escape values if generating a delimited output file (see display_delim_field).
    2. It is important to note that the variable is utilized in a helper template that encapsulates values with the delimiter present in quotes. 
  2. An optional section for specifying what headers will be included. *
    1. Omitting this section or making it empty will generate a file without any output headers
  3. A section specifying the data to output for each record of asset / purchase order data.

* Optional . - Relevant if the style sheet drives generation of a tab- or comma-delimited file

...

  • Location, down to 3 levels in the hierarchy
  • PO number (this value is in no way related to the Procurement module's Purchase Order Number)
  • Model of the asset
  • Serial number of an asset
  • Comment (Form-level Named field)

...

Many elements are available in both Asset and Procurement contexts.  The first two columns below show the context-specific path you should use for each element within the XML data.
Asset form data element pathProcurement form data element pathAttributes
/TaskData/CollectionContext/TaskData/CollectionContext
  • Application
  • DeviceId
  • TaskName
  • TaskId
  • TransactionId
  • UserId
  • DateCollected
  • DateCollected_UtcCultureFull
  • DateCollected_UtcCultureDate
  • DateCollected_UtcCultureTime
  • DateCollected_TimeZoneAsUtc
  • DateCollected_TimeZoneCultureFull
  • DateCollected_TimeZoneCultureDate
  • DateCollected_TimeZoneCultureTime
N/A. (the purchase order element)
  • ExternalId
  • Number
  • Status
N/A./PurchaseOrderLineItem
  • ExternalId
  • LineItemNumber
  • QuantityOrdered
  • QuantityReceived
  • Description
  • Consumable
  • ManagedAsset
  • Collected *

* Value represents either the number of consumables or assets collected against a line item for a given form's collection session

N/A./PurchaseOrderLineItem/Sku
  • ExternalId
  • ManufacturerSku
  • PcnDescription
  • Description

. (the asset element)

./PurchaseOrderLineItem/Asset
  • EntityOperation
  • ExternalId
  • AssetTag
  • SerialNumber
  • MacAddress
  • CustomKey1
  • CustomKey2
  • PONumber
  • Status
  • ServiceStatus
  • Description
  • AssetName
  • HostName
  • Cost
  • CAFloorLocation
  • CARoomLocation
  • CACabinetLocation
  • CAShelfLocation
  • CASlotLocation
  • LeaseEndDate
  • LeaseEndDate_UtcCultureFull
  • LeaseEndDate_UtcCultureDate
  • LeaseEndDate_UtcCultureTime
  • LeaseEndDate_TimeZoneAsUtc
  • LeaseEndDate_TimeZoneCultureFull
  • LeaseEndDate_TimeZoneCultureDate
  • LeaseEndDate_TimeZoneCultureTime
  • WarrantyEndDate
  • WarrantyEndDate_UtcCultureFull
  • WarrantyEndDate_UtcCultureDate
  • WarrantyEndDate_UtcCultureTime
  • WarrantyEndDate_TimeZoneAsUtc
  • WarrantyEndDate_TimeZoneCultureFull
  • WarrantyEndDate_TimeZoneCultureDate
  • WarrantyEndDate_TimeZoneCultureTime
./Assignee./PurchaseOrderLineItem/Asset/Assignee
  • ExternalId
  • FirstName
  • LastName
  • FullName
  • Tag
  • Code
./Location 1./PurchaseOrderLineItem/Asset/Location 1
  • ExternalId
  • Name
  • Code
./Organization 1./PurchaseOrderLineItem/Asset/Organization 1
  • ExternalId
  • Name
  • Code
  • Tag
./Product./PurchaseOrderLineItem/Asset/Product
  • ExternalId
  • Name
  • Number
  • PartControlNumber
  • Description
./Product/Manufacturer./PurchaseOrderLineItem/Asset/Product/Manufacturer
  • ExternalId
  • Name
./Product/AssetType 1./PurchaseOrderLineItem/Asset/Product/AssetType 1
  • ExternalId
  • Name
  • Code
  • Tag
./Stockroom./PurchaseOrderLineItem/Asset/Stockroom
  • ExternalId
  • Name
  • Code
  • Tag
  • Type
./Vendor./PurchaseOrderLineItem/Asset/Vendor
  • ExternalId
  • Name
  • Code
  • Tag
./CostCenter./PurchaseOrderLineItem/Asset/CostCenter
  • ExternalId
  • Name
  • Code
  • Tag
./CustomEntity1./PurchaseOrderLineItem/Asset/CustomEntity1
  • ExternalId
  • Name
  • Code
  • Tag
./CustomEntity2./PurchaseOrderLineItem/Asset/CustomEntity2
  • ExternalId
  • Name
  • Code
  • Tag
./CustomEntity3./PurchaseOrderLineItem/Asset/CustomEntity3
  • ExternalId
  • Name
  • Code
  • Tag
./CustomEntity4./PurchaseOrderLineItem/Asset/CustomEntity4
  • ExternalId
  • Name
  • Code
  • Tag
./CustomFieldList/CustomField

../../CustomFieldList/CustomField (purchase order custom field)

../CustomFieldList/CustomField (purchase order line item custom field)

./CustomFieldList/CustomField (asset custom field)

  • Name
  • Alias
  • Value 2
./NamedFieldList/NamedField./NamedFieldList/NamedField (asset form field)
  • Name
  • Alias
  • Value 2 

Anchor
XslSelectorNotes
XslSelectorNotes
1 Element can be nested inside itself.  See hierarchicalElementAttributeByDepth for details on using a helper template to output hierarchical values.

...

  • field - The value that should be wrapped

...


Code Block
languagehtml/xml
linenumberstrue
<xsl:call-template name="display_delim_field"><!-- Application -->
	<xsl:with-param name="field" select="/TaskData/CollectionContext/@Application" />
</xsl:call-template>

...

  • contextElementNode
  • targetElementName
  • targetAttributeName
  • targetDepth [optional ... will look for the targetAttributeName at the lowest depth found]

...


Code Block
languagehtml/xml
linenumberstrue
<!-- Output the 2nd level Location Name -->
<xsl:call-template name="hierarchicalElementAttributeByDepth">
	<xsl:with-param name="contextElementNode" select="." />
	<xsl:with-param name="targetElementName">Location</xsl:with-param>
	<xsl:with-param name="targetAttributeName">Name</xsl:with-param>
	<xsl:with-param name="targetDepth">2</xsl:with-param>
</xsl:call-template>

...

Looks for the domain portion of the UserId in the TaskData/CollectionContext. If present, it removes it. 


Code Block
languagehtml/xml
linenumberstrue
<!-- Set a variable that contains the value from the Uber Dom -->
<xsl:variable name="userIdRaw" select ="/TaskData/CollectionContext/@UserId" />
		
<!--
Set another variable that is populated from:
	a: the value after the backslash if the uber dom value contains a backslash
		OR
	b: the value from the uber dom if the uber dom value DOES NOT contain a backslash
-->
<xsl:variable name="userId">
	<xsl:choose>
		<xsl:when test="contains( $userIdRaw, '\' )">
			<xsl:value-of select="substring-after($userIdRaw, '\')" />
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="$userIdRaw"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:variable>
		
<!-- Call display_delim_field, passing the $userId value set from the conditional statement above -->
<xsl:call-template name="display_delim_field">
	<xsl:with-param name="field" select="$userId" />
</xsl:call-template>
<xsl:value-of select="$delimiter"/>

...