com.raritantechnologies.xml
Class XMLResultProcessor

java.lang.Object
  extended bycom.raritantechnologies.xml.XMLResultProcessor
All Implemented Interfaces:
IConfigurable, IResultParser, IXMLResultParser

public class XMLResultProcessor
extends java.lang.Object
implements IXMLResultParser, IResultParser

Processes an XMLResult using the ProgrammableSAXFilter. Used to convert 'raw' XML into IResult fields using the parameter setting callback capabilities of the ProgrammableSAXFilter.

XML Configuration Template:
 <XMLResultProcessor resultTagName="[name for result tags]" 
                     addResultID="true" 
                     debug="true|false"
                     characterEncoding="[ optional character encoding (e.g. ISO-8859-1) default=UTF-8 ]"
                     wrapCData="[ true(default) | false ]" >

   <!-- Defines the tag name that contains a record (i.e. a single result) - Equivalent to recordTagName attribute -->
   <RecordTag>Company</RecordTag>

   <NamespaceSchema>[ optional namespace schema for result tags ]</NamespaceSchema>

   <!-- Each Field element defines how a result field is to be extracted from an XML element -->
   <Field ID="[ the field name ]" 
             callbackType="[ fixed callback type: CData | Attribute ]" 
             callback=[ Alternate to callbackType - class of com.raritantechnologies.xml.sax.filter.callbacks.ICallbackOperation ]" 
             multiple="true|false(default)"
             unique="true|false(default)"
             delimiter="[ delimiter for single, non-unique values ]" >

     <ParamName>[ the field name ]</ParamName> 
     <Comparator class="TagComparator" >
       <TagName>CIK</TagName>
     </Comparator>

     <!-- Data Comparator filters on data value -->
     <DataComparator class="[ class of com.raritantechnologies.utils.comparators.IComparator ]" >

     </DataComparator>

   </Field>

   <!-- EXAMPLE Attribute Callback type -->
   <Field ID="Name" callbackType="Attribute" multiple="true">
     <ParamName>Name</ParamName> 
     <AttributeName>attrInXML</AttributeName>
     <Comparator class="TagComparator" >
       <TagName>Name</TagName>
     </Comparator>
   </Field>

   <!-- EXAMPLE CData Callback type -->
   <Field ID="[ field ID ]" callback="com.raritantechnologies.xml.sax.filter.callbacks.CDataCallbackOperation" >
     <ParamName>[ field ID ]</ParamName> 
     <Comparator class="PathComparator" 
                    matchStartsWith="true|false">
       <PathName>[ path to compare ]</PathName>
     </Comparator>

     <!-- Data Comparator filters on data value -->
     <DataComparator class="[ class of com.raritantechnologies.utils.comparators.IComparator ]" >

     </DataComparator>

   </Field>

   <Field ID="SIC" callback="com.raritantechnologies.xml.sax.filter.callbacks.AttributeCallbackOperation" >
     <AttributeName>StandardCode</AttributeName>
     <ParamName>SIC</ParamName> 
     <Comparator class="com.raritantechnologies.xml.sax.filter.comparators.TagComparator" >
       <TagName>SIC</TagName>
     </Comparator>
   </Field>

   <!-- Optional StringFilters be used to post-process the fields extracted from the XML -->
   <StringFilter class="[ some IStringFilter ]" 
                    ID="[field created by callbacks]" 
                    resultID="[field to put filtered result]" >
     <!-- params needed by String Filter -->
   </StringFilter>

   <!-- Optional FieldFormatters be used to post-process the fields extracted from the XML -->
   <FieldFormatter class="[ class of com.raritantechnologies.searchApp.IFieldFormatter ]" >

   </FieldFormatter>

   <!-- XMLResultProcessors can create hierarchically organized IResult objects with nested ResultSets: -->
   <NestedResults>

      <!-- One or more nested XMLResultProcessors keyed by nested result set fieldID --> 
      <XMLResultProcessor 
           fieldID="[ id of nested result Set ]" 
           nestedTagName="name of nested Tag " >

         <!-- configuration parameters of nested XMLResultProcessor -->

      </XMLResultProcessor>

   </NestedResults>

 </XMLResultProcessor>
 

Developed by Raritan Technologies .

Author:
Ted Sullivan

Nested Class Summary
 class XMLResultProcessor.ResSetProcessor
           
 
Field Summary
 
Fields inherited from interface com.raritantechnologies.searchApp.IResultParser
TEMPLATE
 
Constructor Summary
XMLResultProcessor()
           
XMLResultProcessor(org.w3c.dom.Element outputElem)
           
 
Method Summary
 IResultSet createResultSet(java.lang.String xmlResults)
           
 XMLResultSet createResultSet(java.lang.String xmlResults, java.lang.String resultTag, boolean keepXMLString, boolean wrapCData)
           
 java.util.Map getFieldMap()
           
 java.lang.String getNamespaceSchema()
           
 java.lang.String getRecordTag()
           
 void initialize(org.w3c.dom.Element outputElem)
          Initializes the object from an XML tag or element.
 IResult parse(java.lang.String dataString)
          Implementation of IResultParser
 void processXMLRes(XMLResult currResult)
           
 void processXMLRes(XMLResult currResult, java.lang.String xmlResStr, boolean replaceXML, boolean useString)
           
 void processXMLResultSet(XMLResultSet xmlResSet)
           
 void setRecordTag(java.lang.String recordTag)
           
 void setRecordTagName(java.lang.String recordTagName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLResultProcessor

public XMLResultProcessor()

XMLResultProcessor

public XMLResultProcessor(org.w3c.dom.Element outputElem)
Method Detail

initialize

public void initialize(org.w3c.dom.Element outputElem)
Description copied from interface: IConfigurable
Initializes the object from an XML tag or element. This method is called by the Framework as part of the application initializtion. see ConfigurationManager, XMLConfigurationManager, XMLSearchFieldMapFactory, XMLSearchSourceFactory. Configurable objects that are owned or contained by other configurable objects will be initialized in by the parent object.

Specified by:
initialize in interface IConfigurable

parse

public IResult parse(java.lang.String dataString)
Implementation of IResultParser

Specified by:
parse in interface IResultParser

processXMLRes

public void processXMLRes(XMLResult currResult)

processXMLRes

public void processXMLRes(XMLResult currResult,
                          java.lang.String xmlResStr,
                          boolean replaceXML,
                          boolean useString)

processXMLResultSet

public void processXMLResultSet(XMLResultSet xmlResSet)

createResultSet

public IResultSet createResultSet(java.lang.String xmlResults)
Specified by:
createResultSet in interface IXMLResultParser

createResultSet

public XMLResultSet createResultSet(java.lang.String xmlResults,
                                    java.lang.String resultTag,
                                    boolean keepXMLString,
                                    boolean wrapCData)

getFieldMap

public java.util.Map getFieldMap()

setRecordTag

public void setRecordTag(java.lang.String recordTag)

getRecordTag

public java.lang.String getRecordTag()

setRecordTagName

public void setRecordTagName(java.lang.String recordTagName)

getNamespaceSchema

public java.lang.String getNamespaceSchema()