🖍️
Dataloy VMS API Documentation
(Old) Dataloy VMS API Documentation
(Old) Dataloy VMS API Documentation
  • Dataloy VMS API
  • Dataloy Rest API
    • What is it?
    • Authentication / Authorization
    • Getting Started
    • Data Model
    • Filtering
    • Sorting
    • Pagination
    • Adjust Number of Fields to be Returned from a Request
    • Webhooks
      • Webhook example
      • Expressions Made Easy
      • Webhooks - New functionalities
    • Master data Objects
    • Attachments
    • Audit Log
  • User Guides
    • Accounting Integration API
      • Invoicing
      • Payments/Receipts
      • Voyages
      • Business Partners
      • Exchange Rates
      • Bunker Transactions
      • Actuals
      • Autopost Invoices
      • Accruals
    • Schedule API
    • Bunker Order Integration API
    • Service Order Integration API
    • Vessel Report
      • Release 8.0
      • Release 7.3 - 7.12
      • Release 7.0 - 7.2
      • Release 6.29 - 6.46
      • Legacy version (6.26 - 6.28)
      • Vessel report master data
    • Bunker Consumption API
    • Left join in API queries
    • Enterprise functionalities
      • Versioning
      • Endpoint access control
      • Data access control via target object
      • Data access control via target object and security role
      • Data access control at object level
      • Fields access control
      • Alert Scripts
      • Websockets
      • Bulk Deletion
      • Copy objects
      • OR and AND operators in API queries
      • Sub queries
      • XML Transformation
      • Expressions
      • Bulk Update
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. User Guides
  2. Enterprise functionalities

XML Transformation

API 5.24 offers support for XML transformations for any of the resource of the data model.

Using XSLT 3.0 is possible inject XSL strings to any GET request to translate the default JSON response in a XML string based on the XSL in input.

To achieve this the URLs to use are

  • /ws/rest/{ResourceName}/xml

  • /ws/rest/{ResourceName}/xml/{key}

the XSL must be set as HTTP header parameter with the name xsl.

Example of Cargo transformation:

XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://www.w3.org/2005/xpath-functions">
   <xsl:output indent="yes" />
   <xsl:strip-space elements="*" />
   <xsl:param name="json" />
   <xsl:mode on-no-match="deep-skip" />
   <xsl:template name="init">
      <xsl:apply-templates select="json-to-xml($json)" />
   </xsl:template>
   <xsl:template match="/array">
      <Cargos>
         <xsl:apply-templates />
      </Cargos>
   </xsl:template>
   <xsl:template match="/array/map | /map">
      <Cargo>
         <xsl:apply-templates />
      </Cargo>
   </xsl:template>
   <xsl:template match="*[@key='voyage']">
      <IsTc>
         <xsl:value-of select="*[@key='isTc']" />
      </IsTc>
      <VesselCode>
         <xsl:value-of select="*[@key='vessel']/*[@key='vesselCodes'][1]/*/*[@key='vesselCode']" />
      </VesselCode>
      <VesselName>
         <xsl:value-of select="*[@key='vessel']/*[@key='vesselName']" />
      </VesselName>
   </xsl:template>
   <xsl:template match="*[@key='commodity']">
      <CommodityName>
         <xsl:value-of select="*[@key='commodityName']" />
      </CommodityName>
   </xsl:template>
   <xsl:template match="*[@key='cargoPorts']">
      <xsl:apply-templates select="*/*" />
   </xsl:template>
   <xsl:template match="*[@key='portCall']">
      <xsl:variable name="reasonForCall" select="*[@key='reasonForCall']/*[@key='reasonForCall']" />
      <xsl:variable name="name" select="*[@key='port']/*[@key='portName']" />
      <xsl:if test="$reasonForCall = 'L' ">
         <LoadPort>
            <xsl:value-of select="$name" />
         </LoadPort>
         <LoadPortArrival>
            <xsl:apply-templates select="*/*" />
         </LoadPortArrival>
      </xsl:if>
      <xsl:if test="$reasonForCall = 'D' ">
         <DischargePort>
            <xsl:value-of select="$name" />
         </DischargePort>
         <DischargePortArrival>
            <xsl:apply-templates select="*/*" />
         </DischargePortArrival>
      </xsl:if>
   </xsl:template>
   <xsl:template match="*[@key='eventLogs']/*">
      <xsl:variable name="code" select="*[@key='event']/*[@key='eventCode'][text() = 'ARR']" />
      <xsl:if test="$code">
         <xsl:value-of select="*[@key='eventLogDate']" />
      </xsl:if>
   </xsl:template>
</xsl:stylesheet>

Output:

<?xml version="1.0" encoding="UTF-8"?>
<Cargo>
    <CommodityName>FERTILIZER</CommodityName>
    <LoadPort>AMSTERDAM</LoadPort>
    <LoadPortArrival>2006-06-14T12:17:00</LoadPortArrival>
    <DischargePort>LIDKOPING</DischargePort>
    <DischargePortArrival>2006-06-17T19:53:00</DischargePortArrival>
    <IsTc>false</IsTc>
    <VesselCode>FETR</VesselCode>
    <VesselName>FEHN TRADER</VesselName>
</Cargo>
PreviousSub queriesNextExpressions

Last updated 1 year ago

Was this helpful?

URL:

http://platform-dev.dataloy.com/ws/rest/Cargo/xml/1225540