diff --git a/src/xercesc/framework/XMLGrammarPool.hpp b/src/xercesc/framework/XMLGrammarPool.hpp
index a958a9437ec4c08f402bb48faf7caffbc26215d2..16f5d400f167bfc4e6e8b90b8613df72baf5050d 100644
--- a/src/xercesc/framework/XMLGrammarPool.hpp
+++ b/src/xercesc/framework/XMLGrammarPool.hpp
@@ -16,6 +16,9 @@
 
 /*
  * $Log$
+ * Revision 1.17  2005/04/04 15:03:14  cargilld
+ * Add support for not creating xsannotations when deserializing a grammar.
+ *
  * Revision 1.16  2005/03/03 08:02:55  dbertoni
  * Removed superfluous const qualifier.
  *
@@ -342,6 +345,19 @@ public :
     virtual void     serializeGrammars(BinOutputStream* const)  = 0; 
     virtual void     deserializeGrammars(BinInputStream* const) = 0;       
 	   
+    /*
+     * Set/get a flag to not create XSAnnotations when deserializing the grammar.
+     * Defaults to false (create XSAnnotations when deserializing the grammar).
+     */
+    inline void setIgnoreSerializedAnnotations(const bool flag)
+    {
+        fIgnoreSerializedAnnotations = flag;
+    };
+    inline bool getIgnoreSerializedAnnotations() const
+    {
+        return fIgnoreSerializedAnnotations;
+    };
+
 protected :
     // -----------------------------------------------------------------------
     /**  Hidden Constructors */
@@ -349,6 +365,7 @@ protected :
     //@{
     XMLGrammarPool(MemoryManager* const memMgr = XMLPlatformUtils::fgMemoryManager)
     :fMemMgr(memMgr)
+    ,fIgnoreSerializedAnnotations(false)
     {
     };
     //@}
@@ -371,6 +388,7 @@ private :
     // -----------------------------------------------------------------------
     
     MemoryManager* const  fMemMgr;
+    bool fIgnoreSerializedAnnotations;
 
 };
 
diff --git a/src/xercesc/internal/XTemplateSerializer.cpp b/src/xercesc/internal/XTemplateSerializer.cpp
index 7964b788c56c850dbd39776d9f38b346bafefee7..5794be1b5d5f706a3a22df677991d3ea30113e1e 100644
--- a/src/xercesc/internal/XTemplateSerializer.cpp
+++ b/src/xercesc/internal/XTemplateSerializer.cpp
@@ -17,6 +17,9 @@
 /*
  * $Id$
  * $Log$
+ * Revision 1.13  2005/04/04 15:03:14  cargilld
+ * Add support for not creating xsannotations when deserializing a grammar.
+ *
  * Revision 1.12  2005/02/19 22:26:19  cargilld
  * Store key for recreating table instead of using enclosingscope.
  *
@@ -59,6 +62,7 @@
 //  Includes
 // ---------------------------------------------------------------------------
 #include <xercesc/internal/XTemplateSerializer.hpp>
+#include <xercesc/framework/XMLGrammarPool.hpp>
 #include <xercesc/validators/common/Grammar.hpp>
 #include <xercesc/util/HashPtr.hpp>
 
@@ -1883,17 +1887,27 @@ void XTemplateSerializer::loadObject(RefHashTableOf<XSAnnotation>** objToLoad
         int itemNumber = 0;
         serEng>>itemNumber;
 
-        for (int itemIndex = 0; itemIndex < itemNumber; itemIndex++)
-        {
-            XSerializeEngine::XSerializedObjectId_t keyId = 0;
-
-            serEng>>keyId;
-
-            void* key = serEng.lookupLoadPool(keyId);
-            XSAnnotation*  data;
-            serEng>>data;
-
-            (*objToLoad)->put(key, data);
+        int itemIndex;
+        XSerializeEngine::XSerializedObjectId_t keyId;
+        void* key;
+        XSAnnotation*  data;
+        if (!serEng.fGrammarPool->getIgnoreSerializedAnnotations()) {
+            for (itemIndex = 0; itemIndex < itemNumber; itemIndex++)
+            {
+                serEng>>keyId;
+                key = serEng.lookupLoadPool(keyId);                
+                serEng>>data;                       
+                (*objToLoad)->put(key, data);                   
+            }
+        }
+        else {
+            for (itemIndex = 0; itemIndex < itemNumber; itemIndex++)
+            {
+                serEng>>keyId;
+                key = serEng.lookupLoadPool(keyId);                
+                serEng>>data;                            
+                delete data;
+            }
         }
     }
 }