Thursday, July 3, 2014

ACTIVE MQ WITH SPRING 2.5



How to intergrate active MQ with Spring and JAVA MX

Step 01

In this post I will show how to send JMS message to ActiveMQ from your Spring web application. I used Spring 2.5  web application that runs on Tomcat 6 running on JDK 6.

Frist download the Active MQ 5.2  
https://repository.apache.org/content/repositories/snapshots/org/apache/activemq/apache-activemq/5.4-SNAPSHOT/

 Copy the following jars to your WEB-INF/lib directory

  • activemq-all-5.4-SNAPSHOT.jar
  • activemq-pool-5.4-SNAPSHOT.jar
  •  jms.jar
Create a destination queue using active MQ web application

 http://127.0.0.1:8161/admin/
click on Queue and type a name  on

 Step 02

Create a bean which are going to send to the queue

public class MessageBean implements Serializable {

private String msgString;


private String getMsgString() {
 return  msgString;
}

private void setMsgString(String msgString) {
 this.msgString=msgString;
}

}

Create a MessageProducer interface and Implementation


public interface MessageProducer {
     public void send(Object message);
}

public class MessageProducerImpl implements MessageProducer {

    private static final Logger logger  = LoggerFactory.getLogger(MessageProducerImpl.class);

   
    private JmsTemplate jmsTemplate = null;
   
    private Queue queue;
   
    private TestMessageCreater messageCreator;
   
    @Override
    public void send(Object message) {
          this.messageCreator.setMessageBean((MessageBean )message);
          this.jmsTemplate.send(this.queue, this.messageCreator);
    }
   

    public Queue getQueue() {
        return queue;
    }


    public JmsTemplate getJmsTemplate() {
        return jmsTemplate;
    }


    public void setJmsTemplate(JmsTemplate jmsTemplate) {
        this.jmsTemplate = jmsTemplate;
    }


    public void setQueue(Queue queue) {
        this.queue = queue;
    }


    public MessageCreator getMessageCreator() {
        return messageCreator;
    }

    public void setMessageCreator(TestMessageCreater messageCreator) {
        this.messageCreator = messageCreator;
    }   
}

Create TestMessageCreater by implementing org.springframework.jms.core.MessageCreator interface



import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Session;

import org.springframework.jms.core.MessageCreator;

public class TestMessageCreater implements MessageCreator {

       private MessageBean messageBean;
   
       public MapMessage createMessage(Session session) throws JMSException {           
            MapMessage objectMsg = session.createMapMessage();           
            objectMsg.setString("processName", messageBean.getMsgString());                     
            return objectMsg;
        }
       
        public MessageBean getMessageBean() {
            return messageBean;
        }

        public void settMessageBean(MessageBean messageBean) {
            this.messageBean= messageBean;
        }
       
}

 Wiring througth Spring web application

JmsMessageProducer-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
  
  
   
    <bean id="queue" class="org.apache.activemq.command.ActiveMQQueue">
        <constructor-arg>
            <value>test.queue/value>
        </constructor-arg>
    </bean>
   
   
    <!-- Spring JMS Template -->
    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory">
             <ref local="connectionFactory" />
         </property>
    </bean>
   
   
      <bean id="connectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory"  destroy-method="stop">
        <property name="connectionFactory">
            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                <property name="brokerURL">
                    <value>tcp://localhost:61616</value>
                </property>
            </bean>
        </property>
    </bean>
   
   
   
   
    <!-- a sample POJO message producer which uses a Spring JmsTemplate -->
    <bean id="messageProducer"     class="<your.packeage>MessageProducerImpl">
        <property name="jmsTemplate" ref="jmsTemplate"/>
        <property name="queue" ref="queue"/>
        <property name="messageCreator">
            <bean class="<your.packeage>.TestMessageCreator"/>
        </property>
    </bean>
   
    <bean name="messageService" class="<your.packeage>.MessageServiceImpl">
         <property name="messageProducer" ref="messageProducer" />
    </bean>
   
   
</beans>

Create a MessageService interace and MessageServiceImpl
this is used for to inject bean to your spring web action


 public interface MessageService {  
     public void sendMessage(MessageBean messageBean) ;      
}



public class MessageServiceImpl implements MessageService {

    private MessageProducer messageProducer;

    public void sendMessage(MessageBean messageBean) {
        messageProducer.send(messageBean);
    } 
   
   
     public MessageProducer getMessageProducer() {
        return messageProducer;
    }

