XML Data Handler »ç¿ëÀÚ Á¤ÀÇ

´ÙÀ½À» ¼öÇàÇÏ¿© XML Data Handler¸¦ »ç¿ëÀÚ Á¤ÀÇÇÒ ¼ö ÀÖ½À´Ï´Ù.

»ç¿ëÀÚ Á¤ÀÇ XML ³×ÀÓ Çڵ鷯 ºôµå

XML Data Handler´Â ³×ÀÓ Çڵ鷯¸¦ È£ÃâÇÏ¿© XML ¸Þ½ÃÁö·ÎºÎÅÍ Business ObjectÀÇ À̸§À» ÃßÃâÇÕ´Ï´Ù.

XML Data Handler¿Í ÇÔ²² Æ÷ÇԵǴ ±âº» ³×ÀÓ Çڵ鷯´Â ´ÙÀ½ ű׸¦ ã½À´Ï´Ù.


 <!DOCTYPE Name>
 

Data Handler´Â ÀÌ ÅÂ±× ¹× BOPrefix Meta Object ¼Ó¼º¿¡¼­ Business Object À̸§À» »ý¼ºÇÕ´Ï´Ù.

EDI Data Handler´Â Data Handler Meta Object¿¡ ÀúÀåµÈ NameHandlerClass ¼Ó¼º °ªÀ» »ç¿ëÇÏ¿© È£ÃâÇÒ ³×ÀÓ Çڵ鷯¸¦ °áÁ¤ÇÕ´Ï´Ù.

³×ÀÓ Çڵ鷯¸¦ ´Ù¸¥ ¹æ½ÄÀ¸·Î ±â´ÉÇϵµ·Ï ÇÏ·Á¸é, ´ÙÀ½À» ¼öÇàÇØ¾ß ÇÕ´Ï´Ù.

  1. NameHandler Ŭ·¡½º¸¦ È®ÀåÇÏ¿© »ç¿ëÀÚ Á¤ÀÇ ³×ÀÓ Çڵ鷯¸¦ ÀÛ¼ºÇÕ´Ï´Ù.
  2. XML Data Handler¿ë Meta Object¿¡ ÀÖ´Â NameHandlerClass ¼Ó¼ºÀÇ ±âº»°ªÀ» °»½ÅÇÏ¿© »ç¿ëÀÚ Á¤ÀÇ Å¬·¡½º¸¦ »ç¿ëÇϵµ·Ï XML Data Handler¸¦ ±¸¼ºÇÕ´Ï´Ù.

´ÙÀ½ »ùÇà ÄÚµå´Â XML Data Handler¿¡ ´ëÇÑ Custom Data HandlerÀÎ CustomDataHandler¸¦ ÀÛ¼ºÇϵµ·Ï DataHandler Ŭ·¡½º¸¦ È®ÀåÇÕ´Ï´Ù.

package com.crossworlds.DataHandlers.xml;
  
 // DataHandler Dependencies
 import com.crossworlds.DataHandlers.Exceptions.MalformedDataException;
 import com.crossworlds.DataHandlers.NameHandler;
 import com.crossworlds.DataHandlers.DataHandler;
  
 // Java classes
 import java.io.*;
 import java.lang.Exception;
  
 /***********************************************************
  * CustomNameHandler class. This class extends the Namehandler 
  * class and implements method:
  *      getBOName( Reader serializedData, String subType )
  * The method getBOName contains the logic to extract the BOName
 *************************************************************/
 public class CustomNameHandler extends NameHandler
 {
  
          /**
           * This method generates the business object name from 
           * the data extracted from the 'serializedData' arg.
           * In this case, it is up to the caller to create 
           * the BOName.
           */
  
           public String  getBOName( Reader serializedData, String subType )
             throws MalformedDataException
          {
            // The NameHandler uses DataHandler tracing. If the 
            // DataHandler is not set, the NameHandler won't run.
             if (dh == null) 
              return null;
             // Log a message
             dh.traceWrite( 
             "Entering CustomNameHandler.getBOName for subtype '"
               + subType + "'.", 4);
  
             // This method parses the XML document and extracts the
            // business object name from the following tag in 
            // the XML doc:
             //        <cml title= 
             // For example, in:
             //        <cml title="cholestrol" id="cml_cholesterol">
             // the Business Object name is 'cholestrol'.
  
             // Log a message
             dh.traceWrite( 
              "Name resolution will be done using <cml title= ",4);
             String name = null;
  
             try
            {
               // Read line of data from the Reader object
               LineNumberReader lineReader = 
                 new LineNumberReader( serializedData );
               serializedData.mark( 1000 );
               String line = lineReader.readLine();
               while ( line != null )
              {
                 // search for <cml title= in the line
                 int start = line.indexOf("<cml title=");
                 if ( start != -1 )
                {
                   start += 12;
                   // search for the ending quotes for the tile tag
                   int end = line.indexOf('\"', start);
  
                   // extract name from line
                   name = line.substring(start, end);
                   break;
                }
                 line = lineReader.readLine();
              }
  
               if ( name == null || name.length() == 0 )
                 throw new MalformedDataException(
                 "Error: can't determine the BusinessObject Name.");
  
            }
  
             catch(Exception e)
            {
               throw new MalformedDataException( e.getMessage() );
            }
             serializedData.reset();
             return name;
          }
 }
 

»ç¿ëÀÚ Á¤ÀÇ Entity Resolver ºôµå

XML Data Handler¿¡¼­ »ç¿ëÇÏ´Â SAX Parser´Â Entity Resolver¸¦ È£ÃâÇÏ¿© XML ¹®¼­ ³»¿¡¼­ ¿ÜºÎ ¿£Æ¼Æ¼(ÂüÁ¶µÈ DTD)¸¦ ã½À´Ï´Ù. XML Data Handler¿Í ÇÔ²² Æ÷ÇÔµÈ Entity Resolver´Â ·ÎÄà ÆÄÀÏ ½Ã½ºÅÛ¿¡¼­ ¿ÜºÎ ÂüÁ¶¸¦ ¹«½ÃÇϰųª °Ë»öÇÒ ¼ö ÀÖ½À´Ï´Ù. ¿ÜºÎ ¿£Æ¼Æ¼¸¦ ã±â À§ÇÑ ¶Ç´Ù¸¥ ¹æ¹ýÀ» ÁöÁ¤ÇØ¾ß ÇÒ °æ¿ì, »ç¿ëÀÚ Á¤ÀÇ Entity Resolver Ŭ·¡½º¸¦ ÀÛ¼ºÇØ¾ß ÇÕ´Ï´Ù.

XML Data Handler´Â XML Data Handler Meta Object¿¡ ÀúÀåµÈ EntityResolver ¼Ó¼º °ªÀ» »ç¿ëÇÏ¿© Entity Resolver¸¦ °áÁ¤ÇÕ´Ï´Ù.

Copyright IBM Corp. 1997, 2003