You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2016/12/17 15:18:17 UTC

svn commit: r1774774 [5/10] - in /directory/shared/branches/shared-value: ./ asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/ asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/ asn1/ber/src/main/java/org/apache/directory/api/asn1/be...

Modified: directory/shared/branches/shared-value/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/Dsmlv2ResponseGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/Dsmlv2ResponseGrammar.java?rev=1774774&r1=1774773&r2=1774774&view=diff
==============================================================================
--- directory/shared/branches/shared-value/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/Dsmlv2ResponseGrammar.java (original)
+++ directory/shared/branches/shared-value/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/Dsmlv2ResponseGrammar.java Sat Dec 17 15:18:15 2016
@@ -87,7 +87,7 @@ public final class Dsmlv2ResponseGrammar
     private static final Set<String> DSMLV2_DESCR_TAGS;
     static
     {
-        DSMLV2_DESCR_TAGS = new HashSet<String>();
+        DSMLV2_DESCR_TAGS = new HashSet<>();
         DSMLV2_DESCR_TAGS.add( "success" );
         DSMLV2_DESCR_TAGS.add( "operationsError" );
         DSMLV2_DESCR_TAGS.add( "protocolError" );
@@ -129,1902 +129,2016 @@ public final class Dsmlv2ResponseGrammar
         DSMLV2_DESCR_TAGS.add( "other" );
     }
 
-
-    @SuppressWarnings("unchecked")
-    private Dsmlv2ResponseGrammar()
+    /**
+     * GrammarAction that creates the Batch Response
+     */
+    private final GrammarAction batchResponseCreation = new GrammarAction( "Create Batch Response" )
     {
-        name = Dsmlv2ResponseGrammar.class.getName();
-
-        // Create the transitions table
-        super.transitions = ( HashMap<Tag, GrammarTransition>[] ) Array.newInstance( HashMap.class, 300 );
-
-        //====================================================
-        //  Transitions concerning : BATCH RESPONSE
-        //====================================================
-        super.transitions[Dsmlv2StatesEnum.INIT_GRAMMAR_STATE.ordinal()] = new HashMap<Tag, GrammarTransition>();
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            BatchResponseDsml batchResponse = new BatchResponseDsml();
 
-        // ** OPEN BATCH Reponse **
-        // State: [INIT_GRAMMAR_STATE] - Tag: <batchResponse>
-        super.transitions[Dsmlv2StatesEnum.INIT_GRAMMAR_STATE.ordinal()].put( new Tag( "batchResponse", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
-                batchResponseCreation ) );
+            container.setBatchResponse( batchResponse );
 
-        //====================================================
-        //  Transitions concerning : BATCH RESPONSE LOOP
-        //====================================================
-        super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()] = new HashMap<Tag, GrammarTransition>();
+            XmlPullParser xpp = container.getParser();
 
-        // State: [BATCH_RESPONSE_LOOP] - Tag: <addResponse>
-        super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "addResponse", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT,
-                addResponseCreation ) );
+            // Checking and adding the batchRequest's attributes
+            String attributeValue;
+            // requestID
+            attributeValue = xpp.getAttributeValue( "", "requestID" );
 
-        // State: [BATCH_RESPONSE_LOOP] - Tag: <authResponse>
-        super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "authResponse", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT,
-                authResponseCreation ) );
+            if ( attributeValue != null )
+            {
+                batchResponse.setRequestID( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
+            }
+        }
+    };
 
-        // State: [BATCH_RESPONSE_LOOP] - Tag: <compareResponse>
-        super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "compareResponse", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT,
-                compareResponseCreation ) );
+    /**
+     * GrammarAction that creates the Add Response
+     */
+    private final GrammarAction addResponseCreation = new GrammarAction( "Create Add Response" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            AddResponseDsml addResponse = new AddResponseDsml(
+                container.getLdapCodecService(), new AddResponseImpl() );
+            container.getBatchResponse().addResponse( addResponse );
 
-        // State: [BATCH_RESPONSE_LOOP] - Tag: <delResponse>
-        super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "delResponse", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT,
-                delResponseCreation ) );
+            LdapResult ldapResult = addResponse.getLdapResult();
 
-        // State: [BATCH_RESPONSE_LOOP] - Tag: <modifyResponse>
-        super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "modifyResponse", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT,
-                modifyResponseCreation ) );
+            XmlPullParser xpp = container.getParser();
 
-        // State: [BATCH_RESPONSE_LOOP] - Tag: <modDNResponse>
-        super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "modDNResponse", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT,
-                modDNResponseCreation ) );
+            // Checking and adding the batchRequest's attributes
+            String attributeValue;
+            // requestID
+            attributeValue = xpp.getAttributeValue( "", "requestID" );
 
-        // State: [BATCH_RESPONSE_LOOP] - Tag: <extendedResponse>
-        super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put(
-            new Tag( "extendedResponse", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.EXTENDED_RESPONSE,
-                extendedResponseCreation ) );
+            if ( attributeValue != null )
+            {
+                addResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
+            }
 
-        // State: [BATCH_RESPONSE_LOOP] - Tag: <errorResponse>
-        super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "errorResponse", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.ERROR_RESPONSE,
-                errorResponseCreation ) );
+            // MatchedDN
+            attributeValue = xpp.getAttributeValue( "", "matchedDN" );
 
-        // State: [BATCH_RESPONSE_LOOP] - Tag: <searchReponse>
-        super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "searchResponse", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.SEARCH_RESPONSE,
-                searchResponseCreation ) );
+            if ( attributeValue != null )
+            {
+                try
+                {
+                    ldapResult.setMatchedDn( new Dn( attributeValue ) );
+                }
+                catch ( LdapInvalidDnException lide )
+                {
+                    throw new XmlPullParserException( lide.getMessage(), xpp, lide );
+                }
+            }
+        }
+    };
 
