Within Oracle Service Bus 11g, there is not an easy way to reference Domain Value Maps (DVM), like there is in Oracle SOA Suite 11g Composites. Typically, a kluge solution is implemented as a workaround in a Service Bus 11g project. With Oracle Service Bus 12c, this has changed, DVMs are now accessible in XQuery and XSL maps.
While this is good news, the even better news is that XSL maps which contain references to DVMs can now be successfully executed at design time, allowing for testing within JDeveloper. Testing of XSL maps at design time is always a good practice, it allows for catching bugs early in the development process.
Within this article, I will provide an overview of the configurations required to enable testing an XSL map at design time, which references a DVM within an Oracle Service Bus 12c project.
Overview of creation of a DVM along with publishing to the MDS repository can be found here: http://technology.amis.nl/2014/06/27/soa-suite-12c-using-domain-value-map-dvm-in-service-bus-projects/
One prerequisite step necessary when referencing a DVM outside of the current Service Bus project is to import the resource from the Meta Data Storage (MDS). OSB 12c cannot contain references to resources, like a DVM, within the MDS repository. Rather, the resource needs to be imported into the Service Bus project, as shown below.
Select the DVM within the MDS repository and select ‘Import Resource’:
You will now see the DVM in the Service Bus project:
Now that the DVM is local to the project, the XSLT map can be created. Right click on the project and select ‘New’, then ‘XSL Map’:
Provide the map name along with the source and target schemas to be used. After the map is created, you will notice a couple of files created within the project folder ‘XSLNonDeployedFiles’:
The UnitTestURLs.dvm will be of use later on when for testing our map that contains a reference to the DVM.
For now, we will add the DVM lookup capability within our XSLT. The first step is to add the lookupValue function which is provided to query DVMs. In JDeveloper, right click on the middle pane of the XSL map just created and select as noted below:
In the bottom right pane in JDeveloper, click on the pencil icon in the XPath Properties tab. This will bring up the XPath Expression editor:
Within this editor, the DVM lookupValue function is specified. The signature of the function is:
dvm:lookupValue(dvm-location, src-column, src-value, target-column, default-value, qualifiers)
Note: when referencing a DVM in a Service Bus project, the fully qualified path (project name/folder/DVM name) must be used.
The squiggly underline beneath dvm:lookupValue denotes an error. The problem is that the namespace is not yet defined within the XSL map. Click ‘Ok’ in the XPath Editor window, then click on the middle pane of the map.
The ‘Enter Namespace’ window pops up allowing for entry of this missing namespace within the XSLT map:
This can also be entered in the source view of the map:
My mapping now looks like this, the DVM lookup function is shown in the middle pane with 5 inputs:
Now that the namespace is resolved, I can test the map. When I do, I get the following error:
Note the DVM referenced in the error message: UnitTestURLs.dvm. This is the DVM generated when the XSL map was created. This is a ‘helper’ DVM which allows a mapping of the DVM location specified within the XSL map (e.g. SampleProject/DVM/StateTranslation) to the location of the DVM used for unit testing.
Within the Project Navigator in JDeveloper, open the UnitTestURLs.dvm:
Select the Plus icon and select ‘Add Domain Values’ as shown below:
This creates an entry in the DVM with default values which can be edited. To update these values select the pencil icon, then enter values into the Domain Values input:
Note: Don’t edit the domain values directly within the map table. The values will appear to be updated, but are not saved.
The serverURL value should be the fully qualified path (project name/folder/DVM name) DVM specified in the dvm:lookupValue function in the XSL map. The testURL is the fully qualified path to the MDS repository (either file based, like shown below, or database MDS):
Now that the ‘helper’ DVM is updated, testing of the XSL map can be done. Within JDeveloper, right click in the middle pane of the XSL map and select ‘Test XSLT Map’:
Once Ok is pressed in the inputs/output screen, with the results of the mapping displayed in the target file.