This section shows you the way to change the content of input texts by using and extending the XMLProcessor component and its plugins.

h1. XMLProccessor Component {anchor:id="SOCref_developreference_XMLProcessor_Components"}
This service processes the input texts in the system by pushing it through a filter (plugin) chain and returns a result as the diagram below:

!images/ProcessorAndFilterSquenceDia.png|align="center" width="150mm" fo:scalefit="1" html:scalefit="0" !

Each filter is responsible for enriching the content of the input texts. For example, highlight usernames existing in a user's connection or
remove the forbidden HTML tags.

The XMLProcessor component is configured in the _config/src/main/java/conf/social/common-configuration.xml_ file:
{code:xml}
<component>
    <key>org.exoplatform.social.common.xmlprocessor.XMLProcessor</key>
    <type>org.exoplatform.social.common.xmlprocessor.XMLProcessorImpl</type>
</component>
{code}  

To manage the chain of the filters in XMLProcessor, you can use the _addFilterPlugin()_ and _removeFilterPlugin()_ methods.
XMLProcessor is initialized by IOC (Invesion of Control) via the configuration files defined in the _/demo/war/src/main/webapp/WEB-INF/conf/socialdemo/social/component-plugins-configuration.xml_ path.

*Sample code*: {anchor: id="Sample_code"}
{code:xml}
  <external-component-plugins>
    <target-component>org.exoplatform.social.common.xmlprocessor.XMLProcessor</target-component>
    <component-plugin>
      <name>URLConverterFilterPlugin</name>
      <set-method>addFilterPlugin</set-method>
      <type>org.exoplatform.social.common.xmlprocessor.filters.URLConverterFilterPlugin</type>
      <init-params>
        <value-param>
          <name>urlMaxLength</name>
          <description>the max length of URL</description>
          <value>-1</value>
        </value-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>
{code}

h1. Built-in XMLProcessor Plugins {anchor:id="SOCref_developreference_XMLProcessor_Plugins"}
In Social, there are the following built-in XMLProcessor plugins (also known as *filters*) that filter the input texts of users.
|| Filters || Description ||
|*DOMContentEscapeFilter*|Process the *DOM tree* input and escape all *text nodes*.|
|*DOMLineBreakerFilter*|Process the *DOM tree* input and add <br /> to all *text nodes* which contain {{{\\n}}}.|
|*DOMXMLTagFilter*|Process the *DOM tree* input and convert all *tag nodes* which do not exist in the allowed tags list into *text Node*.|
|*LineBreakerFilter*|Process the String input and replace {{{\\n}}} to <br />.|
|*XMLBalancer*|Process the String input and add missing close tags to input.|
|*XMLTagFilter*|Process the String input and convert all tags which do not exist in the allowed tags list into the escapsed String.|

The following is the general Class diagram of XMLProcesscor in Social:

!images/ProcessorAndFilterClassDiagram.png|align="center" width="120mm" fo:scalefit="1" html:scalefit="0"!

All of these filters implements the Filter interface as follows: {anchor: id="Filter_Interface"}
{code:java}
package org.exoplatform.social.common.xmlprocessor;
public interface Filter {
  /**
   * Filters the input data.
   *
   * @param input the input data
   * @return an Object with the result after filtered
   */
  public Object doFilter(Object input);
}
{code}

These filters will process the input texts in the _doFilter(Object input)_ method and return the result to XMLProcessor. 
They are declared in the configuration files found in the _/demo/war/src/main/webapp/WEB-INF/conf/socialdemo/social/component-plugins-configuration.xml_ path.

{code:xml}
<external-component-plugins>
    <target-component>org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy</target-component>
      <component-plugin>
        <name>setAllowedTagPlugin</name>
        <set-method>setAllowedTagPlugin</set-method>
        <type>org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTagPlugin</type>
        <init-params>
          <object-param>
            <name>b tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>b</string></field>
            </object>
          </object-param>
          <object-param>
            <name>i tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>i</string></field>
            </object>
          </object-param>
          <object-param>
            <name>a tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>a</string></field>
              <field name="tagAttributes">
                <collection type="java.util.HashSet" item-type="java.lang.String">
                  <value><string>href</string></value>
                </collection>
              </field>
            </object>
          </object-param>
          <object-param>
            <name>span tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>span</string></field>
            </object>
          </object-param>
          <object-param>
            <name>em tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>em</string></field>
            </object>
          </object-param>
          <object-param>
            <name>strong tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>strong</string></field>
            </object>
          </object-param>
          <object-param>
            <name>p tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>p</string></field>
            </object>
          </object-param>
          <object-param>
            <name>ol tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>ol</string></field>
            </object>
          </object-param>
          <object-param>
            <name>ul tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>ul</string></field>
            </object>
          </object-param>
          <object-param>
            <name>li tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>li</string></field>
            </object>
          </object-param>
          <object-param>
            <name>br tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>br</string></field>
            </object>
          </object-param>
          <object-param>
            <name>img tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>img</string></field>
              <field name="tagAttributes">
                <collection type="java.util.HashSet" item-type="java.lang.String">
                  <value><string>src</string></value>
                </collection>
              </field>
            </object>
          </object-param>
          <object-param>
            <name>blockquote tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>blockquote</string></field>
            </object>
          </object-param>
          <object-param>
            <name>q tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>q</string></field>
            </object>
          </object-param>
        </init-params>
      </component-plugin>
  </external-component-plugins>  
{code}

You can write your own filter by implementing the [Filter interface|#Filter_Interface] and add it to XMLProcessor as the [sample code|#Sample_code] in the *XMLProccessor Component* section.