-        // State: [BATCH_RESPONSE_LOOP] - Tag: </batchResponse>
-        super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "batchResponse", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.GRAMMAR_END, null ) );
+    /**
+     * GrammarAction that creates the Auth Response
+     */
+    private final GrammarAction authResponseCreation = new GrammarAction( "Create Auth Response" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            BindResponseDsml bindResponse = new BindResponseDsml(
+                container.getLdapCodecService(), new BindResponseImpl() );
+            container.getBatchResponse().addResponse( bindResponse );
 
-        //====================================================
-        //  Transitions concerning : ERROR RESPONSE
-        //====================================================
-        super.transitions[Dsmlv2StatesEnum.ERROR_RESPONSE.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.MESSAGE_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.DETAIL_START.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.DETAIL_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
+            LdapResult ldapResult = bindResponse.getLdapResult();
 
-        // State: [ERROR_RESPONSE] - Tag: <message>
-        super.transitions[Dsmlv2StatesEnum.ERROR_RESPONSE.ordinal()].put( new Tag( "message", Tag.START ),
-            new GrammarTransition(
-                Dsmlv2StatesEnum.ERROR_RESPONSE, Dsmlv2StatesEnum.MESSAGE_END, errorResponseAddMessage ) );
+            XmlPullParser xpp = container.getParser();
 
-        // State: [ERROR_RESPONSE] - Tag: <detail>
-        super.transitions[Dsmlv2StatesEnum.ERROR_RESPONSE.ordinal()].put( new Tag( "detail", Tag.START ),
-            new GrammarTransition(
-                Dsmlv2StatesEnum.ERROR_RESPONSE, Dsmlv2StatesEnum.DETAIL_START, ERROR_RESPONSE_ADD_DETAIL ) );
+            // Checking and adding the batchRequest's attributes
+            String attributeValue;
+            // requestID
+            attributeValue = xpp.getAttributeValue( "", "requestID" );
 
-        // State: [MESSAGE_END] - Tag: </errorResponse>
-        super.transitions[Dsmlv2StatesEnum.MESSAGE_END.ordinal()].put( new Tag( "errorResponse", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.MESSAGE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
+            if ( attributeValue != null )
+            {
+                bindResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
 
-        // State: [MESSAGE_END] - Tag: <detail>
-        super.transitions[Dsmlv2StatesEnum.MESSAGE_END.ordinal()].put( new Tag( "detail", Tag.START ),
-            new GrammarTransition(
-                Dsmlv2StatesEnum.MESSAGE_END, Dsmlv2StatesEnum.DETAIL_START, ERROR_RESPONSE_ADD_DETAIL ) );
+            }
 
-        // State: [DETAIL_START] - Tag: </detail>
-        super.transitions[Dsmlv2StatesEnum.DETAIL_START.ordinal()].put( new Tag( "detail", Tag.END ),
-            new GrammarTransition(
-                Dsmlv2StatesEnum.DETAIL_START, Dsmlv2StatesEnum.DETAIL_END, null ) );
+            // MatchedDN
+            attributeValue = xpp.getAttributeValue( "", "matchedDN" );
 
-        // State: [DETAIL_END] - Tag: <detail>
-        super.transitions[Dsmlv2StatesEnum.DETAIL_END.ordinal()].put( new Tag( "detail", Tag.END ),
-            new GrammarTransition(
-                Dsmlv2StatesEnum.DETAIL_END, Dsmlv2StatesEnum.DETAIL_END, ERROR_RESPONSE_ADD_DETAIL ) );
+            if ( attributeValue != null )
+            {
+                try
+                {
+                    ldapResult.setMatchedDn( new Dn( attributeValue ) );
+                }
+                catch ( LdapInvalidDnException lide )
+                {
+                    throw new XmlPullParserException( lide.getMessage(), xpp, lide );
+                }
+            }
+        }
+    };
 
-        // State: [ERROR_RESPONSE] - Tag: </errorResponse>
-        super.transitions[Dsmlv2StatesEnum.ERROR_RESPONSE.ordinal()].put( new Tag( "errorResponse", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.ERROR_RESPONSE, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
+    /**
+     * GrammarAction that creates the Compare Response
+     */
+    private final GrammarAction compareResponseCreation = new GrammarAction( "Create Compare Response" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            CompareResponseDsml compareResponse = new CompareResponseDsml(
+                container.getLdapCodecService(), new CompareResponseImpl() );
+            container.getBatchResponse().addResponse( compareResponse );
 
-        //====================================================
-        //  Transitions concerning : EXTENDED RESPONSE
-        //====================================================
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_START.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.RESPONSE_NAME_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.RESPONSE_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
+            LdapResult ldapResult = compareResponse.getLdapResult();
 
-        // State: [EXTENDED_RESPONSE] - Tag: <control>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE.ordinal()].put( new Tag( "control", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START, ldapResultControlCreation ) );
+            XmlPullParser xpp = container.getParser();
 
-        // State: [EXTENDED_RESPONSE_CONTROL_START] - Tag: <controlValue>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START.ordinal()].put( new Tag( "controlValue",
-            Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_END, ldapResultControlValueCreation ) );
+            // Checking and adding the batchRequest's attributes
+            String attributeValue;
+            // requestID
+            attributeValue = xpp.getAttributeValue( "", "requestID" );
 
-        // State: [EXTENDED_RESPONSE_CONTROL_VALUE_END] - Tag: </control>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_END.ordinal()].put( new Tag( "control",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_END,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END, null ) );
+            if ( attributeValue != null )
+            {
+                compareResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
+            }
 
-        // State: [EXTENDED_RESPONSE_CONTROL_START] - Tag: </control>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START.ordinal()].put(
-            new Tag( "control", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END, null ) );
+            // MatchedDN
+            attributeValue = xpp.getAttributeValue( "", "matchedDN" );
 
-        // State: [EXTENDED_RESPONSE_CONTROL_END] - Tag: <control>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END.ordinal()].put(
-            new Tag( "control", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START, ldapResultControlCreation ) );
+            if ( attributeValue != null )
+            {
+                try
+                {
+                    ldapResult.setMatchedDn( new Dn( attributeValue ) );
+                }
+                catch ( LdapInvalidDnException lide )
+                {
+                    throw new XmlPullParserException( lide.getMessage(), xpp, lide );
+                }
+            }
+        }
+    };
 
-        // State: [EXTENDED_RESPONSE_CONTROL_END] - Tag: <resultCode>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END.ordinal()].put( new Tag( "resultCode",
-            Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_START, extendedResponseAddResultCode ) );
+    /**
+     * GrammarAction that creates the Del Response
+     */
+    private final GrammarAction delResponseCreation = new GrammarAction( "Create Del Response" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            DelResponseDsml delResponse = new DelResponseDsml(
+                container.getLdapCodecService(), new DeleteResponseImpl() );
+            container.getBatchResponse().addResponse( delResponse );
 
-        // State: [EXTENDED_RESPONSE] - Tag: <resultCode>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE.ordinal()].put( new Tag( "resultCode", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_START, extendedResponseAddResultCode ) );
+            LdapResult ldapResult = delResponse.getLdapResult();
 
-        // State: [EXTENDED_RESPONSE_RESULT_CODE_START] - Tag: </resultCode>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_START.ordinal()].put( new Tag( "resultCode",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_START,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, null ) );
+            XmlPullParser xpp = container.getParser();
 
-        // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: <errorMessage>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END.ordinal()].put(
-            new Tag( "errorMessage", Tag.START ), new GrammarTransition(
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END, extendedResponseAddErrorMessage ) );
+            // Checking and adding the batchRequest's attributes
+            String attributeValue;
+            // requestID
+            attributeValue = xpp.getAttributeValue( "", "requestID" );
 
-        // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: <referral>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END.ordinal()].put( new Tag( "referral",
-            Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, extendedResponseAddReferral ) );
+            if ( attributeValue != null )
+            {
+                delResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
+            }
 
-        // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: <responseName>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END.ordinal()].put(
-            new Tag( "responseName", Tag.START ), new GrammarTransition(
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, Dsmlv2StatesEnum.RESPONSE_NAME_END,
-                extendedResponseAddResponseName ) );
+            // MatchedDN
+            attributeValue = xpp.getAttributeValue( "", "matchedDN" );
 
-        // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: <response>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END.ordinal()].put( new Tag( "response",
-            Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, Dsmlv2StatesEnum.RESPONSE_END,
-                extendedResponseAddResponse ) );
+            if ( attributeValue != null )
+            {
+                try
+                {
+                    ldapResult.setMatchedDn( new Dn( attributeValue ) );
+                }
+                catch ( LdapInvalidDnException lide )
+                {
+                    throw new XmlPullParserException( lide.getMessage(), xpp, lide );
+                }
+            }
+        }
+    };
 
