Thursday, February 17, 2011

Identity template in XSLT

Identity template in XSLT

Identity template is used to copy everything from the source to the destination. It demonstrates the charm of the recursion ability of XSLT. The below is the basic form of the identity template. 

Figure 1. Identity template
How does it work?

1. Firstly by using match=”@* node()” the template will be used for each attribute and each node which include element node, text node, comment and processing-instruction. But the namespace node is not included here.

2. Then for each matched node (attribute, element, text node or whatever) do the copy.

3. Finally inside apply the template recursively to child elements if the node has any. This will show the charm of XSLT’s recursive ability which makes the XSLT template very clean and powerful.

However that is just the basic form of the identity template. In the reality there seems no chance to make the exact copy from the source to destination. Quite often some modifications are required while doing the copy. For example a portion of XML needs to be copied but at the same time the value of one particular element is needed to be assigned a new value or a new attribute is needed to add to this particular element.

These variations to the basic form of XSLT identity template can be achieved via another template which works together with identity template. This template will handle the copy of one particular element or attribute. The key point is that this template has the specific match than the identity template and when one element or attribute matches this template, XSLT engine will choose this template to process the element or attribute instead of identity template although the element or attribute also matches the identity template. Why? Because the identity template is less specific.


This example is quite simple and it just copies everything from the source to the target except the value of one element. 

Figure 2. Source

Figure 3. Transformation

Figure 4. Result

This example is a bit complicated than example 1.  What we need to do is to convert one root element from one name to another name and at the same time change the namespace XYZ to ABC.  All subelements keep the same name.     
 Figure 5. Source

 Figure 6. Transformation

 Figure 7. Result

Wednesday, February 9, 2011

Add one user header to JMS message in JMSBC

In this example one JMS header proerty: ACTION is needed to add the message sent out via JMSBC. This can be done through the assign activity in BPEL. Note normalize-space is used to avoid the warning when the BPEL is built.

Synchronously send and consume the JMS message in BPEL

Sychronous JMS provider

When sending out a JMS message sychronously from BPEL - which means that you send out JMS message to a destination and BPEL process will not procede until it get the JMS message
from ReplyTo destination.

Figure 1

Steps to create sychronous JMS provider

  • Define the WSDL with the type "Send and Wait for Reply" which will generate the 2-way WSDL as shown in Figure 1.
  • So before the message is send out several Header properties are to be set. The figure 2 shows one example of configuring the JMS BC for setting up these properties.

Figure 2

Sychronous JMS consumer

When consuming a JMS message sychronously in BPEL, the BPEL instance wil pick up a message from the destination and start to process the message until it sends out a reply message to the destination specified as ReplyTo header property in the coming message. THEN the BPEL instance starts to pick up the next message in the destination.

Steps to create sychronous JMS consumer

  • Define the WSDL with the type "Receive and Reply" which will generate the 2-way WSDL as shown in Figure 1.
  • Set the ReplyTo header property of the message to be consumed by the BPEL.

Thursday, February 3, 2011

Find out the default Http port used in HttpComponent in JCAPS

In order to find the default HTTP port number used in HttpComponent in JCAPS
Go to the folder in the domain:
Open the file:

Loo up the item: HttpDefaultPort=19380

19380 is the default port number of HTTP component in JCAPS.

Wednesday, February 2, 2011

Creat a JAXB class library in NetBeans IDE

It's convenient to have a seperate JAXB class libray project when using JAXB in processing XML in Java application.

The below are the some simple steps to demonstrate how to create such a project in NetBeans IDE.

1. Create the project of Java class library
  • Start a new project by selecting New Project... from File menu
  • Choose project type as: Java Class Library
  • Give the name of the project and then click on Finish button

2. Create the JAXB binding
  • Right click on the new created project and choose New
  • Choose the file category as: XML and File Types as: JAXB Binding
  • Give the name of JAXB Binding
  • Select the schema file

3. Build the project



Deleting directory D:\WIS\commbiz-jaxb-lib\build






Created dir: D:\WIS\commbiz-jaxb-lib\build\generated\addons\jaxb

Created dir: D:\WIS\commbiz-jaxb-lib\build\generated\jaxbCache

Created dir: D:\WIS\commbiz-jaxb-lib\build\classes

Created dir: D:\WIS\commbiz-jaxb-lib\build\generated\jaxbCache\Commbiz

Compiling file:/D:/WIS/commbiz-jaxb-lib/xml-resources/jaxb/Commbiz/combiz_alterting_service.xsd

Writing output to D:\WIS\commbiz-jaxb-lib\build\generated\jaxbCache\Commbiz

Copying 54 files to D:\WIS\commbiz-jaxb-lib\build\generated\addons\jaxb

Compiling 54 source files to D:\WIS\commbiz-jaxb-lib\build\classes


Created dir: D:\WIS\commbiz-jaxb-lib\dist

Building jar: D:\WIS\commbiz-jaxb-lib\dist\commbiz-jaxb-lib.jar


BUILD SUCCESSFUL (total time: 2 seconds)

All generated JAXB classes based on the given schema file are in the .jar file.