diff --git a/src/xercesc/framework/ValidationContext.hpp b/src/xercesc/framework/ValidationContext.hpp
index 748fc3e7d7f70869ab47dcb6dfe72a74a80fe985..8dab517423988d9676819fdfcac2c0247dafbf4d 100644
--- a/src/xercesc/framework/ValidationContext.hpp
+++ b/src/xercesc/framework/ValidationContext.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.2  2003/11/24 05:10:26  neilg
+ * implement method for determining member type of union that validated some value
+ *
  * Revision 1.1  2003/11/12 20:28:16  peiyongz
  * Stateless Grammar: ValidationContext
  *
@@ -75,6 +78,7 @@ XERCES_CPP_NAMESPACE_BEGIN
 
 class XMLRefInfo;
 class DTDEntityDecl;
+class DatatypeValidator;
 
 class XMLPARSER_EXPORT ValidationContext : public XMemory
 {
@@ -122,6 +126,14 @@ public :
            
     virtual void                             checkEntity(const XMLCh * const ) const = 0 ;
 
+    /**
+      * Union datatype handling
+      *
+      */
+
+    virtual DatatypeValidator * getValidatingMemberType() const = 0 ;
+    virtual void setValidatingMemberType(DatatypeValidator * validatingMemberType) = 0 ;
+
     //@}
 
    
@@ -158,3 +170,4 @@ private :
 XERCES_CPP_NAMESPACE_END
 
 #endif
+
diff --git a/src/xercesc/internal/ValidationContextImpl.cpp b/src/xercesc/internal/ValidationContextImpl.cpp
index d5714c74bc64a107641ee4e552aecc4f77407a0c..34f3177f234940b3c8f05c3ee73bea29c9454a5d 100644
--- a/src/xercesc/internal/ValidationContextImpl.cpp
+++ b/src/xercesc/internal/ValidationContextImpl.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.2  2003/11/24 05:10:26  neilg
+ * implement method for determining member type of union that validated some value
+ *
  * Revision 1.1  2003/11/12 20:29:47  peiyongz
  * Stateless Grammar: ValidationContext
  *
@@ -88,6 +91,7 @@ ValidationContextImpl::ValidationContextImpl(MemoryManager* const manager)
 ,fIdRefList(0)
 ,fEntityDeclPool(0)
 ,fToCheckIdRefList(true)
+,fValidatingMemberType(0)
 {
     fIdRefList = new (fMemoryManager) RefHashTableOf<XMLRefInfo>(109, fMemoryManager);
 }
diff --git a/src/xercesc/internal/ValidationContextImpl.hpp b/src/xercesc/internal/ValidationContextImpl.hpp
index 87dbbeaf2f28a2c462dcd11321f596ece463ccd0..81a5b5ed771fbb864f812d455fc63f3eb7a3dbf0 100644
--- a/src/xercesc/internal/ValidationContextImpl.hpp
+++ b/src/xercesc/internal/ValidationContextImpl.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.2  2003/11/24 05:10:26  neilg
+ * implement method for determining member type of union that validated some value
+ *
  * Revision 1.1  2003/11/12 20:29:47  peiyongz
  * Stateless Grammar: ValidationContext
  *
@@ -119,6 +122,15 @@ public :
            
     virtual void                             checkEntity(const XMLCh * const ) const;
 
+
+    /**
+      * Union datatype handling
+      *
+      */
+
+    virtual DatatypeValidator * getValidatingMemberType() const;
+    virtual void setValidatingMemberType(DatatypeValidator * validatingMemberType) ;
+
     //@}
   
 private:
@@ -143,14 +155,34 @@ private:
     //      default entities (such as &gt; &lt; ...) defined by the XML Standard.
     //
     //  fToAddToList
+    //  fValidatingMemberType
+    //      The member type in a union that actually
+    //      validated some text.  Note that the validationContext does not
+    //      own this object, and the value of getValidatingMemberType
+    //      will not be accurate unless the type of the most recently-validated
+    //      element/attribute is in fact a union datatype.
     // -----------------------------------------------------------------------
 
     RefHashTableOf<XMLRefInfo>*         fIdRefList;
     const NameIdPool<DTDEntityDecl>*    fEntityDeclPool;
     bool                                fToCheckIdRefList;
+    DatatypeValidator *                 fValidatingMemberType;
 
 };
 
+
+
+inline DatatypeValidator * ValidationContextImpl::getValidatingMemberType() const
+{
+    return fValidatingMemberType;
+}
+
+inline void ValidationContextImpl::setValidatingMemberType(DatatypeValidator * validatingMemberType) 
+{
+    fValidatingMemberType = validatingMemberType;
+}
+
 XERCES_CPP_NAMESPACE_END
 
 #endif
+
diff --git a/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp b/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp
index 4883ff4314455fc3feaf9ccc4f8649f22babb68c..888df3a412e1c6fb58fdc9990d74b1ddff11125b 100644
--- a/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp
+++ b/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp
@@ -57,6 +57,9 @@
 /*
  * $Id$
  * $Log$
+ * Revision 1.18  2003/11/24 05:10:26  neilg
+ * implement method for determining member type of union that validated some value
+ *
  * Revision 1.17  2003/11/13 23:19:18  peiyongz
  * initSize
  *
@@ -138,9 +141,8 @@
 
 XERCES_CPP_NAMESPACE_BEGIN
 
-static const int BUF_LEN = 64;
+static const unsigned int BUF_LEN = 64;
 static XMLCh value1[BUF_LEN+1];
-static XMLCh value2[BUF_LEN+1];
 
 // ---------------------------------------------------------------------------
 //  Constructors and Destructor
@@ -360,6 +362,9 @@ void UnionDatatypeValidator::checkContent(const XMLCh*             const content
                 //set the validator of the type actually used to validate the content
                 DatatypeValidator *dtv = fMemberTypeValidators->elementAt(i);
                 fValidatedDatatype = dtv;
+                // context will be null during schema construction
+                if(context)
+                    context->setValidatingMemberType(dtv);
             }
             catch (XMLException&)
             {
diff --git a/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp b/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp
index 3174071a0b188183c8b06d1f9cc7c391e6f0b320..e10a7152f7476e4f5dd25878e3e8c2088ec459d1 100644
--- a/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp
+++ b/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp
@@ -57,6 +57,9 @@
 /*
  * $Id$
  * $Log$
+ * Revision 1.13  2003/11/24 05:10:26  neilg
+ * implement method for determining member type of union that validated some value
+ *
  * Revision 1.12  2003/11/12 20:32:03  peiyongz
  * Statless Grammar: ValidationContext
  *
@@ -462,3 +465,4 @@ XERCES_CPP_NAMESPACE_END
 /**
   * End of file UnionDatatypeValidator.hpp
   */
+