-        // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: </extendedResponse>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END.ordinal()].put(
-            new Tag( "extendedResponse", Tag.END ), new GrammarTransition(
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
+    /**
+     * GrammarAction that creates the Modify Response
+     */
+    private final GrammarAction modifyResponseCreation = new GrammarAction( "Create Modify Response" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            ModifyResponseDsml modifyResponse = new ModifyResponseDsml(
+                container.getLdapCodecService(), new ModifyResponseImpl() );
+            container.getBatchResponse().addResponse( modifyResponse );
 
-        // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_END] - Tag: <referral>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END.ordinal()].put( new Tag( "referral",
-            Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, extendedResponseAddReferral ) );
+            LdapResult ldapResult = modifyResponse.getLdapResult();
 
-        // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_END] - Tag: <responseName>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END.ordinal()].put(
-            new Tag( "responseName", Tag.START ), new GrammarTransition(
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END, Dsmlv2StatesEnum.RESPONSE_NAME_END,
-                extendedResponseAddResponseName ) );
+            XmlPullParser xpp = container.getParser();
 
-        // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_END] - Tag: <response>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END.ordinal()].put( new Tag( "response",
-            Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END, Dsmlv2StatesEnum.RESPONSE_END,
-                extendedResponseAddResponse ) );
+            // Checking and adding the batchRequest's attributes
+            String attributeValue;
+            // requestID
+            attributeValue = xpp.getAttributeValue( "", "requestID" );
 
-        // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_END] - Tag: </extendedResponse>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END.ordinal()].put( new Tag(
-            "extendedResponse",
-            Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END,
-            Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
+            if ( attributeValue != null )
+            {
+                modifyResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
+            }
 
-        // State: [EXTENDED_RESPONSE_REFERRAL_END] - Tag: <referral>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END.ordinal()].put( new Tag( "referral",
-            Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, extendedResponseAddReferral ) );
+            // MatchedDN
+            attributeValue = xpp.getAttributeValue( "", "matchedDN" );
 
-        // State: [EXTENDED_RESPONSE_REFERRAL_END] - Tag: <responseName>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END.ordinal()].put( new Tag( "responseName",
-            Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, Dsmlv2StatesEnum.RESPONSE_NAME_END,
-                extendedResponseAddResponseName ) );
+            if ( attributeValue != null )
+            {
+                try
+                {
+                    ldapResult.setMatchedDn( new Dn( attributeValue ) );
+                }
+                catch ( LdapInvalidDnException lide )
+                {
+                    throw new XmlPullParserException( lide.getMessage(), xpp, lide );
+                }
+            }
+        }
+    };
 
-        // State: [EXTENDED_RESPONSE_REFERRAL_END] - Tag: <reponse>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END.ordinal()].put(
-            new Tag( "reponse", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, Dsmlv2StatesEnum.RESPONSE_END,
-                extendedResponseAddResponse ) );
+    /**
+     * GrammarAction that creates the Mod Dn Response
+     */
+    private final GrammarAction modDNResponseCreation = new GrammarAction( "Create Mod Dn Response" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            ModDNResponseDsml modDNResponse = new ModDNResponseDsml(
+                container.getLdapCodecService(), new ModifyDnResponseImpl() );
+            container.getBatchResponse().addResponse( modDNResponse );
 
-        // State: [EXTENDED_RESPONSE_REFERRAL_END] - Tag: </extendedResponse>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END.ordinal()].put( new Tag( "extendedResponse",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END,
-                Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
+            LdapResult ldapResult = modDNResponse.getLdapResult();
 
-        // State: [RESPONSE_NAME_END] - Tag: <response>
-        super.transitions[Dsmlv2StatesEnum.RESPONSE_NAME_END.ordinal()].put( new Tag( "response", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.RESPONSE_NAME_END, Dsmlv2StatesEnum.RESPONSE_END,
-                extendedResponseAddResponse ) );
+            XmlPullParser xpp = container.getParser();
 
-        // State: [RESPONSE_NAME_END] - Tag: </extendedResponse>
-        super.transitions[Dsmlv2StatesEnum.RESPONSE_NAME_END.ordinal()].put( new Tag( "extendedResponse", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.RESPONSE_NAME_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
+            // Checking and adding the batchRequest's attributes
+            String attributeValue;
+            // requestID
+            attributeValue = xpp.getAttributeValue( "", "requestID" );
 
-        // State: [RESPONSE_END] - Tag: </extendedResponse>
-        super.transitions[Dsmlv2StatesEnum.RESPONSE_END.ordinal()].put( new Tag( "extendedResponse", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.RESPONSE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
+            if ( attributeValue != null )
+            {
+                modDNResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
+            }
 
-        //====================================================
-        //  Transitions concerning : LDAP RESULT
-        //====================================================
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_START.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
+            // MatchedDN
+            attributeValue = xpp.getAttributeValue( "", "matchedDN" );
 
-        // State: [LDAP_RESULT] - Tag: <control>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT.ordinal()].put( new Tag( "control", Tag.START ),
-            new GrammarTransition(
-                Dsmlv2StatesEnum.LDAP_RESULT, Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START, ldapResultControlCreation ) );
+            if ( attributeValue != null )
+            {
+                try
+                {
+                    ldapResult.setMatchedDn( new Dn( attributeValue ) );
+                }
+                catch ( LdapInvalidDnException lide )
+                {
+                    throw new XmlPullParserException( lide.getMessage(), xpp, lide );
+                }
+            }
+        }
+    };
 
-        // State: [LDAP_RESULT] - Tag: <resultCode>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT.ordinal()]
-            .put( new Tag( "resultCode", Tag.START ), new GrammarTransition(
-                Dsmlv2StatesEnum.LDAP_RESULT, Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_START, ldapResultAddResultCode ) );
+    /**
+     * GrammarAction that creates the Extended Response
+     */
+    private final GrammarAction extendedResponseCreation = new GrammarAction( "Create Extended Response" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            ExtendedResponseDsml extendedResponse;
 
-        // State: [LDAP_RESULT_CONTROL_START] - Tag: <controlValue>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START.ordinal()].put(
-            new Tag( "controlValue", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START,
-                Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_END, ldapResultControlValueCreation ) );
+            // Checking and adding the batchRequest's attributes
+            String attributeValue;
 
-        // State: [LDAP_RESULT_CONTROL_VALUE_END] - Tag: </control>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_END.ordinal()].put( new Tag( "control", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_END,
-                Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END, null ) );
+            XmlPullParser xpp = container.getParser();
 
-        // State: [LDAP_RESULT_CONTROL_START] - Tag: </control>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START.ordinal()].put( new Tag( "control", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START,
-                Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END, null ) );
+            // requestID
+            attributeValue = xpp.getAttributeValue( "", "requestID" );
 
