DECIPHER: Dynamic XSLTs in BPEL (SOA 12c)
Let's take the example of account creation. There is a source application sending account information in an XML document which we need to update in a backend database. Now source system can send different types of address information like home address, business address, or shipping address. We get this information in the addressType input field. In the backend database, for each type of address, there are different fields in the backend database. There could various ways to handle this.
1. Create one single XSLT to handle all the scenarios using XSLT functions like if, choose-when, etc. One single XSLT file for all the scenarios, BPEL code will be easy to read. But this will lead to a huge XSLT file and will be a bit tricky to maintain. In the future, if we want to add new conditions for only secondary addresses, then regression testing might be required to ensure we don't hamper the other functionality.
2. Another way could be to have separate XSLTs for each scenario. As per the example, we have 3 scenarios. The address can be of type home, business, or shipping address.
- ora:processXSLT
- ora:doXSLTransformForDoc
Both of the above functions support the location of the XSLT file and input XML. The above functions can be used in conjunction with DVM to fetch the location of XSLT and assign it to the input of the function.
For the same example, let's consider below DVM file as an example.
dvm:lookupValue("dvms/dynamicXSLT.dvm", "addressType",$addType, "xsltLocation", "transformations/default.xsl")
ora:processXSLT($dynamicXSLT, $input)
ora:doXSLTransformForDoc($dynamicXSLT, $input)
Both the above functions do a similar task. But there is one major difference. Suppose your XSLT requires extra complex parameters to be passed as input. In such scenarios ora:doXSLTransformForDoc comes real handy. In this function, we can pass key-value pairs of parameters that can be used within the XSLT.
For example, if our XSLT requires a parameter contact(as defined in XSLT) and the value is stored in the $Contact variable in the BPEL process. Now our function will look like.
ora:doXSLTransformForDoc($dynamicXSLT, $input, 'contact', $contact)References:
Please share your valuable feedback ๐๐๐
Comments
Post a Comment