Using the RaXML Utility

Use the RaXML utility in your code.

  1. Import the essential modules:
    import org.dom4j.Element;
    import com.sybase.connector.repra.util.*;
  2. Create an instance of RaXMLBuilder:
    RaXMLBuilder raXML = new RaXMLBuilder();
  3. Get the event body, which requires three parameters:
    • The URI of the xsd. file

    • The name of the database

    • The event ID of the current event, which can be any string value

      If you want the transaction (<tran>) type to contain multiple database operations, enter:

      foo.createTranDocument("file://dbeventstream.
      			xsd","pubs2"","00001001");

      If you want the event (<dbevent>) type to contain a single database operation, enter:

      foo.createEventDocument("file://dbeventstream.
      			xsd","pubs2"","00001001");
  4. Add an operation, which requires:
    • The command

    • The name of the schema

    For example:

    Element oper1=foo.addOperation("update","authors"):
  5. Add data to the operation, which requires:
    • The operation element

    • fieldName

    • fieldType

    • fieldValue, the string value of the field

    For example:
    foo.addValue(operl,"au_id","CHAR","0001");
    foo.addValue(oper1,"au_num","INT","1");

    The field types, as SQL datatypes, are:

    • TEXT, DATETIME, SMALLDATETIME, MONEY, SMALLMONEY,

    • NUMERIC, DECIMAL, VARCHAR, CHAR, DATE, TIME

    • BINARY, IMAGE, VARBINARY

    • TINYINT, SMALLINT, INT

    • REAL

    • FLOAT

    • BIT

    • UNICHAR, UNIVARCHAR

    • UNITEXT

    • BIGINT, USMALLINT, UINT, UBIGINT

  6. Add a where clause to the operation, which requires:
    • The operation element

    • fieldName

    • fieldType

    • fieldValue

    • SQL condition: either AND or OR

    • SQL operator: =, <,>, NOT, and so forth

    For example:
    foo.addWhere
    		(oper1,"au_id","CHAR","0002","AND","=");
  7. Create an XML file:
    foo.write(fileName);
  8. Get the String value of the event from the current XML document:
    String dataStr=foo.xmlDocString();

    Your application must send the dataStr object to the RepConnector connection.