-        // State: [LDAP_RESULT_CONTROL_END] - Tag: <control>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END.ordinal()].put( new Tag( "control", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END,
-                Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START, ldapResultControlCreation ) );
+            if ( attributeValue != null )
+            {
+                extendedResponse = new ExtendedResponseDsml(
+                    container.getLdapCodecService(), new ExtendedResponseImpl(
+                        ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) ) );
+            }
+            else
+            {
+                extendedResponse = new ExtendedResponseDsml(
+                    container.getLdapCodecService(), new ExtendedResponseImpl( -1 ) );
+            }
 
-        // State: [LDAP_RESULT_CONTROL_END] - Tag: <resultCode>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END.ordinal()].put( new Tag( "resultCode", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END,
-                Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_START, ldapResultAddResultCode ) );
+            container.getBatchResponse().addResponse( extendedResponse );
 
-        // State: [LDAP_RESULT_RESULT_CODE_START] - Tag: </resultCode>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_START.ordinal()].put(
-            new Tag( "resultCode", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_START,
-                Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, null ) );
+            LdapResult ldapResult = extendedResponse.getLdapResult();
 
-        // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: <errorMessage>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put( new Tag( "errorMessage",
-            Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END,
-                Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END, ldapResultAddErrorMessage ) );
+            // MatchedDN
+            attributeValue = xpp.getAttributeValue( "", "matchedDN" );
 
-        // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: <referral>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put(
-            new Tag( "referral", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END,
-                Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, ldapResultAddReferral ) );
+            if ( attributeValue != null )
+            {
+                try
+                {
+                    ldapResult.setMatchedDn( new Dn( attributeValue ) );
+                }
+                catch ( LdapInvalidDnException lide )
+                {
+                    throw new XmlPullParserException( lide.getMessage(), xpp, lide );
+                }
+            }
+        }
+    };
 
-        // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </addResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put(
-            new Tag( "addResponse", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
-                null ) );
+    /**
+     * GrammarAction that creates the Error Response
+     */
+    private final GrammarAction errorResponseCreation = new GrammarAction( "Create Error Response" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            ErrorResponse errorResponse = null;
+            XmlPullParser xpp = container.getParser();
 
-        // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </authResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put(
-            new Tag( "authResponse", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
-                null ) );
+            // Checking and adding the batchRequest's attributes
+            String attributeValue;
+            
+            // requestID
+            attributeValue = xpp.getAttributeValue( "", "requestID" );
 
-        // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </compareResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put( new Tag( "compareResponse",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
-                null ) );
+            if ( attributeValue != null )
+            {
+                errorResponse = new ErrorResponse( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ), null );
 
-        // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </delResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put(
-            new Tag( "delResponse", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
-                null ) );
+                container.getBatchResponse().addResponse( errorResponse );
+            }
+            
+            // type
+            attributeValue = xpp.getAttributeValue( "", "type" );
+            
+            if ( attributeValue != null )
+            {
+                if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.NOT_ATTEMPTED ) ) )
+                {
+                    errorResponse.setErrorType( ErrorResponseType.NOT_ATTEMPTED );
+                }
+                else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.COULD_NOT_CONNECT ) ) )
+                {
+                    errorResponse.setErrorType( ErrorResponseType.COULD_NOT_CONNECT );
+                }
+                else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.CONNECTION_CLOSED ) ) )
+                {
+                    errorResponse.setErrorType( ErrorResponseType.CONNECTION_CLOSED );
+                }
+                else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.MALFORMED_REQUEST ) ) )
+                {
+                    errorResponse.setErrorType( ErrorResponseType.MALFORMED_REQUEST );
+                }
+                else if ( attributeValue
+                    .equals( errorResponse.getTypeDescr( ErrorResponseType.GATEWAY_INTERNAL_ERROR ) ) )
+                {
+                    errorResponse.setErrorType( ErrorResponseType.GATEWAY_INTERNAL_ERROR );
+                }
+                else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.AUTHENTICATION_FAILED ) ) )
+                {
+                    errorResponse.setErrorType( ErrorResponseType.AUTHENTICATION_FAILED );
+                }
+                else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.UNRESOLVABLE_URI ) ) )
+                {
+                    errorResponse.setErrorType( ErrorResponseType.UNRESOLVABLE_URI );
+                }
+                else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.OTHER ) ) )
+                {
+                    errorResponse.setErrorType( ErrorResponseType.OTHER );
+                }
+                else
+                {
+                    throw new XmlPullParserException( I18n.err( I18n.ERR_03004 ), xpp, null );
+                }
+            }
+            else
+            {
+                throw new XmlPullParserException( I18n.err( I18n.ERR_03005 ), xpp, null );
+            }
+        }
+    };
 
-        // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </modifyResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put( new Tag( "modifyResponse",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
-                null ) );
+    /**
+     * GrammarAction that adds Message to an Error Response
+     */
+    private final GrammarAction errorResponseAddMessage = new GrammarAction( "Add Message to Error Response" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            ErrorResponse errorResponse = ( ErrorResponse ) container.getBatchResponse().getCurrentResponse();
 
-        // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </modDNResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put( new Tag( "modDNResponse",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
-                null ) );
+            XmlPullParser xpp = container.getParser();
+            try
+            {
+                String nextText = xpp.nextText();
+                if ( !Strings.isEmpty( nextText ) )
+                {
+                    errorResponse.setMessage( nextText.trim() );
+                }
+            }
+            catch ( IOException ioe )
+            {
+                throw new XmlPullParserException( ioe.getMessage(), xpp, ioe );
+            }
+        }
+    };
 
-        // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </searchResultDone>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put( new Tag( "searchResultDone",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END,
-                Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END, null ) );
+    /**
+     * GrammarAction that adds Detail to an Error Response
+     */
+    // TODO Look for documentation about this Detail element (the DSML documentation doesn't give enough information)
+    private static final GrammarAction ERROR_RESPONSE_ADD_DETAIL = null;
 
-        // State: [SEARCH_RESULT_DONE_END] - Tag: </searchResponse>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END.ordinal()]
-            .put( new Tag( "searchResponse", Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END,
-                Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
 
-        // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: <referral>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()].put(
-            new Tag( "referral", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
-                Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, ldapResultAddReferral ) );
+    /**
+     * GrammarAction that creates a Control for LDAP Result
+     */
+    private final GrammarAction ldapResultControlCreation = new GrammarAction( "Create Control for LDAP Result" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            AbstractDsmlMessageDecorator<? extends Message> message =
+                ( AbstractDsmlMessageDecorator<? extends Message> )
+                container.getBatchResponse().getCurrentResponse();
 
-        // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </addResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()].put( new Tag( "addResponse",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
-                Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
+            if ( message instanceof SearchResponseDsml )
+            {
+                createAndAddControl( container,
+                    ( ( SearchResponse ) ( ( SearchResponseDsml ) message ).getDecorated() ).getSearchResultDone() );
+            }
+            else
+            {
+                createAndAddControl( container, message );
+            }
+        }
+    };
 
