peiyongz 2004/09/13 14:22:42
Modified: c/src/xercesc/framework/psvi PSVIItem.hpp PSVIItem.cpp
Log:
new method: getActualValue()
Revision Changes Path
1.10 +13 -0 xml-xerces/c/src/xercesc/framework/psvi/PSVIItem.hpp
Index: PSVIItem.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/PSVIItem.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- PSVIItem.hpp 8 Sep 2004 13:56:07 -0000 1.9
+++ PSVIItem.hpp 13 Sep 2004 21:22:42 -0000 1.10
@@ -16,6 +16,9 @@
/*
* $Log$
+ * Revision 1.10 2004/09/13 21:22:42 peiyongz
+ * new method: getActualValue()
+ *
* Revision 1.9 2004/09/08 13:56:07 peiyongz
* Apache License Version 2.0
*
@@ -64,6 +67,7 @@
// forward declarations
class XSTypeDefinition;
class XSSimpleTypeDefinition;
+class XSValue;
class XMLPARSER_EXPORT PSVIItem : public XMemory
{
@@ -218,6 +222,15 @@
const XMLCh *getCanonicalRepresentation() const;
//@}
+
+ /**
+ *
+ * Get actual value in the form of XSValue,
+ * caller needs to delete the object returned.
+ *
+ * @return an XSValue
+ */
+ virtual XSValue *getActualValue() const;
//----------------------------------
/** methods needed by implementation */
1.7 +81 -0 xml-xerces/c/src/xercesc/framework/psvi/PSVIItem.cpp
Index: PSVIItem.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/PSVIItem.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- PSVIItem.cpp 8 Sep 2004 13:56:07 -0000 1.6
+++ PSVIItem.cpp 13 Sep 2004 21:22:42 -0000 1.7
@@ -16,6 +16,9 @@
/*
* $Log$
+ * Revision 1.7 2004/09/13 21:22:42 peiyongz
+ * new method: getActualValue()
+ *
* Revision 1.6 2004/09/08 13:56:07 peiyongz
* Apache License Version 2.0
*
@@ -39,6 +42,9 @@
*/
#include <xercesc/framework/psvi/PSVIItem.hpp>
+#include <xercesc/framework/psvi/XSValue.hpp>
+#include <xercesc/framework/psvi/XSComplexTypeDefinition.hpp>
+#include <xercesc/validators/datatype/DatatypeValidatorFactory.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -80,6 +86,81 @@
void PSVIItem::setValidity(PSVIItem::VALIDITY_STATE validity)
{
fValidityState = validity;
+}
+
+XSValue* PSVIItem::getActualValue() const
+{
+ /***
+ * assessment
+ * VALIDATION_PARTIAL
+ * VALIDATION_FULL
+ * validity
+ * VALIDITY_INVALID
+ * VALIDITY_VALID
+ ***/
+ if ((fAssessmentType==VALIDATION_NONE) || (fValidityState==VALIDITY_NOTKNOWN))
+ return 0;
+
+ /***
+ * XSSimpleType or
+ * XSComplexType's CONTENTTYPE_SIMPLE
+ * allowed
+ ***/
+ if ((!fType) ||
+ ((fType->getTypeCategory() == XSTypeDefinition::COMPLEX_TYPE) &&
+ (((XSComplexTypeDefinition*)fType)->getContentType() !=
XSComplexTypeDefinition::CONTENTTYPE_SIMPLE)))
+ return 0;
+
+ /***
+ * Resolve dv
+ *
+ * 1. If fMemberType is not null, use the fMemberType->fDataTypeValidator
+ * 2. If fType is XSSimpleType, use fType->fDataTypeValidator
+ * 3. If fType is XSComplexType, use fType->fXSSimpleTypeDefinition->
fDataTypeValidator
+ *
+ ***/
+
+ DatatypeValidator *dv = 0;
+
+ if (fMemberType)
+ {
+ /***
+ * Now that fType is either XSSimpleTypeDefinition or
+ * XSComlextTypeDefinition with CONTENTTYPE_SIMPLE, the
+ * fMemberType must be XSSimpleTypeDefinition if present
+ ***/
+ dv=((XSSimpleTypeDefinition*) fMemberType)->getDatatypeValidator();
+ }
+ else if (fType->getTypeCategory() == XSTypeDefinition::SIMPLE_TYPE)
+ {
+ dv=((XSSimpleTypeDefinition*) fType)->getDatatypeValidator();
+ }
+ else
+ {
+ XSSimpleTypeDefinition* simType =
((XSComplexTypeDefinition*)fType)->getSimpleType();
+ if (simType)
+ dv = simType->getDatatypeValidator();
+ }
+
+ if (!dv) return 0;
+
+ /***
+ * Get the ultimate base dv in the datatype registry
+ ***/
+ DatatypeValidator *basedv =
DatatypeValidatorFactory::getBuiltInBaseValidator(dv);
+
+ if (!basedv) return 0;
+
+ XSValue::Status status=XSValue::st_Init;
+
+ return XSValue::getActualValue(fNormalizedValue
+ , XSValue::getDataType(basedv->getTypeLocalName())
+ , status
+ , XSValue::ver_10
+ , false
+ , fMemoryManager);
+
+
}
XERCES_CPP_NAMESPACE_END
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]