diff --git a/src/xercesc/internal/IGXMLScanner.cpp b/src/xercesc/internal/IGXMLScanner.cpp
index 4ffa16380a2f23d45e0e8dd250e65835fdf0b7cf..072a00026c0d3f7503445d604850afc2fc49dc95 100644
--- a/src/xercesc/internal/IGXMLScanner.cpp
+++ b/src/xercesc/internal/IGXMLScanner.cpp
@@ -1194,6 +1194,9 @@ void IGXMLScanner::scanEndTag(bool& gotData)
             endElementPSVI(
                 (SchemaElementDecl*)topElem->fThisElement, psviMemberType);
         }
+        // now we can reset the datatype buffer, since the 
+        // application has had a chance to copy the characters somewhere else
+        ((SchemaValidator *)fValidator)->clearDatatypeBuffer();
     }
 
     // If we have a doc handler, tell it about the end tag
diff --git a/src/xercesc/internal/SGXMLScanner.cpp b/src/xercesc/internal/SGXMLScanner.cpp
index 1aac881118fff900119e6f97b54b65f4d313873b..e1e941ae57f6c45baca1b1ba99dc56df3ed17c4c 100644
--- a/src/xercesc/internal/SGXMLScanner.cpp
+++ b/src/xercesc/internal/SGXMLScanner.cpp
@@ -1102,6 +1102,9 @@ void SGXMLScanner::scanEndTag(bool& gotData)
             (SchemaElementDecl*)topElem->fThisElement, psviMemberType
         );
     }
+    // now we can reset the datatype buffer, since the 
+    // application has had a chance to copy the characters somewhere else
+    ((SchemaValidator *)fValidator)->clearDatatypeBuffer();
 
     // If we have a doc handler, tell it about the end tag
     if (fDocHandler)
diff --git a/src/xercesc/validators/schema/SchemaValidator.cpp b/src/xercesc/validators/schema/SchemaValidator.cpp
index 3f403920c1efdd8fa8dc47dd5b8f90c51d408e3b..d9dae74f1b13d337b48348217f7f7bf8b6db3108 100644
--- a/src/xercesc/validators/schema/SchemaValidator.cpp
+++ b/src/xercesc/validators/schema/SchemaValidator.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.47  2003/12/03 20:00:27  neilg
+ * PSVI fix:  cannot allow validator to reset its element content buffer before exposing it to the application
+ *
  * Revision 1.46  2003/11/27 22:52:37  knoaman
  * PSVIElement implementation
  *
@@ -541,7 +544,8 @@ int SchemaValidator::checkContent (XMLElementDecl* const elemDecl
         ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMType);
     }
 
-    fDatatypeBuffer.reset();
+    // must rely on scanner to clear fDatatypeBuffer
+    // since it may need to query its contents after this method completes
     fNil = false;
     fTrailing=false;
 
diff --git a/src/xercesc/validators/schema/SchemaValidator.hpp b/src/xercesc/validators/schema/SchemaValidator.hpp
index ad85d7589e47344467ed00f2dc9954dc64675df2..9ec5981460264cd1afc212f8bd97b04bf206f84a 100644
--- a/src/xercesc/validators/schema/SchemaValidator.hpp
+++ b/src/xercesc/validators/schema/SchemaValidator.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.24  2003/12/03 20:00:27  neilg
+ * PSVI fix:  cannot allow validator to reset its element content buffer before exposing it to the application
+ *
  * Revision 1.23  2003/11/28 21:18:32  knoaman
  * Make use of canonical representation in PSVIElement
  *
@@ -266,6 +269,7 @@ public:
     void setErrorReporter(XMLErrorReporter* const errorReporter);
     void setExitOnFirstFatal(const bool newValue);
     void setDatatypeBuffer(const XMLCh* const value);
+    void clearDatatypeBuffer();
 
     // -----------------------------------------------------------------------
     //  Getter methods
@@ -461,6 +465,11 @@ inline void SchemaValidator::setDatatypeBuffer(const XMLCh* const value)
     fDatatypeBuffer.append(value);
 }
 
+inline void SchemaValidator::clearDatatypeBuffer()
+{
+    fDatatypeBuffer.reset();
+}
+
 // ---------------------------------------------------------------------------
 //  SchemaValidator: Getter methods
 // ---------------------------------------------------------------------------