-        // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </authResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()].put( new Tag( "authResponse",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
-                Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
+    /**
+     * GrammarAction that creates a Control for Search Result Entry
+     */
+    private final GrammarAction searchResultEntryControlCreation = new GrammarAction(
+        "Create Control for Search Result Entry" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            SearchResponse response = ( SearchResponse )
+                ( ( SearchResponseDsml ) container.getBatchResponse()
+                    .getCurrentResponse() ).getDecorated();
 
-        // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </compareResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()].put( new Tag( "compareResponse",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
-                Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
+            createAndAddControl( container, response.getCurrentSearchResultEntry() );
+        }
+    };
+
+    /**
+     * GrammarAction that creates a Control for Search Result Entry
+     */
+    private final GrammarAction searchResultReferenceControlCreation = new GrammarAction(
+        "Create Control for Search Result Reference" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            SearchResponse response = ( SearchResponse )
+                ( ( SearchResponseDsml ) container.getBatchResponse()
+                    .getCurrentResponse() ).getDecorated();
+
+            createAndAddControl( container, response.getCurrentSearchResultReference() );
+        }
+    };
+
+    /**
+     * GrammarAction that creates a Control Value for LDAP Result
+     */
+    private final GrammarAction ldapResultControlValueCreation = new GrammarAction(
+        "Add ControlValue to Control for LDAP Result" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            AbstractDsmlMessageDecorator<? extends Response> response
+            = ( AbstractDsmlMessageDecorator<? extends Response> )
+                container.getBatchResponse().getCurrentResponse();
+
+            if ( response instanceof SearchResponseDsml )
+            {
+                SearchResponse searchResponse = ( SearchResponse )
+                    response.getDecorated();
+                createAndAddControlValue( container,
+                    searchResponse.getSearchResultDone() );
+            }
+            else
+            {
+                createAndAddControlValue( container, response );
+            }
+        }
+    };
+
+    /**
+     * GrammarAction that creates a Control Value for Search Result Entry
+     */
+    private final GrammarAction searchResultEntryControlValueCreation = new GrammarAction(
+        "Add ControlValue to Control for Search Result Entry" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            SearchResponse response = ( SearchResponse )
+                container.getBatchResponse().getCurrentResponse().getDecorated();
+            createAndAddControlValue( container,
+                response.getCurrentSearchResultEntry() );
+        }
+    };
+
+    /**
+     * GrammarAction that creates a Control Value for Search Result Reference
+     */
+    private final GrammarAction searchResultReferenceControlValueCreation = new GrammarAction(
+        "Add ControlValue to Control for Search Result Entry" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            SearchResponseDsml response = ( SearchResponseDsml )
+                container.getBatchResponse().getCurrentResponse();
+            createAndAddControlValue( container,
+                ( ( SearchResponse ) response.getDecorated() ).getCurrentSearchResultReference() );
+        }
+    };
+
+    /**
+     * GrammarAction that adds a Result Code to a LDAP Result
+     */
+    private final GrammarAction ldapResultAddResultCode = new GrammarAction( "Add ResultCode to LDAP Result" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            DsmlDecorator<? extends Response> ldapResponse =
+                container.getBatchResponse().getCurrentResponse();
 
-        // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </delResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()].put( new Tag( "delResponse",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
-                Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
+            LdapResult ldapResult;
 
-        // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </modifyResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()].put( new Tag( "modifyResponse",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
-                Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
+            // Search Response is a special case
+            // ResultCode can only occur in a case of Search Result Done in a Search Response
+            if ( ldapResponse.getDecorated() instanceof SearchResponse )
+            {
+                SearchResponse searchResponse = ( SearchResponse ) ldapResponse.getDecorated();
+                ldapResult = searchResponse.getSearchResultDone().getLdapResult();
+            }
+            else
+            {
+                ldapResult = ( ( ResultResponse ) ldapResponse.getDecorated() ).getLdapResult();
+            }
 
-        // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </modDNResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()].put( new Tag( "modDNResponse",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
-                Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
+            XmlPullParser xpp = container.getParser();
 
-        // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </searchResultDone>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()].put( new Tag( "searchResultDone",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
-                Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END, null ) );
+            // Checking and adding the request's attributes
+            String attributeValue;
+            // code
+            attributeValue = xpp.getAttributeValue( "", "code" );
 
-        // State: [LDAP_RESULT_REFERRAL_END] - Tag: <referral>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()].put( new Tag( "referral", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END,
-                Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, ldapResultAddReferral ) );
+            if ( attributeValue != null )
+            {
+                try
+                {
+                    ldapResult.setResultCode( ResultCodeEnum.getResultCode( Integer.parseInt( attributeValue ) ) );
+                }
+                catch ( NumberFormatException nfe )
+                {
+                    throw new XmlPullParserException( I18n.err( I18n.ERR_03009 ), xpp, nfe );
+                }
+            }
+            else
+            {
+                throw new XmlPullParserException( I18n.err( I18n.ERR_03010 ), xpp, null );
+            }
 
-        // State: [LDAP_RESULT_REFERRAL_END] - Tag: </addResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()].put( new Tag( "addResponse", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
-                null ) );
+            // descr
+            attributeValue = xpp.getAttributeValue( "", "descr" );
 
-        // State: [LDAP_RESULT_REFERRAL_END] - Tag: </authResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()].put( new Tag( "authResponse", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
-                null ) );
+            if ( ( attributeValue != null ) && !DSMLV2_DESCR_TAGS.contains( attributeValue ) )
+            {
+                throw new XmlPullParserException( I18n.err( I18n.ERR_03011, attributeValue ), xpp, null );
+            }
+        }
+    };
 
-        // State: [LDAP_RESULT_REFERRAL_END] - Tag: </compareResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()].put(
-            new Tag( "compareResponse", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
-                null ) );
+    /**
+     * GrammarAction that adds a Error Message to a LDAP Result
+     */
+    private final GrammarAction ldapResultAddErrorMessage = new GrammarAction( "Add Error Message to LDAP Result" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            DsmlDecorator<? extends Response> ldapResponse =
+                container.getBatchResponse().getCurrentResponse();
 
-        // State: [LDAP_RESULT_REFERRAL_END] - Tag: </delResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()].put( new Tag( "delResponse", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
-                null ) );
+            LdapResult ldapResult;
 
-        // State: [LDAP_RESULT_REFERRAL_END] - Tag: </modifyResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()].put(
-            new Tag( "modifyResponse", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
-                null ) );
+            // Search Response is a special case
+            // ResultCode can only occur in a case of Search Result Done in a Search Response
+            if ( ldapResponse.getDecorated() instanceof SearchResponse )
+            {
+                SearchResponse searchResponse = ( SearchResponse ) ldapResponse.getDecorated();
+                ldapResult = searchResponse.getSearchResultDone().getLdapResult();
+            }
+            else
+            {
+                ldapResult = ( ( ResultResponse ) ldapResponse.getDecorated() ).getLdapResult();
+            }
 
-        // State: [LDAP_RESULT_REFERRAL_END] - Tag: </modDNResponse>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()].put(
-            new Tag( "modDNResponse", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
-                null ) );
+            XmlPullParser xpp = container.getParser();
 
-        // State: [LDAP_RESULT_REFERRAL_END] - Tag: </searchResultDone>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()].put( new Tag( "searchResultDone",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END,
-                null ) );
+            try
+            {
+                String nextText = xpp.nextText();
 
-        //====================================================
-        //  Transitions concerning : SEARCH RESPONSE
-        //====================================================
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESPONSE.ordinal()] = new HashMap<Tag, GrammarTransition>();
+                if ( !Strings.isEmpty( nextText ) )
+                {
+                    ldapResult.setDiagnosticMessage( nextText.trim() );
+                }
+            }
+            catch ( IOException ioe )
+            {
+                throw new XmlPullParserException( I18n.err( I18n.ERR_03008, ioe.getMessage() ), xpp, ioe );
+            }
+        }
+    };
 