    /**
     * @param messageProducer the messageProducer to set
     */
    public void setMessageProducer(MessageProducer messageProducer) {
        this.messageProducer = messageProducer;
    }

}


Inject messageService bean to your spring web action and try to send sample message


MessageBean messageBean = new MessageBean();
 messageBean.setMsgString("Hello Active MQ");
 messageService.sendMessage(messageBean);   

Wednesday, August 1, 2012

ZK - add onCheck event to ZK Checkbox component using JAVA

add onCheck event to ZK Checkbox  component using JAVA
private Grid           listGrid;

 Checkbox checkbox = new Checkbox();
        checkbox.setValue("value");
        //checkbox.addForward(Events.ON_CHECK, "onModifySelectedList", null);
        checkbox.addEventListener(Events.ON_CHECK, new EventListener()
        {
          public void onEvent( Event arg0 ) throws Exception
          {

            onModifySelectedList(arg0);
          }
        });

  public void onModifySelectedList( Event event )
  {
    Checkbox checkbox = (Checkbox)event.getTarget();
    if (checkbox.isChecked())
    {
      System.out.println("check box is checked");
    }
    else
    {
      System.out.println("check box is unchecked");
     }

     }

Tuesday, July 3, 2012

ZK - Override zk error box function by client side

Override zk error box on click fuction and prologHTML_ box customization in zk

If you need to customized client side constraint errorbox message behaviour using zk you can do it by overriding Errorbox.js file

1) This is my override js fuction
here i override prologHTML function and doClick_ function in Errorbox.js file

prologHTML is used to create message box user interface
doClick_ is used to change behavoioutr of message box

zk.afterLoad('zul.inp', function () {
  zk.override(zul.inp.Errorbox.prototype, {}, {
    prologHTML_ : function(a) {
      var b = this.uuid;
      a.push('<div id="', b);
      a.push('-a" class="z-errbox-left z-arrow" title="');
      a.push(zUtl.encodeXML(msgzk.GOTO_ERROR_FIELD));
      a.push('"><div id="', b,'-c" class="z-errbox-right z-errbox-close" title="Close"><div class="z-errbox-center">');
      a.push(zUtl.encodeXML(this.msg, {multiline : true}));
      a.push("</div></div></div>");                   
    },
    doClick_: function (evt) {
      var p = evt.domTarget;
      if (p == this.$n('c')) {
        if ((p = this.parent) && p.clearErrorMessage) {
          p.clearErrorMessage(true, true);
        } else
          zAu.wrongValue_(p, false);
        } else {
          this.$supers('doClick_', arguments);
          this.parent.focus(0);
        }
    }               
  });           
});       




Sunday, June 17, 2012

ZK with spring hibernate - Anotation based

HI All

1) Create dynamic web project using eclipse IDE ex:- zkspringhibernatetest

2) Jar file those we needed to compile and run zk+spring+hibernate project

























 

placed these jars to WEB-INF/lib directory

