gareth 2003/01/29 11:47:17
Modified: c/src/xercesc/validators/schema SchemaAttDef.cpp
SchemaAttDef.hpp SchemaElementDecl.cpp
SchemaElementDecl.hpp
Log:
added DOMTypeInfo and some PSVI methods
Revision Changes Path
1.3 +15 -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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SchemaAttDef.cpp 4 Nov 2002 14:49:41 -0000 1.2
+++ SchemaAttDef.cpp 29 Jan 2003 19:47:16 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2003/01/29 19:47:16 gareth
+ * added DOMTypeInfo and some PSVI methods
+ *
* Revision 1.2 2002/11/04 14:49:41 tng
* C++ Namespace Support.
*
@@ -100,7 +103,10 @@
fElemId(XMLElementDecl::fgInvalidElemId)
, fAttName(0)
, fDatatypeValidator(0)
+ , fAnyDatatypeValidator(0)
, fNamespaceList(0)
+ , fValidity(PSVIDefs::UNKNOWN)
+ , fValidation(PSVIDefs::NONE)
{
}
@@ -112,7 +118,10 @@
XMLAttDef(type, defType)
, fElemId(XMLElementDecl::fgInvalidElemId)
, fDatatypeValidator(0)
+ , fAnyDatatypeValidator(0)
, fNamespaceList(0)
+ , fValidity(PSVIDefs::UNKNOWN)
+ , fValidation(PSVIDefs::NONE)
{
fAttName = new QName(prefix, localPart, uriId);
}
@@ -128,7 +137,10 @@
XMLAttDef(attValue, type, defType, enumValues)
, fElemId(XMLElementDecl::fgInvalidElemId)
, fDatatypeValidator(0)
+ , fAnyDatatypeValidator(0)
, fNamespaceList(0)
+ , fValidity(PSVIDefs::UNKNOWN)
+ , fValidation(PSVIDefs::NONE)
{
fAttName = new QName(prefix, localPart, uriId);
}
@@ -140,7 +152,10 @@
, fElemId(XMLElementDecl::fgInvalidElemId)
, fAttName(0)
, fDatatypeValidator(other->fDatatypeValidator)
+ , fAnyDatatypeValidator(other->fAnyDatatypeValidator)
, fNamespaceList(0)
+ , fValidity(other->fValidity)
+ , fValidation(other->fValidation)
{
QName* otherName = other->getAttName();
fAttName = new QName(otherName->getPrefix(),
1.3 +225 -2 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SchemaAttDef.hpp 4 Nov 2002 14:49:41 -0000 1.2
+++ SchemaAttDef.hpp 29 Jan 2003 19:47:16 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2003/01/29 19:47:16 gareth
+ * added DOMTypeInfo and some PSVI methods
+ *
* Revision 1.2 2002/11/04 14:49:41 tng
* C++ Namespace Support.
*
@@ -87,6 +90,9 @@
#include <xercesc/util/XMLString.hpp>
#include <xercesc/framework/XMLAttDef.hpp>
#include <xercesc/util/ValueVectorOf.hpp>
+#include <xercesc/validators/datatype/DatatypeValidator.hpp>
+#include <xercesc/validators/datatype/UnionDatatypeValidator.hpp>
+#include <xercesc/validators/schema/PSVIDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -101,7 +107,6 @@
class VALIDATORS_EXPORT SchemaAttDef : public XMLAttDef
{
public :
-
// -----------------------------------------------------------------------
// Constructors and Destructors
// -----------------------------------------------------------------------
@@ -134,7 +139,82 @@
// Implementation of the XMLAttDef interface
// -----------------------------------------------------------------------
virtual const XMLCh* getFullName() const;
+ virtual void reset();
+
+ // ----------------------------------------------------------------------
+ // Partial implementation of PSVI
+ // The values these methods return are only accurate until the DOMAttr
+ // is created that uses the values. After this a celan up method is called
+ // and the SchemaAttDef may be used again.
+ // note that some of this information has dependancies. For example,
+ // if something is not valid then the information returned by the other
+ // calls may be meaningless
+ // See http://www.w3.org/TR/xmlschema-1/ for detailed information
+ // ----------------------------------------------------------------------
+
+ /**
+ * The appropriate case among the following:
+ * 1 If it was strictly assessed, then the appropriate case among the following:
+ * 1.1 If it was valid as defined by Attribute Locally Valid (3.2.4), then
valid;
+ * 1.2 otherwise invalid.
+ * 2 otherwise notKnown.
+ */
+ PSVIDefs::Validity getValidity() const;
+
+ /**
+ * The appropriate case among the following:
+ * 1 If it was strictly assessed, then full;
+ * 2 otherwise none.
+ */
+ PSVIDefs::Validation getValidationAttempted() const;
+
+ /**
+ * @return the complexity. Always simple for attrs
+ */
+ PSVIDefs::Complexity getTypeType() const;
+
+ /**
+ * The target namespace of the type definition.
+ */
+ const XMLCh* getTypeUri() const;
+
+ /**
+ * The {name} of the type definition, if it is not absent.
+ */
+ const XMLCh* getTypeName() const;
+
+ /**
+ * true if the {name} of the type definition is absent, otherwise false.
+ */
+ bool getTypeAnonymous() const;
+
+ /**
+ * If this method returns true and validity is VALID then the next three
+ * produce accurate results
+ * @return true if the element is validated using a union type
+ */
+ bool isTypeDefinitionUnion() const;
+
+ /**
+ * The {target namespace} of the actual member type definition.
+ */
+ const XMLCh* getMemberTypeUri() const;
+
+ /**
+ * @return true if the {name} of the actual member type definition is absent,
otherwise false.
+ */
+ bool getMemberTypeAnonymous() const;
+
+ /**
+ * @return the {name} of the actual member type definition, if it is not
absent.
+ */
+ const XMLCh* getMemberTypeName() const;
+
+ virtual const XMLCh* getDOMTypeInfoUri() const;
+ virtual const XMLCh* getDOMTypeInfoName() const;
+
+
// -----------------------------------------------------------------------
// Getter methods
@@ -155,9 +235,11 @@
,const int uriId = -1
);
void setDatatypeValidator(DatatypeValidator* newDatatypeValidator);
+ void setAnyDatatypeValidator(DatatypeValidator* newDatatypeValidator);
void setNamespaceList(const ValueVectorOf<unsigned int>* const toSet);
void resetNamespaceList();
-
+ void setValidity(PSVIDefs::Validity valid);
+ void setValidationAttempted(PSVIDefs::Validation validation);
private :
// -----------------------------------------------------------------------
@@ -175,14 +257,26 @@
// fDatatypeValidator
// The DatatypeValidator used to validate this attribute type.
//
+ // fAnyDatatypeValidator
+ // Tempory storage for the DatatypeValidator used to validate an any
+ //
// fNamespaceList
// The list of namespace values for a wildcard attribute
//
+ // fValidity
+ // After this attr has been validated this is its validity
+ //
+ // fValidation
+ // The type of validation that happened to this attr
+ //
// -----------------------------------------------------------------------
unsigned int fElemId;
QName* fAttName;
DatatypeValidator* fDatatypeValidator;
+ DatatypeValidator* fAnyDatatypeValidator;
ValueVectorOf<unsigned int>* fNamespaceList;
+ PSVIDefs::Validity fValidity;
+ PSVIDefs::Validation fValidation;
};
@@ -205,6 +299,119 @@
return fDatatypeValidator;
}
+inline void SchemaAttDef::setValidity(PSVIDefs::Validity valid) {
+ fValidity = valid;
+}
+
+inline void SchemaAttDef::setValidationAttempted(PSVIDefs::Validation validation) {
+ fValidation = validation;
+}
+
+
+inline const XMLCh* SchemaAttDef::getTypeName() const {
+ if(fAnyDatatypeValidator)
+ return fAnyDatatypeValidator->getTypeLocalName();
+ else if(fDatatypeValidator)
+ return fDatatypeValidator->getTypeLocalName();
+
+ //its anySimpleType if we have not done validation on it
+ if(getValidationAttempted() == PSVIDefs::NONE)
+ return SchemaSymbols::fgDT_ANYSIMPLETYPE;
+
+
+ return 0;
+}
+
+inline PSVIDefs::Complexity SchemaAttDef::getTypeType() const {
+ return PSVIDefs::SIMPLE;
+}
+
+inline const XMLCh* SchemaAttDef::getTypeUri() const {
+ if(fAnyDatatypeValidator)
+ return fAnyDatatypeValidator->getTypeUri();
+ else if(fDatatypeValidator)
+ return fDatatypeValidator->getTypeUri();
+
+ //its anySimpleType if we have not done validation on it
+ if(getValidationAttempted() == PSVIDefs::NONE)
+ return SchemaSymbols::fgURI_SCHEMAFORSCHEMA;
+
+ return 0;
+}
+
+
+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();
+ 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();
+ return 0;
+}
+
+inline PSVIDefs::Validity SchemaAttDef::getValidity() const {
+ return fValidity;
+}
+
+inline PSVIDefs::Validation SchemaAttDef::getValidationAttempted() const {
+ return fValidation;
+}
+
+inline const XMLCh* SchemaAttDef::getDOMTypeInfoName() const {
+ if(fValidity != PSVIDefs::VALID)
+ return SchemaSymbols::fgDT_ANYSIMPLETYPE;
+ if(getTypeAnonymous() || getMemberTypeAnonymous())
+ return 0;
+
+ if(fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union ||
+ fAnyDatatypeValidator && fAnyDatatypeValidator->getType() ==
DatatypeValidator::Union) {
+ return getMemberTypeName();
+ }
+ return getTypeName();
+}
+
+inline const XMLCh* SchemaAttDef::getDOMTypeInfoUri() const {
+ if(fValidity != PSVIDefs::VALID)
+ return SchemaSymbols::fgURI_SCHEMAFORSCHEMA;
+ if(getTypeAnonymous() || getMemberTypeAnonymous())
+ return 0;
+ if(fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union ||
+ fAnyDatatypeValidator && fAnyDatatypeValidator->getType() ==
DatatypeValidator::Union)
+ return getMemberTypeUri();
+ return getTypeUri();
+}
+
+inline bool SchemaAttDef::getTypeAnonymous() const {
+ if(fAnyDatatypeValidator)
+ return fAnyDatatypeValidator->getAnonymous();
+ else if(fDatatypeValidator)
+ return fDatatypeValidator->getAnonymous();
+
+ return false;
+}
+
+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();
+ return false;
+}
+
+inline bool SchemaAttDef::isTypeDefinitionUnion() const {
+ if(fAnyDatatypeValidator && fAnyDatatypeValidator->getType() ==
DatatypeValidator::Union ||
+ fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union)
+ return true;
+ return false;
+}
+
inline ValueVectorOf<unsigned int>*
SchemaAttDef::getNamespaceList() const {
return fNamespaceList;
@@ -224,6 +431,11 @@
fDatatypeValidator = newDatatypeValidator;
}
+inline void SchemaAttDef::setAnyDatatypeValidator(DatatypeValidator*
newDatatypeValidator)
+{
+ fAnyDatatypeValidator = newDatatypeValidator;
+}
+
inline void SchemaAttDef::resetNamespaceList() {
if (fNamespaceList && fNamespaceList->size()) {
@@ -245,6 +457,17 @@
else {
resetNamespaceList();
}
+}
+
+inline void SchemaAttDef::reset() {
+ if(fAnyDatatypeValidator && fAnyDatatypeValidator->getType() ==
DatatypeValidator::Union)
+ ((UnionDatatypeValidator *)fAnyDatatypeValidator)->reset();
+ else if(fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union)
+ ((UnionDatatypeValidator *)fDatatypeValidator)->reset();
+
+ fAnyDatatypeValidator = 0;
+ fValidity = PSVIDefs::UNKNOWN;
+ fValidation = PSVIDefs::NONE;
}
XERCES_CPP_NAMESPACE_END
1.7 +21 -0 xml-xerces/c/src/xercesc/validators/schema/SchemaElementDecl.cpp
Index: SchemaElementDecl.cpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaElementDecl.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SchemaElementDecl.cpp 4 Nov 2002 14:49:41 -0000 1.6
+++ SchemaElementDecl.cpp 29 Jan 2003 19:47:16 -0000 1.7
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.7 2003/01/29 19:47:16 gareth
+ * added DOMTypeInfo and some PSVI methods
+ *
* Revision 1.6 2002/11/04 14:49:41 tng
* C++ Namespace Support.
*
@@ -159,10 +162,16 @@
, fDefaultValue(0)
, fComplexTypeInfo(0)
, fXsiComplexTypeInfo(0)
+ , fXsiSimpleTypeInfo(0)
, fAttDefs(0)
, fIdentityConstraints(0)
, fAttWildCard(0)
, fSubstitutionGroupElem(0)
+ , fValidity(PSVIDefs::UNKNOWN)
+ , fValidation(PSVIDefs::NONE)
+ , fSeenValidation(false)
+ , fSeenNoValidation(false)
+ , fHadContent(false)
{
}
@@ -181,10 +190,16 @@
, fDefaultValue(0)
, fComplexTypeInfo(0)
, fXsiComplexTypeInfo(0)
+ , fXsiSimpleTypeInfo(0)
, fAttDefs(0)
, fIdentityConstraints(0)
, fAttWildCard(0)
, fSubstitutionGroupElem(0)
+ , fValidity(PSVIDefs::UNKNOWN)
+ , fValidation(PSVIDefs::NONE)
+ , fSeenValidation(false)
+ , fSeenNoValidation(false)
+ , fHadContent(false)
{
setElementName(prefix, localPart, uriId);
}
@@ -202,10 +217,16 @@
, fDefaultValue(0)
, fComplexTypeInfo(0)
, fXsiComplexTypeInfo(0)
+ , fXsiSimpleTypeInfo(0)
, fAttDefs(0)
, fIdentityConstraints(0)
, fAttWildCard(0)
, fSubstitutionGroupElem(0)
+ , fValidity(PSVIDefs::UNKNOWN)
+ , fValidation(PSVIDefs::NONE)
+ , fSeenValidation(false)
+ , fSeenNoValidation(false)
+ , fHadContent(false)
{
setElementName(elementName);
}
1.8 +349 -1 xml-xerces/c/src/xercesc/validators/schema/SchemaElementDecl.hpp
Index: SchemaElementDecl.hpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaElementDecl.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SchemaElementDecl.hpp 4 Nov 2002 14:49:41 -0000 1.7
+++ SchemaElementDecl.hpp 29 Jan 2003 19:47:16 -0000 1.8
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.8 2003/01/29 19:47:16 gareth
+ * added DOMTypeInfo and some PSVI methods
+ *
* Revision 1.7 2002/11/04 14:49:41 tng
* C++ Namespace Support.
*
@@ -136,12 +139,14 @@
#include <xercesc/validators/common/Grammar.hpp>
#include <xercesc/validators/schema/ComplexTypeInfo.hpp>
#include <xercesc/validators/schema/identity/IdentityConstraint.hpp>
+#include <xercesc/validators/datatype/DatatypeValidator.hpp>
+#include <xercesc/validators/datatype/UnionDatatypeValidator.hpp>
+#include <xercesc/validators/schema/PSVIDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class ContentSpecNode;
class SchemaAttDefList;
-class DatatypeValidator;
//
// This class is a derivative of the basic element decl. This one implements
@@ -150,6 +155,7 @@
class VALIDATORS_EXPORT SchemaElementDecl : public XMLElementDecl
{
public :
+
// -----------------------------------------------------------------------
// Class specific types
//
@@ -237,6 +243,89 @@
SchemaElementDecl* getSubstitutionGroupElem() const;
+ // ----------------------------------------------------------------------
+ // Partial implementation of PSVI
+ // The values these methods return are only accurate until the cleanUp method
+ // is called (in the end tag part of the scanner you are using)
+ // note that some of this information has dependancies. For example,
+ // if something is not valid then the information returned by the other
+ // calls may be meaningless
+ // See http://www.w3.org/TR/xmlschema-1/ for detailed information
+ // ----------------------------------------------------------------------
+
+
+ /**
+ * The appropriate case among the following:
+ * 1 If it was strictly assessed, then the appropriate case among the following:
+ * 1.1 If all of the following are true
+ * 1.1.1
+ * 1.1.1.1 clause 1.1 of Schema-Validity Assessment (Element) (3.3.4)
applied and the item was valid as defined by Element Locally Valid (Element) (3.3.4);
+ * 1.1.1.2 clause 1.2 of Schema-Validity Assessment (Element) (3.3.4)
applied and the item was valid as defined by Element Locally Valid (Type) (3.3.4).
+ * 1.1.2 Neither its [children] nor its [attributes] contains an information
item (element or attribute respectively) whose [validity] is invalid.
+ * 1.1.3 Neither its [children] nor its [attributes] contains an information
item (element or attribute respectively) with a context-determined declaration of
mustFind whose [validity] is unknown.
+ , then valid;
+ * 1.2 otherwise invalid.
+ * 2 otherwise notKnown.
+ */
+ PSVIDefs::Validity getValidity() const;
+
+
+ /**
+ * The appropriate case among the following:
+ * 1 If it was strictly assessed and neither its [children] nor its
[attributes] contains an information item (element or attribute respectively) whose
[validation attempted] is not full, then full;
+ * 2 If it was not strictly assessed and neither its [children] nor its
[attributes] contains an information item (element or attribute respectively) whose
[validation attempted] is not none, then none;
+ *3 otherwise partial.
+ */
+ PSVIDefs::Validation getValidationAttempted() const;
+
+
+ /**
+ * @return the complexity. simple or complex, depending on the type definition.
+ */
+ PSVIDefs::Complexity getTypeType() const;
+
+ /**
+ * The target namespace of the type definition.
+ */
+ const XMLCh* getTypeUri() const;
+
+ /**
+ * The {name} of the type definition, if it is not absent.
+ */
+ const XMLCh* getTypeName() const;
+
+ /**
+ * true if the {name} of the type definition is absent, otherwise false.
+ */
+ bool getTypeAnonymous() const;
+
+ /**
+ * If this method returns true and validity is VALID then the next three
+ * produce accurate results
+ * @return true if the element is validated using a union type
+ */
+ bool isTypeDefinitionUnion() const;
+
+ /**
+ * The {target namespace} of the actual member type definition.
+ */
+ const XMLCh* getMemberTypeUri() const;
+
+ /**
+ * @return true if the {name} of the actual member type definition is absent,
otherwise false.
+ */
+ bool getMemberTypeAnonymous() const;
+
+ /**
+ * @return the {name} of the actual member type definition, if it is not
absent.
+ */
+ const XMLCh* getMemberTypeName() const;
+
+
+ virtual const XMLCh* getDOMTypeInfoUri() const;
+ virtual const XMLCh* getDOMTypeInfoName() const;
+
+
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
@@ -249,8 +338,20 @@
void setDefaultValue(const XMLCh* const value);
void setComplexTypeInfo(ComplexTypeInfo* const typeInfo);
void setXsiComplexTypeInfo(ComplexTypeInfo* const typeInfo);
+ void setXsiSimpleTypeInfo(const DatatypeValidator* const dtv);
void setAttWildCard(SchemaAttDef* const attWildCard);
void setSubstitutionGroupElem(SchemaElementDecl* const elemDecl);
+ void setValidity(PSVIDefs::Validity valid);
+ void setValidationAttempted(PSVIDefs::Validation validation);
+
+ //called when element content of this element was validated
+ void updateValidityFromElement(const XMLElementDecl *decl, Grammar::GrammarType
eleGrammar);
+
+ //called when attribute content of this element was validated
+ void updateValidityFromAttribute(const SchemaAttDef *def);
+
+ //cleans up inbetween uses of the SchemaElementDecl. Resets xsiType, Validity
etc.
+ void reset();
// -----------------------------------------------------------------------
// IC methods
@@ -299,6 +400,10 @@
// Temporary store the xsi:type ComplexType here for validation
// If it presents, then it takes precedence than its own fComplexTypeInfo.
//
+ // fXsiSimpleTypeInfo
+ // Temporary store the xsi:type SimpleType here for validation
+ // If it present then the information from it will be returned rather than
fDatatypeValidator
+ //
// fIdentityConstraints
// Store information about an element identity constraints.
//
@@ -308,6 +413,23 @@
//
// fSubstitutionGroupElem
// The substitution group element declaration.
+ //
+ // fValidity
+ // After this attr has been validated this is its validity
+ //
+ // fValidation
+ // The type of validation that happened to this attr
+ //
+ // fSeenValidation
+ // set to true when a piece of content of this element is validated
+ //
+ // fSeenNoValidation
+ // set to true when a piece of content of this element is laxly or skip
validated
+ //
+ // fHadContent
+ // true when this element actually had content.
+ // -----------------------------------------------------------------------
+
// -----------------------------------------------------------------------
ModelTypes fModelType;
DatatypeValidator* fDatatypeValidator;
@@ -319,9 +441,15 @@
ComplexTypeInfo* fComplexTypeInfo;
RefHash2KeysTableOf<SchemaAttDef>* fAttDefs;
ComplexTypeInfo* fXsiComplexTypeInfo;
+ const DatatypeValidator* fXsiSimpleTypeInfo;
RefVectorOf<IdentityConstraint>* fIdentityConstraints;
SchemaAttDef* fAttWildCard;
SchemaElementDecl* fSubstitutionGroupElem;
+ PSVIDefs::Validity fValidity;
+ PSVIDefs::Validation fValidation;
+ bool fSeenValidation;
+ bool fSeenNoValidation;
+ bool fHadContent;
};
// ---------------------------------------------------------------------------
@@ -468,6 +596,156 @@
return fSubstitutionGroupElem;
}
+inline const XMLCh* SchemaElementDecl::getTypeName() const {
+ if (fXsiComplexTypeInfo)
+ return fXsiComplexTypeInfo->getTypeLocalName();
+ else if (fComplexTypeInfo)
+ return fComplexTypeInfo->getTypeLocalName();
+ else if(fXsiSimpleTypeInfo)
+ return fXsiSimpleTypeInfo->getTypeLocalName();
+ else if(fDatatypeValidator)
+ return fDatatypeValidator->getTypeLocalName();
+
+ //its anyType if we have not done validation on it
+ if(getValidationAttempted() == PSVIDefs::NONE)
+ return SchemaSymbols::fgATTVAL_ANYTYPE;
+
+
+ return 0;
+}
+
+inline PSVIDefs::Complexity SchemaElementDecl::getTypeType() const {
+ if(getModelType() == Simple) {
+ return PSVIDefs::SIMPLE;
+ }
+ else {
+ return PSVIDefs::COMPLEX;
+ }
+}
+
+
+inline const XMLCh* SchemaElementDecl::getTypeUri() const {
+ if (fXsiComplexTypeInfo)
+ return fXsiComplexTypeInfo->getTypeUri();
+ else if (fComplexTypeInfo)
+ return fComplexTypeInfo->getTypeUri();
+ else if(fXsiSimpleTypeInfo)
+ return fXsiSimpleTypeInfo->getTypeUri();
+ else if(fDatatypeValidator)
+ return fDatatypeValidator->getTypeUri();
+
+ //its anyType if we have not done validation on it
+ if(getValidationAttempted() == PSVIDefs::NONE)
+ return SchemaSymbols::fgURI_SCHEMAFORSCHEMA;
+
+
+ return 0;
+}
+
+inline const XMLCh* SchemaElementDecl::getMemberTypeName() const {
+ if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() ==
DatatypeValidator::Union)
+ return ((UnionDatatypeValidator*)fXsiSimpleTypeInfo)->getMemberTypeName();
+ else if(fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union)
+ return ((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeName();
+ return 0;
+}
+
+inline const XMLCh* SchemaElementDecl::getMemberTypeUri() const {
+ if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() ==
DatatypeValidator::Union)
+ return ((UnionDatatypeValidator*)fXsiSimpleTypeInfo)->getMemberTypeUri();
+ if(fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union)
+ return ((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeUri();
+
+ return 0;
+}
+
+inline bool SchemaElementDecl::getMemberTypeAnonymous() const {
+ if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() ==
DatatypeValidator::Union)
+ return
((UnionDatatypeValidator*)fXsiSimpleTypeInfo)->getMemberTypeAnonymous();
+ else if(fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union)
+ return
((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeAnonymous();
+ return false;
+}
+
+inline bool SchemaElementDecl::isTypeDefinitionUnion() const {
+ if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() ==
DatatypeValidator::Union ||
+ fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union)
+ return true;
+ return false;
+}
+
+inline PSVIDefs::Validity SchemaElementDecl::getValidity() const {
+ return fValidity;
+}
+
+inline PSVIDefs::Validation SchemaElementDecl::getValidationAttempted() const {
+ if(!fHadContent)
+ return fValidation;
+
+ if(!fSeenNoValidation && fSeenValidation)
+ return PSVIDefs::FULL;
+ else if(fSeenNoValidation && !fSeenValidation)
+ return PSVIDefs::NONE;
+ else
+ return PSVIDefs::PARTIAL;
+}
+
+inline bool SchemaElementDecl::getTypeAnonymous() const {
+
+ //REVISIT - since xsi type have to be accessed through names
+ //presumeably they cannot be anonymous
+
+ if (fXsiComplexTypeInfo) {
+ return fXsiComplexTypeInfo->getAnonymous();
+ }
+ else if (fComplexTypeInfo) {
+ return fComplexTypeInfo->getAnonymous();
+ }
+ else if(fXsiSimpleTypeInfo) {
+ return fXsiSimpleTypeInfo->getAnonymous();
+ }
+ else if(fDatatypeValidator){
+ return fDatatypeValidator->getAnonymous();
+ }
+
+ return true;
+}
+
+inline const XMLCh* SchemaElementDecl::getDOMTypeInfoName() const {
+ if(fValidity != PSVIDefs::VALID) {
+ if(getTypeType() == PSVIDefs::SIMPLE)
+ return SchemaSymbols::fgDT_ANYSIMPLETYPE;
+ else
+ return SchemaSymbols::fgATTVAL_ANYTYPE;
+ }
+
+ if(getTypeAnonymous() || getMemberTypeAnonymous())
+ return 0;
+ if(fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union)
+ return ((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeName();
+ if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() ==
DatatypeValidator::Union)
+ return ((UnionDatatypeValidator*)fXsiSimpleTypeInfo)->getMemberTypeName();
+ return getTypeName();
+}
+
+inline const XMLCh* SchemaElementDecl::getDOMTypeInfoUri() const {
+
+ if(fValidity != PSVIDefs::VALID)
+ return SchemaSymbols::fgURI_SCHEMAFORSCHEMA;
+
+ if(getTypeAnonymous() || getMemberTypeAnonymous())
+ return 0;
+
+ if(fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union)
+ return ((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeUri();
+
+ if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() ==
DatatypeValidator::Union)
+ return ((UnionDatatypeValidator*)fXsiSimpleTypeInfo)->getMemberTypeUri();
+
+
+ return getTypeUri();
+}
+
// ---------------------------------------------------------------------------
// SchemaElementDecl: Setter methods
// ---------------------------------------------------------------------------
@@ -524,6 +802,12 @@
}
inline void
+SchemaElementDecl::setXsiSimpleTypeInfo(const DatatypeValidator* const dtv)
+{
+ fXsiSimpleTypeInfo = dtv;
+}
+
+inline void
SchemaElementDecl::setAttWildCard(SchemaAttDef* const attWildCard) {
if (fAttWildCard)
@@ -536,6 +820,70 @@
SchemaElementDecl::setSubstitutionGroupElem(SchemaElementDecl* const elemDecl) {
fSubstitutionGroupElem = elemDecl;
+}
+
+inline void SchemaElementDecl::setValidity(PSVIDefs::Validity valid) {
+ fValidity = valid;
+}
+
+inline void SchemaElementDecl::setValidationAttempted(PSVIDefs::Validation
validation) {
+ fValidation = validation;
+}
+
+inline void SchemaElementDecl::updateValidityFromAttribute(const SchemaAttDef *def)
{
+
+ PSVIDefs::Validation curValAttemted = def->getValidationAttempted();
+ PSVIDefs::Validity curVal = def->getValidity();
+
+ if(curValAttemted == PSVIDefs::NONE || curValAttemted == PSVIDefs::PARTIAL) {
+ fSeenNoValidation = true;
+ fValidity = PSVIDefs::UNKNOWN;
+ }
+ else {
+ fSeenValidation = true;
+ }
+
+ if(curVal == PSVIDefs::INVALID)
+ fValidity = PSVIDefs::INVALID;
+
+ fHadContent = true;
+}
+
+inline void SchemaElementDecl::updateValidityFromElement(const XMLElementDecl
*decl, Grammar::GrammarType eleGrammar) {
+
+ if (eleGrammar == Grammar::SchemaGrammarType) {
+ PSVIDefs::Validation curValAttemted = ((SchemaElementDecl
*)decl)->getValidationAttempted();
+ PSVIDefs::Validity curVal = ((SchemaElementDecl *)decl)->getValidity();
+
+ if(curValAttemted == PSVIDefs::NONE || curValAttemted == PSVIDefs::PARTIAL)
{
+ fSeenNoValidation = true;
+ fValidity = PSVIDefs::UNKNOWN;
+ }
+ else {
+ fSeenValidation = true;
+ }
+
+ if(curVal == PSVIDefs::INVALID)
+ fValidity = PSVIDefs::INVALID;
+ }
+
+ fHadContent = true;
+
+}
+
+inline void SchemaElementDecl::reset() {
+ if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() ==
DatatypeValidator::Union)
+ ((UnionDatatypeValidator *)fXsiSimpleTypeInfo)->reset();
+ if(fDatatypeValidator && fDatatypeValidator->getType() ==
DatatypeValidator::Union)
+ ((UnionDatatypeValidator *)fDatatypeValidator)->reset();
+
+ setXsiSimpleTypeInfo(0);
+ setXsiComplexTypeInfo(0);
+ fValidity = PSVIDefs::UNKNOWN;
+ fValidation = PSVIDefs::NONE;
+ fSeenValidation = false;
+ fSeenNoValidation = false;
+ fHadContent = false;
}
// ---------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]