-        // State: [SEARCH_REPONSE] - Tag: <searchResultEntry>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESPONSE.ordinal()].put( new Tag( "searchResultEntry", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESPONSE, Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY,
-                searchResultEntryCreation ) );
+    /**
+     * GrammarAction that adds a Referral to a LDAP Result
+     */
+    private final GrammarAction ldapResultAddReferral = new GrammarAction( "Add Referral to LDAP Result" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            DsmlDecorator<? extends Response> ldapResponse =
+                container.getBatchResponse().getCurrentResponse();
 
-        // State: [SEARCH_REPONSE] - Tag: <searchResultReference>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESPONSE.ordinal()].put(
-            new Tag( "searchResultReference", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESPONSE, Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE,
-                searchResultReferenceCreation ) );
+            LdapResult ldapResult;
 
-        // State: [SEARCH_REPONSE] - Tag: <searchResultDone>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESPONSE.ordinal()].put( new Tag( "searchResultDone", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESPONSE, Dsmlv2StatesEnum.LDAP_RESULT,
-                searchResultDoneCreation ) );
+            // Search Response is a special case
+            // ResultCode can only occur in a case of Search Result Done in a Search Response
+            if ( ldapResponse.getDecorated() instanceof SearchResponse )
+            {
+                SearchResponse searchResponse = ( SearchResponse ) ldapResponse.getDecorated();
+                ldapResult = searchResponse.getSearchResultDone().getLdapResult();
+            }
+            else
+            {
+                ldapResult = ( ( ResultResponse ) ldapResponse.getDecorated() ).getLdapResult();
+            }
 
-        //====================================================
-        //  Transitions concerning : SEARCH RESULT ENTRY
-        //====================================================
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
+            // Initialization of the Referrals if needed
+            if ( ldapResult.getReferral() == null )
+            {
+                ldapResult.setReferral( new ReferralImpl() );
+            }
 
-        // State: [SEARCH_RESULT_ENTRY] - Tag: <control>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY.ordinal()].put( new Tag( "control", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START, searchResultEntryControlCreation ) );
+            XmlPullParser xpp = container.getParser();
 
-        // State: [SEARCH_RESULT_ENTRY] - Tag: <attr>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY.ordinal()].put( new Tag( "attr", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START, searchResultEntryAddAttr ) );
+            try
+            {
+                String nextText = xpp.nextText();
 
-        // State: [SEARCH_RESULT_ENTRY] - Tag: </searchResultEntry>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY.ordinal()].put( new Tag( "searchResultEntry", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY, Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP,
-                null ) );
+                if ( !Strings.isEmpty( nextText ) )
+                {
+                    try
+                    {
+                        String urlStr = nextText.trim();
+                        LdapUrl ldapUrl = new LdapUrl( urlStr );
+                        ldapResult.getReferral().addLdapUrl( ldapUrl.toString() );
+                    }
+                    catch ( LdapURLEncodingException luee )
+                    {
+                        throw new XmlPullParserException( luee.getMessage(), xpp, luee );
+                    }
+                }
+            }
+            catch ( IOException ioe )
+            {
+                throw new XmlPullParserException( I18n.err( I18n.ERR_03008, ioe.getMessage() ), xpp, ioe );
+            }
+        }
+    };
 
-        // State: [SEARCH_RESULT_ENTRY_CONTROL_START] - Tag: <controlValue>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START.ordinal()].put(
-            new Tag( "controlValue", Tag.START ), new GrammarTransition(
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_END, searchResultEntryControlValueCreation ) );
+    /**
+     * GrammarAction that creates the Search Response
+     */
+    private final GrammarAction searchResponseCreation = new GrammarAction( "Create Search Response" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            XmlPullParser xpp = container.getParser();
+            SearchResponse searchResponse;
 
-        // State: [SEARCH_RESULT_ENTRY_CONTROL_VALUE_END] - Tag: </control>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_END.ordinal()].put( new Tag( "control",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_END,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END, null ) );
+            // Checking and adding the batchRequest's attributes
+            String attributeValue = xpp.getAttributeValue( "", "requestID" );
 
-        // State: [SEARCH_RESULT_ENTRY_CONTROL_START] - Tag: </control>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START.ordinal()].put( new Tag( "control",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END, null ) );
+            if ( attributeValue != null )
+            {
+                searchResponse = new SearchResponse(
+                    ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
+            }
+            else
+            {
+                searchResponse = new SearchResponse();
+            }
 
-        // State: [SEARCH_RESULT_ENTRY_CONTROL_END] - Tag: <control>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END.ordinal()].put( new Tag( "control",
-            Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START, searchResultEntryControlCreation ) );
+            container.getBatchResponse().addResponse( new SearchResponseDsml(
+                container.getLdapCodecService(), searchResponse ) );
+        }
+    };
 
-        // State: [SEARCH_RESULT_ENTRY_CONTROL_END] - Tag: </searchResultEntry>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END.ordinal()].put(
-            new Tag( "searchResultEntry", Tag.END ), new GrammarTransition(
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END, Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, null ) );
+    /**
+     * GrammarAction that creates a Search Result Entry
+     */
+    private final GrammarAction searchResultEntryCreation = new GrammarAction(
+        "Add Search Result Entry to Search Response" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            SearchResultEntryDsml searchResultEntry =
+                new SearchResultEntryDsml( container.getLdapCodecService(),
+                    new SearchResultEntryImpl() );
+            SearchResponseDsml searchResponse = ( SearchResponseDsml )
+                container.getBatchResponse().getCurrentResponse();
+            searchResponse.addResponse( searchResultEntry );
 
-        // State: [SEARCH_RESULT_ENTRY_CONTROL_END] - Tag: <attr>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END.ordinal()].put(
-            new Tag( "attr", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START, null ) );
+            XmlPullParser xpp = container.getParser();
 
-        // State: [SEARCH_RESULT_ENTRY_ATTR_START] - Tag: </attr>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START.ordinal()].put( new Tag( "attr", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END, null ) );
+            // Checking and adding the request's attributes
+            String attributeValue;
+            // requestID
+            attributeValue = xpp.getAttributeValue( "", "requestID" );
 
-        // State: [SEARCH_RESULT_ENTRY_ATTR_START] - Tag: <value>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START.ordinal()].put(
-            new Tag( "value", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END, searchResultEntryAddValue ) );
+            if ( attributeValue != null )
+            {
+                searchResultEntry.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
+            }
 
-        // State: [SEARCH_RESULT_ENTRY_ATTR_END] - Tag: <attr>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END.ordinal()].put( new Tag( "attr", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START, searchResultEntryAddAttr ) );
+            // dn
+            attributeValue = xpp.getAttributeValue( "", "dn" );
 