3) create web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>zkspringhibernatetest</display-name>
    <!-- spring -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>
   
    <!-- ZK -->
    <listener>
        <description>ZK listener for session cleanup</description>
        <listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
    </listener>
    <servlet>
        <description>ZK loader for ZUML pages</description>
        <servlet-name>zkLoader</servlet-name>
        <servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
        <init-param>
            <param-name>update-uri</param-name>
            <param-value>/zkau</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup><!-- Must -->
    </servlet>
    <servlet-mapping>
        <servlet-name>zkLoader</servlet-name>
        <url-pattern>*.zul</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>zkLoader</servlet-name>
        <url-pattern>*.zhtml</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>zkLoader</servlet-name>
        <url-pattern>/zk/*</url-pattern>
    </servlet-mapping>
    <servlet>
        <description>The asynchronous update engine for ZK</description>
        <servlet-name>auEngine</servlet-name>
        <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>auEngine</servlet-name>
        <url-pattern>/zkau/*</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>dspLoader</servlet-name>
        <servlet-class>org.zkoss.web.servlet.dsp.InterpreterServlet</servlet-class>
        <init-param>
            <param-name>class-resource</param-name>
            <param-value>true</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>dspLoader</servlet-name>
        <url-pattern>*.dsp</url-pattern>
    </servlet-mapping>

    <!-- Hibernate OpenSession Filter -->
    <filter>
        <filter-name>lazyLoadingFilter</filter-name>
        <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>lazyLoadingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
       
    <session-config>
        <session-timeout>60</session-timeout>
    </session-config>

    <welcome-file-list>
        <welcome-file>index.zul</welcome-file>
    </welcome-file-list>
</web-app>


4) create dao-config.xml (placed this file into the WEB-INF directory)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<!-- Hibernate session factory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

    <property name="dataSource">
      <ref bean="dataSource"/>
    </property>

    <property name="hibernateProperties">
       <props>
         <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
         <prop key="hibernate.show_sql">true</prop>
       </props>
    </property>

    <property name="annotatedClasses">
    <list>
        <value>com.zkspringhibernatetest.model.Order</value>
        <value>com.zkspringhibernatetest.model.User</value>
    </list>
    </property>

    </bean>
</beans>


5) create datasource.xml (placed this file into the WEB-INF directory)

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location">
        <value>WEB-INF/database.properties</value>
    </property>
</bean>

<bean id="dataSource"  class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${jdbc.driverClassName}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
</bean>
 
</beans>

6) create database.properties (placed this file into the WEB-INF directory)

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/springhibernatetest
jdbc.username=root
jdbc.password=

7) in here I used mysql database

create table scripts

CREATE TABLE  user (
  user_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  name VARCHAR(10) NOT NULL,
  email VARCHAR(200) NOT NULL,
  user_name VARCHAR(50) NOT NULL,
  password VARCHAR(50) NOT NULL,
  PRIMARY KEY (user_id) USING BTREE
);



CREATE TABLE  orders (
  order_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  order_code VARCHAR(10) NOT NULL,
  order_name VARCHAR(50) NOT NULL,
  order_desc VARCHAR(200) NOT NULL,
  PRIMARY KEY (order_id) USING BTREE
);


Insert  into user (name,email,user_name,password) VALUES ('saneera1', 'saneera@gmail.com','saneera1','test');
Insert  into user (name,email,user_name,password) VALUES ('saneera2', 'saneera@gmail.com','saneera2','test');
Insert  into user (name,email,user_name,password) VALUES ('saneera3', 'saneera@gmail.com','saneera3','test');
Insert  into user (name,email,user_name,password) VALUES ('saneera4', 'saneera@gmail.com','saneera4','test');


Insert  into orders (order_code,order_name,order_desc) VALUES ('AAA', 'Computer','Intel Core I3');
Insert  into orders (order_code,order_name,order_desc) VALUES ('BBB', 'Printer','HP');
Insert  into orders (order_code,order_name,order_desc) VALUES ('CCC', 'Monitor','Samsung LCD');
Insert  into orders (order_code,order_name,order_desc) VALUES ('DDD', 'Extention','Aptella');


8) zk.xml put this file into the WEB-INF directory

<?xml version="1.0" encoding="UTF-8"?>
<zk>   
    <system-config>
        <disable-event-thread/>
    </system-config>       
</zk>


9)Java pacake and class structure




10)  index.zul (which has login details ex: username and password and login button )

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<zk>
 <window id="loginWindow" title="Spring Hibernate Login" border="normal" width="600px" height="300px"
            apply="com.zkspringhibernatetest.web.LoginController" position="center,center" >
          <grid>
            <columns>
              <column label="" width="70px" align="right" />
              <column label="" align="left" />
            </columns>
            <rows>
              <row>
                <label value="Username:" />
                <textbox id="username" value="" maxlength="12" focus="true" width="100px" />
              </row>
              <row>
                <label value="Password:" />
                <cell>
                  <textbox id="password" value="" maxlength="12"  width="100px" />
                  <space width="10px" height="5px"/>
                </cell>
              </row>
              <row>
                <cell colspan="2" align="center" >
                 <button label="Login" id="login" />
                </cell>
              </row>             
            </rows>
          </grid>
        </window>
</zk>

11)

This is not finished yet if anyone has issues about this wiring please send me an email(saneera@gmail.com) ,becuase i have already done the code 

read and update xml/xsd file file from pl sql

 sample xsd file

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <xsd:simpleType name="NODE1">
    <xsd:restriction base="xsd:string">
      <xsd:minLength value="1"/>
      <xsd:maxLength value="50"/>
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:simpleType name="NODE2">
    <xsd:restriction base="xsd:string">
      <xsd:minLength value="1"/>
      <xsd:maxLength value="50"/>
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:simpleType name="NODE3">
    <xsd:restriction base="xsd:string">
      <xsd:minLength value="1"/>
      <xsd:maxLength value="8"/>
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:simpleType name="NODE4">
    <xsd:restriction base="xsd:string">
      <xsd:minLength value="1"/>
      <xsd:maxLength value="80"/>
    </xsd:restriction>
  </xsd:simpleType>
</xsd:schema>


follwing procedure change NODE1 -> maxlength value 50 to 100


create or replace procedure XMLTEST3 is

--Documents variables
doc                                                    DBMS_XMLDOM.DOMDocument;
docelem                                                DBMS_XMLDOM.DOMElement;

--sympleType Nodes
simpleTypeNodeList                                     DBMS_XMLDOM.DOMNodelist;
simpleTypeNode                                         DBMS_XMLDOM.DOMNode;
simpleTypeChildNodeList                                DBMS_XMLDOM.DOMNodelist;
simpleTypeChildNodeMap                                 DBMS_XMLDOM.DOMNamedNodeMap;
simpleTypeChildNodeAttr                                DBMS_XMLDOM.DOMAttr;
simpleTypeNodeListLength                               number;  
simpleTypeAttributeNode                                DBMS_XMLDOM.DOMNode;

--generalTypeCode Nodes
strGeneralTypeCode                                     VARCHAR2(200); 
simpleTypeChildNodeListLength                          number; 
generalTypeCodeAttributeNode                           DBMS_XMLDOM.DOMNode;
strIGeneralTypeCodeAttr                                VARCHAR2(200);
generalTypeCodeMap                                     DBMS_XMLDOM.DOMNamedNodeMap;
generalTypeCodeAttr                                    DBMS_XMLDOM.DOMAttr;
generalTypeCodeNode                                    DBMS_XMLDOM.DOMNode;

--generalTypeChild Nodes
generalTypeCodeChildNodeList                           DBMS_XMLDOM.DOMNodelist;
generalTypeCodeCNListLength                            number;
strGeneralTypeCodeCN                                   VARCHAR2(200);
generalTypeCodeCNMap                                   DBMS_XMLDOM.DOMNamedNodeMap;
generalTypeCodeCNAttr                                  DBMS_XMLDOM.DOMAttr;
generalTypeCodeChildNode                               DBMS_XMLDOM.DOMNode;

--Other Variables
xmlTypeValue                                           XMLType;
--used for write modified xmltype
xmlTypeTOClob                                          CLOB;

--used for write again modified clob to xmltype
clobToXmlType                                          sys.xmlType;

--rowid used to update modified record
row_id                                                 varchar(200);

--file name to check specisfic file
fileName                                               varchar(1000);



BEGIN

 xmlTypeValue := XMLType(
 '
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

 <xsd:simpleType name="NODE1">
    <xsd:restriction base="xsd:string">
      <xsd:minLength value="1"/>
      <xsd:maxLength value="50"/>
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:simpleType name="NODE2">
    <xsd:restriction base="xsd:string">
      <xsd:minLength value="1"/>
      <xsd:maxLength value="50"/>
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:simpleType name="NODE3">
    <xsd:restriction base="xsd:string">
      <xsd:minLength value="1"/>
      <xsd:maxLength value="8"/>
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:simpleType name="NODE4">
    <xsd:restriction base="xsd:string">
      <xsd:minLength value="1"/>
      <xsd:maxLength value="80"/>
    </xsd:restriction>
  </xsd:simpleType>
</xsd:schema>
');



   -- Create DOMDocument handle
  doc     := DBMS_XMLDOM.newDOMDocument(xmlTypeValue);
  DBMS_LOB.createtemporary (xmlTypeTOClob, TRUE);
  DBMS_XMLDOM.WRITETOCLOB(doc, xmlTypeTOClob);

  docelem := DBMS_XMLDOM.getDocumentElement(doc);

  -- get nodelist

  -- Access simpletype elements
  simpleTypeNodeList := DBMS_XMLDOM.getElementsByTagName(docelem, 'simpleType');
  simpleTypeNodeListLength  := dbms_xmldom.getLength(simpleTypeNodeList);
 
  -- loop through simple type elements
  FOR i IN 0 .. simpleTypeNodeListLength - 1 LOOP
        simpleTypeNode := DBMS_XMLDOM.item(simpleTypeNodeList, i);
         -- Get the attributes of this node
        simpleTypeChildNodeMap := DBMS_XMLDOM.GETATTRIBUTES(simpleTypeNode);
       
        -- Find the 'index' attribute
        simpleTypeAttributeNode := DBMS_XMLDOM.GETNAMEDITEM(simpleTypeChildNodeMap,'name');
        simpleTypeChildNodeAttr := DBMS_XMLDOM.MAKEATTR(simpleTypeAttributeNode);
        strGeneralTypeCode := DBMS_XMLDOM.GETVALUE(simpleTypeChildNodeAttr);
       
        IF strGeneralTypeCode = 'NODE2' THEN
       
         simpleTypeChildNodeList := DBMS_XMLDOM.GETCHILDNODES(simpleTypeNode);
         simpleTypeChildNodeListLength := dbms_xmldom.getLength(simpleTypeChildNodeList);
        
         FOR j IN 0 .. simpleTypeChildNodeListLength - 1 LOOP
            -- Get the attributes of this node
            generalTypeCodeNode := DBMS_XMLDOM.item(simpleTypeChildNodeList, j);
            generalTypeCodeMap := DBMS_XMLDOM.GETATTRIBUTES(generalTypeCodeNode);
            generalTypeCodeAttributeNode := DBMS_XMLDOM.GETNAMEDITEM(generalTypeCodeMap,'base');
            generalTypeCodeAttr := DBMS_XMLDOM.MAKEATTR(generalTypeCodeAttributeNode);
            strIGeneralTypeCodeAttr := DBMS_XMLDOM.GETVALUE(generalTypeCodeAttr);
                     
            --final loop
            generalTypeCodeChildNodeList := DBMS_XMLDOM.GETCHILDNODES(generalTypeCodeNode);
            generalTypeCodeCNListLength := dbms_xmldom.getLength(generalTypeCodeChildNodeList);
            
             FOR k IN 0 .. generalTypeCodeCNListLength - 1 LOOP
                -- Get the attributes of this node
                generalTypeCodeChildNode := DBMS_XMLDOM.item(generalTypeCodeChildNodeList, k);
                generalTypeCodeCNMap := DBMS_XMLDOM.GETATTRIBUTES(generalTypeCodeChildNode);
                generalTypeCodeAttributeNode := DBMS_XMLDOM.GETNAMEDITEM(generalTypeCodeCNMap,'value');
                generalTypeCodeCNAttr := DBMS_XMLDOM.MAKEATTR(generalTypeCodeAttributeNode);
                strGeneralTypeCodeCN := DBMS_XMLDOM.GETVALUE(generalTypeCodeCNAttr);                
               
                IF DBMS_XMLDOM.GETNODENAME(generalTypeCodeChildNode) = 'xsd:maxLength' THEN  
                  IF DBMS_XMLDOM.GETVALUE(DBMS_XMLDOM.MAKEATTR(generalTypeCodeAttributeNode)) = '50' THEN
                     DBMS_OUTPUT.PUT_LINE('-------UPDATING RECORD--------BEGIN  ROW ID -'||row_id);
                     DBMS_OUTPUT.PUT_LINE('-------BEFORE CHANGE = '||strGeneralTypeCodeCN);
                     DBMS_XMLDOM.setAttribute(DBMS_XMLDOM.makeElement(generalTypeCodeChildNode), 'value', '100');
                     DBMS_OUTPUT.PUT_LINE('-------AFTER CHANGE = '||DBMS_XMLDOM.GETVALUE(DBMS_XMLDOM.MAKEATTR(generalTypeCodeAttributeNode)));
                     DBMS_XMLDOM.WRITETOCLOB(doc, xmlTypeTOClob);
                     clobToXmlType := sys.xmlType.createXML(xmlTypeTOClob);
                    
                      --update  <table_name> set <column_name> = clobToXmlType where ROWID = row_id;
                      --commit;
                      DBMS_OUTPUT.PUT_LINE('-------UPDATING RECORD--------END  ROW ID -'||row_id);
                      DBMS_OUTPUT.PUT_LINE('');
                   END IF;
                END IF;
               
             END LOOP; --generalTypeCodeCNListLength for
        
        END LOOP; --simpleTypeChildNodeListLength   for
             
        END IF;      
  END LOOP; --simpleTypeNodeListLength for

 
  DBMS_XMLDOM.freeDocument(doc);




end XMLTEST3;


You can do this from updateXML and xpath also 

send me and email (saneera@gmail.com) if there is any question regarding this

Thanks