gareth 2003/02/06 05:51:55
Modified: c/src/xercesc/internal IGXMLScanner2.cpp SGXMLScanner.cpp
c/src/xercesc/validators/datatype UnionDatatypeValidator.cpp
UnionDatatypeValidator.hpp
c/src/xercesc/validators/schema SchemaAttDef.cpp
SchemaAttDef.hpp SchemaValidator.cpp
Log:
fixed bug with multiple attributes being validated by the same union type.
Revision Changes Path
1.14 +6 -4 xml-xerces/c/src/xercesc/internal/IGXMLScanner2.cpp
Index: IGXMLScanner2.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/IGXMLScanner2.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- IGXMLScanner2.cpp 5 Feb 2003 17:08:42 -0000 1.13
+++ IGXMLScanner2.cpp 6 Feb 2003 13:51:54 -0000 1.14
@@ -384,11 +384,13 @@
// Save the type for later use
attType = attDefForWildCard->getType();
-
-
- if(fGrammarType == Grammar::SchemaGrammarType)
+ if(fGrammarType == Grammar::SchemaGrammarType) {
((SchemaElementDecl
*)(elemDecl))->updateValidityFromAttribute((SchemaAttDef *)attDef);
+ DatatypeValidator* tempDV = ((SchemaAttDef*)
attDefForWildCard)->getDatatypeValidator();
+ if(tempDV && tempDV->getType() == DatatypeValidator::Union)
+
((SchemaAttDef*)attDef)->setMembertypeValidator(((UnionDatatypeValidator
*)tempDV)->getMemberTypeValidator());
+ }
}
else {
normalizeAttValue
1.18 +4 -2 xml-xerces/c/src/xercesc/internal/SGXMLScanner.cpp
Index: SGXMLScanner.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/SGXMLScanner.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- SGXMLScanner.cpp 5 Feb 2003 17:08:42 -0000 1.17
+++ SGXMLScanner.cpp 6 Feb 2003 13:51:54 -0000 1.18
@@ -2190,12 +2190,14 @@
, elemDecl
);
}
-
// Save the type for later use
attType = attDefForWildCard->getType();
((SchemaElementDecl
*)(elemDecl))->updateValidityFromAttribute((SchemaAttDef *)attDef);
+ DatatypeValidator* tempDV = ((SchemaAttDef*)
attDefForWildCard)->getDatatypeValidator();
+ if(tempDV && tempDV->getType() == DatatypeValidator::Union)
+
((SchemaAttDef*)attDef)->setMembertypeValidator(((UnionDatatypeValidator
*)tempDV)->getMemberTypeValidator());
}
else {
normalizeAttValue
1.8 +5 -2
xml-xerces/c/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp
Index: UnionDatatypeValidator.cpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- UnionDatatypeValidator.cpp 29 Jan 2003 19:53:35 -0000 1.7
+++ UnionDatatypeValidator.cpp 6 Feb 2003 13:51:55 -0000 1.8
@@ -57,6 +57,9 @@
/*
* $Id$
* $Log$
+ * Revision 1.8 2003/02/06 13:51:55 gareth
+ * fixed bug with multiple attributes being validated by the same union type.
+ *
* Revision 1.7 2003/01/29 19:53:35 gareth
* we now store information about which validator was used to validate.
*
@@ -310,7 +313,7 @@
fMemberTypeValidators->elementAt(i)->validate(content);
memTypeValid = true;
- //set the name of the type actually used to validate the content
+ //set the validator of the type actually used to validate the
content
DatatypeValidator *dtv = fMemberTypeValidators->elementAt(i);
fValidatedDatatype = dtv;
}
1.8 +15 -1
xml-xerces/c/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp
Index: UnionDatatypeValidator.hpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- UnionDatatypeValidator.hpp 29 Jan 2003 19:55:19 -0000 1.7
+++ UnionDatatypeValidator.hpp 6 Feb 2003 13:51:55 -0000 1.8
@@ -57,6 +57,9 @@
/*
* $Id$
* $Log$
+ * Revision 1.8 2003/02/06 13:51:55 gareth
+ * fixed bug with multiple attributes being validated by the same union type.
+ *
* Revision 1.7 2003/01/29 19:55:19 gareth
* updated to deal with null pointer issue with fValidatedDatatype.
*
@@ -241,6 +244,13 @@
*/
bool getMemberTypeAnonymous() const;
+
+ /**
+ * Returns the member DatatypeValidator used to validate the content the last
time validate
+ * was called
+ */
+ const DatatypeValidator* getMemberTypeValidator() const;
+
/**
* Called inbetween uses of this validator to reset PSVI information
*/
@@ -396,6 +406,10 @@
return fValidatedDatatype->getAnonymous();
}
return 0;
+}
+
+inline const DatatypeValidator* UnionDatatypeValidator::getMemberTypeValidator()
const {
+ return fValidatedDatatype;
}
inline void UnionDatatypeValidator::reset() {
1.4 +7 -0 xml-xerces/c/src/xercesc/validators/schema/SchemaAttDef.cpp
Index: SchemaAttDef.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaAttDef.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SchemaAttDef.cpp 29 Jan 2003 19:47:16 -0000 1.3
+++ SchemaAttDef.cpp 6 Feb 2003 13:51:55 -0000 1.4
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.4 2003/02/06 13:51:55 gareth
+ * fixed bug with multiple attributes being validated by the same union type.
+ *
* Revision 1.3 2003/01/29 19:47:16 gareth
* added DOMTypeInfo and some PSVI methods
*
@@ -104,6 +107,7 @@
, fAttName(0)
, fDatatypeValidator(0)
, fAnyDatatypeValidator(0)
+ , fMemberTypeValidator(0)
, fNamespaceList(0)
, fValidity(PSVIDefs::UNKNOWN)
, fValidation(PSVIDefs::NONE)
@@ -118,6 +122,7 @@
XMLAttDef(type, defType)
, fElemId(XMLElementDecl::fgInvalidElemId)
, fDatatypeValidator(0)
+ , fMemberTypeValidator(0)
, fAnyDatatypeValidator(0)
, fNamespaceList(0)
, fValidity(PSVIDefs::UNKNOWN)
@@ -138,6 +143,7 @@
, fElemId(XMLElementDecl::fgInvalidElemId)
, fDatatypeValidator(0)
, fAnyDatatypeValidator(0)
+ , fMemberTypeValidator(0)
, fNamespaceList(0)
, fValidity(PSVIDefs::UNKNOWN)
, fValidation(PSVIDefs::NONE)
@@ -153,6 +159,7 @@
, fAttName(0)
, fDatatypeValidator(other->fDatatypeValidator)
, fAnyDatatypeValidator(other->fAnyDatatypeValidator)
+ , fMemberTypeValidator(other->fMemberTypeValidator)
, fNamespaceList(0)
, fValidity(other->fValidity)
, fValidation(other->fValidation)
1.4 +26 -21 xml-xerces/c/src/xercesc/validators/schema/SchemaAttDef.hpp
Index: SchemaAttDef.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaAttDef.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SchemaAttDef.hpp 29 Jan 2003 19:47:16 -0000 1.3
+++ SchemaAttDef.hpp 6 Feb 2003 13:51:55 -0000 1.4
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.4 2003/02/06 13:51:55 gareth
+ * fixed bug with multiple attributes being validated by the same union type.
+ *
* Revision 1.3 2003/01/29 19:47:16 gareth
* added DOMTypeInfo and some PSVI methods
*
@@ -93,7 +96,6 @@
#include <xercesc/validators/datatype/DatatypeValidator.hpp>
#include <xercesc/validators/datatype/UnionDatatypeValidator.hpp>
#include <xercesc/validators/schema/PSVIDefs.hpp>
-
XERCES_CPP_NAMESPACE_BEGIN
class DatatypeValidator;
@@ -236,6 +238,7 @@
);
void setDatatypeValidator(DatatypeValidator* newDatatypeValidator);
void setAnyDatatypeValidator(DatatypeValidator* newDatatypeValidator);
+ void setMembertypeValidator(const DatatypeValidator* newDatatypeValidator);
void setNamespaceList(const ValueVectorOf<unsigned int>* const toSet);
void resetNamespaceList();
void setValidity(PSVIDefs::Validity valid);
@@ -257,9 +260,13 @@
// fDatatypeValidator
// The DatatypeValidator used to validate this attribute type.
//
- // fAnyDatatypeValidator
+ // fAnyDatatypeValidator
// Tempory storage for the DatatypeValidator used to validate an any
//
+ // fMemberTypeValidator
+ // Tempory storage used when the validator being used is of union type.
+ // This stores the actual member validator used to validate.
+ //
// fNamespaceList
// The list of namespace values for a wildcard attribute
//
@@ -274,6 +281,7 @@
QName* fAttName;
DatatypeValidator* fDatatypeValidator;
DatatypeValidator* fAnyDatatypeValidator;
+ const DatatypeValidator* fMemberTypeValidator;
ValueVectorOf<unsigned int>* fNamespaceList;
PSVIDefs::Validity fValidity;
PSVIDefs::Validation fValidation;
@@ -341,18 +349,14 @@
inline const XMLCh* SchemaAttDef::getMemberTypeName() const {
- if(fAnyDatatypeValidator && fAnyDatatypeValidator->getType() ==
DatatypeValidator::Union)
- return
((UnionDatatypeValidator*)fAnyDatatypeValidator)->getMemberTypeName();
- else if(fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union)
- return ((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeName();
+ if(fMemberTypeValidator)
+ return fMemberTypeValidator->getTypeLocalName();
return 0;
}
inline const XMLCh* SchemaAttDef::getMemberTypeUri() const {
- if(fAnyDatatypeValidator && fAnyDatatypeValidator->getType() ==
DatatypeValidator::Union)
- return ((UnionDatatypeValidator*)fAnyDatatypeValidator)->getMemberTypeUri();
- else if(fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union)
- return ((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeUri();
+ if(fMemberTypeValidator)
+ return fMemberTypeValidator->getTypeUri();
return 0;
}
@@ -369,11 +373,9 @@
return SchemaSymbols::fgDT_ANYSIMPLETYPE;
if(getTypeAnonymous() || getMemberTypeAnonymous())
return 0;
-
- if(fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union ||
- fAnyDatatypeValidator && fAnyDatatypeValidator->getType() ==
DatatypeValidator::Union) {
+ if(fMemberTypeValidator)
return getMemberTypeName();
- }
+
return getTypeName();
}
@@ -382,8 +384,7 @@
return SchemaSymbols::fgURI_SCHEMAFORSCHEMA;
if(getTypeAnonymous() || getMemberTypeAnonymous())
return 0;
- if(fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union ||
- fAnyDatatypeValidator && fAnyDatatypeValidator->getType() ==
DatatypeValidator::Union)
+ if(fMemberTypeValidator)
return getMemberTypeUri();
return getTypeUri();
}
@@ -398,10 +399,9 @@
}
inline bool SchemaAttDef::getMemberTypeAnonymous() const {
- if(fAnyDatatypeValidator && fAnyDatatypeValidator->getType() ==
DatatypeValidator::Union)
- return
((UnionDatatypeValidator*)fAnyDatatypeValidator)->getMemberTypeAnonymous();
- else if(fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union)
- return
((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeAnonymous();
+ if(fMemberTypeValidator)
+ return fMemberTypeValidator->getAnonymous();
+
return false;
}
@@ -436,6 +436,11 @@
fAnyDatatypeValidator = newDatatypeValidator;
}
+inline void SchemaAttDef::setMembertypeValidator(const DatatypeValidator*
newDatatypeValidator)
+{
+ fMemberTypeValidator = newDatatypeValidator;
+}
+
inline void SchemaAttDef::resetNamespaceList() {
if (fNamespaceList && fNamespaceList->size()) {
@@ -464,8 +469,8 @@
((UnionDatatypeValidator *)fAnyDatatypeValidator)->reset();
else if(fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union)
((UnionDatatypeValidator *)fDatatypeValidator)->reset();
-
fAnyDatatypeValidator = 0;
+ fMemberTypeValidator = 0;
fValidity = PSVIDefs::UNKNOWN;
fValidation = PSVIDefs::NONE;
}
1.28 +7 -3 xml-xerces/c/src/xercesc/validators/schema/SchemaValidator.cpp
Index: SchemaValidator.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaValidator.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- SchemaValidator.cpp 29 Jan 2003 20:01:20 -0000 1.27
+++ SchemaValidator.cpp 6 Feb 2003 13:51:55 -0000 1.28
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.28 2003/02/06 13:51:55 gareth
+ * fixed bug with multiple attributes being validated by the same union type.
+ *
* Revision 1.27 2003/01/29 20:01:20 gareth
* We now detect when elements/attributes are validated and the result of the
validation is stored.
*
@@ -731,16 +734,17 @@
catch (...) {
emitError(XMLValid::GenericError);
((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
- ((SchemaAttDef *)(attDef))->setValidity(PSVIDefs::INVALID);
+ ((SchemaAttDef *)attDef)->setValidity(PSVIDefs::INVALID);
throw;
}
}
if(!valid) {
((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
- ((SchemaAttDef *)(attDef))->setValidity(PSVIDefs::INVALID);
+ ((SchemaAttDef *)attDef)->setValidity(PSVIDefs::INVALID);
}
-
+ else if(attDefDV && attDefDV->getType() == DatatypeValidator::Union)
+ ((SchemaAttDef *)attDef)->setMembertypeValidator(((UnionDatatypeValidator
*)attDefDV)->getMemberTypeValidator());
fTrailing = false;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]