-        // State: [SEARCH_RESULT_ENTRY_ATTR_END] - Tag: </searchResultEntry>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END.ordinal()].put( new Tag( "searchResultEntry",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, null ) );
+            if ( attributeValue != null )
+            {
+                try
+                {
+                    searchResultEntry.setObjectName( new Dn( attributeValue ) );
+                }
+                catch ( LdapInvalidDnException lide )
+                {
+                    throw new XmlPullParserException( lide.getMessage(), xpp, lide );
+                }
+            }
+            else
+            {
+                throw new XmlPullParserException( "dn attribute is required", xpp, null );
+            }
+        }
+    };
 
-        // State: [SEARCH_RESULT_ENTRY_VALUE_END] - Tag: <value>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END.ordinal()].put( new Tag( "value", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END, searchResultEntryAddValue ) );
+    /**
+     * GrammarAction that creates a Search Result Reference
+     */
+    private final GrammarAction searchResultReferenceCreation = new GrammarAction(
+        "Add Search Result Reference to Search Response" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            SearchResultReferenceDsml searchResultReference =
+                new SearchResultReferenceDsml(
+                    container.getLdapCodecService(),
+                    new SearchResultReferenceImpl() );
 
-        // State: [SEARCH_RESULT_ENTRY_VALUE_END] - Tag: </attr>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END.ordinal()].put( new Tag( "attr", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END, null ) );
+            SearchResponseDsml searchResponseDsml = ( SearchResponseDsml )
+                container.getBatchResponse().getCurrentResponse();
 
-        //====================================================
-        //  Transitions concerning : SEARCH RESULT ENTRY LOOP
-        //====================================================
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP.ordinal()] = new HashMap<Tag, GrammarTransition>();
+            searchResponseDsml.addResponse( searchResultReference );
 
-        // State: [SEARCH_RESULT_ENTRY_LOOP] - Tag: <searchResultEntry>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP.ordinal()].put( new Tag( "searchResultEntry",
-            Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY,
-                searchResultEntryCreation ) );
+            XmlPullParser xpp = container.getParser();
 
-        // State: [SEARCH_RESULT_ENTRY_LOOP] - Tag: <searchResultReference>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP.ordinal()].put(
-            new Tag( "searchResultReference", Tag.START ), new GrammarTransition(
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE,
-                searchResultReferenceCreation ) );
+            // Checking and adding the request's attributes
+            String attributeValue;
+            // requestID
+            attributeValue = xpp.getAttributeValue( "", "requestID" );
 
-        // State: [SEARCH_RESULT_ENTRY_LOOP] - Tag: <searchResultDone>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP.ordinal()].put( new Tag( "searchResultDone",
-            Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, Dsmlv2StatesEnum.LDAP_RESULT,
-                searchResultDoneCreation ) );
+            if ( attributeValue != null )
+            {
+                searchResultReference.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
+            }
+        }
+    };
 
-        //====================================================
-        //  Transitions concerning : SEARCH RESULT REFERENCE
-        //====================================================
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
+    /**
+     * GrammarAction that creates a Search Result Done
+     */
+    private final GrammarAction searchResultDoneCreation = new GrammarAction(
+        "Add Search Result Done to Search Response" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            SearchResultDoneDsml searchResultDone =
+                new SearchResultDoneDsml( container.getLdapCodecService(),
+                    new SearchResultDoneImpl() );
 
-        // State: [SEARCH_RESULT_REFERENCE] - Tag: <control>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE.ordinal()].put( new Tag( "control", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE,
-                Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START, searchResultReferenceControlCreation ) );
+            SearchResponseDsml searchResponseDsml = ( SearchResponseDsml )
+                container.getBatchResponse().getCurrentResponse();
+            searchResponseDsml.addResponse( searchResultDone );
 
-        // State: [SEARCH_RESULT_REFERENCE] - Tag: <ref>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE.ordinal()].put( new Tag( "ref", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE,
-                Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END, searchResultReferenceAddRef ) );
+            XmlPullParser xpp = container.getParser();
 
-        // State: [SEARCH_RESULT_REFERENCE_CONTROL_START] - Tag: <controlValue>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START.ordinal()].put( new Tag(
-            "controlValue",
-            Tag.START ), new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START,
-            Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END, searchResultReferenceControlValueCreation ) );
+            // Checking and adding the batchRequest's attributes
+            String attributeValue;
+            // requestID
+            attributeValue = xpp.getAttributeValue( "", "requestID" );
 
-        // State: [sEARCH_RESULT_REFERENCE_CONTROL_VALUE_END] - Tag: </control>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END.ordinal()].put(
-            new Tag( "control", Tag.END ), new GrammarTransition(
-                Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END,
-                Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END, null ) );
+            if ( attributeValue != null )
+            {
+                searchResultDone.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
+            }
 
-        // State: [SEARCH_RESULT_REFERENCE_CONTROL_START] - Tag: </control>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START.ordinal()].put( new Tag( "control",
-            Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START,
-                Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END, null ) );
+            // MatchedDN
+            attributeValue = xpp.getAttributeValue( "", "matchedDN" );
 
-        // State: [SEARCH_RESULT_REFERENCE_CONTROL_END] - Tag: <control>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END.ordinal()].put( new Tag( "control",
-            Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END,
-                Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START, searchResultReferenceControlCreation ) );
+            if ( attributeValue != null )
+            {
+                try
+                {
+                    searchResultDone.getLdapResult().setMatchedDn( new Dn( attributeValue ) );
+                }
+                catch ( LdapInvalidDnException lide )
+                {
+                    throw new XmlPullParserException( lide.getMessage(), xpp, lide );
+                }
+            }
+        }
+    };
 
-        // State: [SEARCH_RESULT_REFERENCE_CONTROL_END] - Tag: <ref>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END.ordinal()].put( new Tag( "ref",
-            Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END,
-                Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END, searchResultReferenceAddRef ) );
+    /**
+     * GrammarAction that adds an Attr to a Search Result Entry
+     */
+    private final GrammarAction searchResultEntryAddAttr = new GrammarAction( "Add Attr to Search Result Entry" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            SearchResponse searchResponse = ( SearchResponse )
+                container.getBatchResponse().getCurrentResponse().getDecorated();
 
-        // State: [SEARCH_RESULT_REFERENCE_REF_END] - Tag: <ref>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END.ordinal()].put( new Tag( "ref", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END,
-                Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END, searchResultReferenceAddRef ) );
+            SearchResultEntryDsml searchResultEntry = searchResponse.getCurrentSearchResultEntry();
 
-        // State: [SEARCH_RESULT_REFERENCE_REF_END] - Tag: </searchResultReference>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END.ordinal()].put( new Tag(
-            "searchResultReference",
-            Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END,
-            Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP, null ) );
+            XmlPullParser xpp = container.getParser();
 
-        //==========================================================
-        //  Transitions concerning : SEARCH RESULT REFERENCE LOOP
-        //==========================================================
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP.ordinal()] = new HashMap<Tag, GrammarTransition>();
+            // Checking and adding the request's attributes
+            String attributeValue;
+            // name
+            attributeValue = xpp.getAttributeValue( "", "name" );
 
-        // State: [SEARCH_RESULT_REFERENCE_LOOP] - Tag: <searchResultReference>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP.ordinal()].put( new Tag(
-            "searchResultReference",
-            Tag.START ), new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP,
-            Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE, searchResultReferenceCreation ) );
+            if ( attributeValue != null )
+            {
+                try
+                {
+                    searchResultEntry.addAttribute( attributeValue );
+                }
+                catch ( LdapException le )
+                {
+                    throw new XmlPullParserException( I18n.err( I18n.ERR_03012 ), xpp, le );
+                }
+            }
+            else
+            {
+                throw new XmlPullParserException( I18n.err( I18n.ERR_03012 ), xpp, null );
+            }
+        }
+    };
+
+    /**
+     * GrammarAction that adds a Value to an Attr of a Search Result Entry
+     */
+    private final GrammarAction searchResultEntryAddValue = new GrammarAction(
+        "Add a Value to an Attr of a Search Result Entry" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            SearchResponse searchResponse = ( SearchResponse )
+                container.getBatchResponse().getCurrentResponse().getDecorated();
+            SearchResultEntryDsml searchResultEntry = searchResponse.getCurrentSearchResultEntry();
 
-        // State: [SEARCH_RESULT_REFERENCE_LOOP] - Tag: <searchResultDone>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP.ordinal()].put( new Tag( "searchResultDone",
-            Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT,
-                searchResultDoneCreation ) );
+            XmlPullParser xpp = container.getParser();
 
-        //------------------------------------------ handle SOAP envelopes --------------------------
-        super.transitions[Dsmlv2StatesEnum.SOAP_ENVELOPE_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SOAP_HEADER_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SOAP_HEADER_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SOAP_BODY_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SOAP_BODY_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
+            try
+            {
+                // We have to catch the type Attribute Value before going to the next Text node
+                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
 
-        super.transitions[Dsmlv2StatesEnum.GRAMMAR_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
+                // Getting the value
+                String nextText = xpp.nextText();
 
-        // State: [INIT_GRAMMAR_STATE] - Tag: <envelope>
-        super.transitions[Dsmlv2StatesEnum.INIT_GRAMMAR_STATE.ordinal()].put( new Tag( "envelope", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE, Dsmlv2StatesEnum.SOAP_ENVELOPE_START_TAG,
-                null ) );
+                try
+                {
+                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+                    {
+                        searchResultEntry.addAttributeValue( Base64.decode( nextText.toCharArray() ) );
+                    }
+                    else
+                    {
+                        searchResultEntry.addAttributeValue( nextText );
+                    }
+                }
+                catch ( LdapException le )
+                {
+                    throw new XmlPullParserException( le.getMessage(), xpp, le );
+                }
+            }
+            catch ( IOException ioe )
+            {
+                throw new XmlPullParserException( I18n.err( I18n.ERR_03008, ioe.getMessage() ), xpp, ioe );
+            }
+        }
+    };
 
-        // state: [SOAP_ENVELOPE_START_TAG] -> Tag: <header>
-        super.transitions[Dsmlv2StatesEnum.SOAP_ENVELOPE_START_TAG.ordinal()].put( new Tag( "header", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SOAP_ENVELOPE_START_TAG, Dsmlv2StatesEnum.SOAP_HEADER_START_TAG,
-                ParserUtils.READ_SOAP_HEADER ) );
+    /**
+     * GrammarAction that adds a Ref to a Search Result Reference
+     */
+    private final GrammarAction searchResultReferenceAddRef = new GrammarAction(
+        "Add a Ref to a Search Result Reference" )
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void action( Dsmlv2Container container ) throws XmlPullParserException
+        {
+            SearchResponse searchResponse = ( SearchResponse )
+                container.getBatchResponse().getCurrentResponse().getDecorated();
+            SearchResultReference searchResultReference = searchResponse.getCurrentSearchResultReference();
 
-        // state: [SOAP_HEADER_START_TAG] -> Tag: </header>
-        super.transitions[Dsmlv2StatesEnum.SOAP_HEADER_START_TAG.ordinal()]
-            .put( new Tag( "header", Tag.END ),
-                new GrammarTransition( Dsmlv2StatesEnum.SOAP_HEADER_START_TAG, Dsmlv2StatesEnum.SOAP_HEADER_END_TAG,
-                    null ) );
+            XmlPullParser xpp = container.getParser();
 
-        // state: [SOAP_HEADER_END_TAG] -> Tag: <body>
-        super.transitions[Dsmlv2StatesEnum.SOAP_HEADER_END_TAG.ordinal()].put( new Tag( "body", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SOAP_HEADER_END_TAG, Dsmlv2StatesEnum.SOAP_BODY_START_TAG, null ) );
+            try
+            {
+                String nextText = xpp.nextText();
 
-        // state: [SOAP_BODY_START_TAG] -> Tag: <batchResponse>
-        super.transitions[Dsmlv2StatesEnum.SOAP_BODY_START_TAG.ordinal()].put( new Tag( "batchResponse", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.SOAP_BODY_START_TAG, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
-                batchResponseCreation ) );
+                if ( !Strings.isEmpty( nextText ) )
+                {
+                    LdapUrl ldapUrl = new LdapUrl( nextText );
 
-        // the optional transition if no soap header is present
-        // state: [SOAP_ENVELOPE_START_TAG] -> Tag: <body>
-        super.transitions[Dsmlv2StatesEnum.SOAP_ENVELOPE_START_TAG.ordinal()]
-            .put( new Tag( "body", Tag.START ),
-                new GrammarTransition( Dsmlv2StatesEnum.SOAP_ENVELOPE_START_TAG, Dsmlv2StatesEnum.SOAP_BODY_START_TAG,
-                    null ) );
+                    searchResultReference.getReferral().addLdapUrl( ldapUrl.toString() );
+                }
+            }
+            catch ( IOException ioe )
+            {
+                throw new XmlPullParserException( I18n.err( I18n.ERR_03008, ioe.getMessage() ), xpp, ioe );
+            }
+            catch ( LdapURLEncodingException luee )
+            {
+                throw new XmlPullParserException( luee.getMessage(), xpp, luee );
+            }
+        }
+    };
 
-        // the below two transitions are a bit unconventional, technically the container's state is set to GRAMMAR_END
-        // when the </batchRequest> tag is encountered by the parser and the corresponding action gets executed but in
-        // a SOAP envelop we still have two more end tags(</body> and </envelope>) are left so we set those corresponding
-        // current and next transition states always to GRAMMAR_END
-        super.transitions[Dsmlv2StatesEnum.GRAMMAR_END.ordinal()].put( new Tag( "body", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.GRAMMAR_END, Dsmlv2StatesEnum.GRAMMAR_END, null ) );
+    /**
+     * GrammarAction that adds Result Code to an Extended Response
+     */
+    private final GrammarAction extendedResponseAddResultCode = ldapResultAddResultCode;
 
-        super.transitions[Dsmlv2StatesEnum.GRAMMAR_END.ordinal()].put( new Tag( "envelope", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.GRAMMAR_END, Dsmlv2StatesEnum.GRAMMAR_END, null ) );
+    /**
+     * GrammarAction that creates the Search Response
+     */
+    private final GrammarAction extendedResponseAddErrorMessage = ldapResultAddErrorMessage;
 
-        //------------------------------------------
-    }
+    /**
+     * GrammarAction that adds a Referral to an Extended Response
+     */

[... 1895 lines stripped ...]