Friday 1 February 2013

LookUp DVM in SoaSuite 10g, the 11g way

In SoaSuite 10g there is a xpath and xslt function do Domain Value Map lookups,lookupDVM. This function is based on tables in the SoaSuite repository. There is a screen in the ESB console to edit them.

In SoaSuite 11g there is a separate artefact for DVM's, and a corresponding lookupDVM function.
I found that one more convenient, since there is an editor in Jdeveloper for it and the artefact is in fact an xml file that can be put in the MDS and referenced from anywhere in your SOA projects. And lastly, it can be versioned as any other artefact.
Deployment is similar to other SOA-artefacts. For 10g you must ensure to synchronise the dvm's in the database between the different (OTAP) environments.

Today I needed a simple translation from 0,1 to Ja,Nee (Yes, No). I did not feel like to create a DVM in the database. But, also in 10g there is a quite similar solution as the 11g lookupDVM function

In SoaSuite 10g, there is an oracle xsl-extension function: lookupXML. It enables you to read in a xml file and perform a xpath-lookup query. I found it very convenient to lookup fixed (OTAP) environment-dependent parameters. If you would put those in bpel preferences you have to ensure that they're changed every deployment between the environments. Using the lookupXML function, you can lookup those values from an xml file from the filesystem of the SOASuite. Then you only have to put an version of the file in a fixed folder on every SOASuite environment. After adapting those for the particular environment, you don't need to touch it every deployment anymore.

This same construction can be used to do lookups. I created the following xml file:

<?xml version="1.0" encoding="windows-1252" ?>
<!-- $Id: email_texts.xml 99 2013-02-01 08:27:07Z ca_mavandenakker $ -->
<!-- This file can be located in a HTTP accessible directory in the midtier installation and it's referred 
     through an lookup-xml XPath expression in the service invocation.  -->
<!-- The current location is http://${deploy.soasuite.URL}/ObjectLibrary/Core/xml/v1/CoreLookupDVM.xml -->
      <domain name="JaNee">
      <domain name="JaNee">
Since the lookupXML is a xsl function, it is in 10g apparently not available as an Xpath function, I created an XSD for the convenience of doing the DVM-lookups:
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="" xmlns:version="1.0"
            xmlns:svnId="$Id$" xmlns=""
  <xsd:element name="DVM" type="dvm:DVMType">
      <xsd:documentation>Domain Value Mapping</xsd:documentation>
  <xsd:complexType name="DVMType">
      <xsd:element name="Domain" type="xsd:string"/>
      <xsd:element name="FromKey" type="xsd:string"/>
      <xsd:element name="FromValue" type="xsd:string"/>
      <xsd:element name="ToKey" type="xsd:string"/>
      <xsd:element name="ToValue" type="xsd:string"/>
Based on this XSD you can create a variable, fill in the Domain, eg. "JaNee", the FromKey, eg. "keyDb", the FromKeyValue, eg. "0", and the ToKey, eg. "dispValue" or "boolean". Then you can transform the variable to it's self using the following XSL:
<?xml version="1.0" encoding="UTF-8" ?>
    <source type="XSD">
      <schema location=""/>
      <rootElement name="DVM" namespace=""/>
    <target type="XSD">
      <schema location=""/>
      <rootElement name="DVM" namespace=""/>
  <!-- GENERATED BY ORACLE XSL MAPPER 090730.0200.1754) AT [FRI FEB 01 10:04:09 CET 2013]. -->
<xsl:stylesheet version="1.0"
                xmlns:xsd="" xmlns:version="1.0"
                exclude-result-prefixes="xsl xsd version ns0 svnId bpws ehdr hwf xp20 xref ora ids orcl">
  <xsl:variable name="configURI"
  <xsl:template match="/">
        <xsl:value-of select="/ns0:DVM/ns0:Domain"/>
        <xsl:value-of select="/ns0:DVM/ns0:FromKey"/>
        <xsl:value-of select="/ns0:DVM/ns0:FromValue"/>
        <xsl:value-of select="/ns0:DVM/ns0:ToKey"/>
        <xsl:call-template name="LookupDVM">
          <xsl:with-param name="domainName" select="/ns0:DVM/ns0:Domain"/>
          <xsl:with-param name="fromKey" select="/ns0:DVM/ns0:FromKey"/>
          <xsl:with-param name="fromKeyValue" select="/ns0:DVM/ns0:FromValue"/>
          <xsl:with-param name="toKey" select="/ns0:DVM/ns0:ToKey"/>
  <!--  User Defined Templates  -->
  <xsl:template name="LookupDVM">
    <xsl:param name="domainName"/>
    <xsl:param name="fromKey"/>
    <xsl:param name="fromKeyValue"/>
    <xsl:param name="toKey"/>
    <xsl:variable name="parentPath"
                  select="concat('/domains/domain[@name=&quot;',$domainName,'&quot;]' )"/>
    <xsl:variable name="result"
                  select="orcl:lookup-xml($configURI,$parentPath,$fromKey,$toKey ,$fromKeyValue)"/>
    <xsl:value-of select="$result"/>
This for those cases that you just want to lookup some values from the domain-xml this construction can be handy. In other cases where you need to lookup multiple values in an complexer xsl't you can copy and paste the construction above.

Since the CoreLookupDVM.xml is a, quite simple, xml file, it can easily be transformed to an 11g lookupDVM file.

No comments :