Sterling OMS Writing First XSL Program

By | 07/16/2017

Sterling OMS Writing First XSL Program

Sterling OMS Writing First XSL Program

Can someone write code in OMS without java knowledge? Answer is yes. Using XSL program we should be perform most of the activities similar to Java.

What is XSL?

XSL is a language for expressing style sheets. An XSL style sheet is, like with CSS.

XSLT is a Programming Language and used for processing XML data. That is, transforming XML documents.

  • A small set of flexible data types: Boolean, number, string.
  • A full set of operations: <xsl:template>, <xsl:apply-templates>, <xsl:sort>,<xsl:output>.
  • Programming flow-control: <xsl:if>, <xsl:for-each>, <xsl:choose>, and so on

How XSL will be used in OMS (Simple Example)?

Consider below simple scenario

  • Customer wants to get organization details using given input XML (Can be in any format)
  • Input XML coming into Service looks as shown below
<?xml version="1.0"?>
<Enterprise EnterpriseCode="Matrix" />

Requirement and Flow XSL

We can create below XSL file and convert input XML to required input XML for getOrganizationHierarchy API.

  • Create XSL file
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <xsl:variable name="OrganizationCode" select="/Enterprise/@EnterpriseCode"/>          
    <Organization OrganizationCode="{$OrganizationCode}" />    
  </xsl:template>
</xsl:stylesheet>
  • Final Result XML to call getOrganizationHierarchy API
<Organization OrganizationCode="Matrix" />

How to build custom code?

  • Create mapenterprise.xsl file as under <OMS_Install_Dir>/global/template/xsl/mapenterprise.xsl
  • Run Command : deployer.cmd -t resourcejar
  • Run Command : buildear.cmd -Dappserver=weblogic -Dwarfiles=smcfs,sbc -Dearfile=smcfs.ear -Dnowebservice=true -Ddevmode=true -Dnodocear=true -Dwls-10=true create-ear
  • Run Command: del C:\deploy\smcfs.ear (Deleting old ear file)
  • copy <Install Directory>\external_deployments\smcfs.ear C:\deploy
  • Manually deploy the ear file in weblogic server

How to test?

  • Create new service with name XSLTTest and Service group name Custom

XSLTestService

  • Add XSL Translator as shown below and enter the file location

XSL Translator

  • Add API after the XSL translator and connect all the points

XSL Final Service

Example given here very simple. You can construct any complex XML input using XSL.

Run the test?

Input

XSL API Tester

Result

Result

What is best with XSL?

  1. We can do programming with help of browser and no IDE (Integrated Development Environment) needed
  2. If we know the input XML (coming into service/api) and final XML to call any API/Service, we can apply the XSL easily
  3. In online there are many websites available to do test the changes
  4. We can use below URL to test the changes made https://www.freeformatter.com/xsl-transformer.html
  5. For example

FreeFormater_XSL

Try yourself?

Can you write java program instead of XSL and generate same XML output?

Register with us to get more OMS updates

OMS Interview Questions

7 thoughts on “Sterling OMS Writing First XSL Program

  1. Aman

    Thnaks for This example . I want some example like creating local agent and integration server.

    Reply
  2. Vishal

    Thanks ActiveKite. Can you post examples on when it is best to use XSL and when it’s best to use java code from performance point of view.

    Reply
    1. admin

      Sure. we can do. But in high level

      XSL is good when you have very small transformation. Lets say if Order with 100+ lines and if you want to do some logic on order lines, XSL will be slow. If we do the same logic in Java will be much faster. So XSL is good only when you do very small xml manipulation.

      Hope helps… Happy learning !!!

      Reply
  3. Prakash Singh

    Thanks for this valuable information ….we appreciate your valuable time and effort.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *