You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tn...@apache.org on 2001/08/29 22:52:36 UTC
cvs commit: xml-xerces/c/src/validators/schema SchemaElementDecl.cpp SchemaElementDecl.hpp SchemaValidator.cpp
tng 01/08/29 13:52:36
Modified: c/src/internal XMLScanner.cpp
c/src/validators/DTD DTDValidator.cpp
c/src/validators/schema SchemaElementDecl.cpp
SchemaElementDecl.hpp SchemaValidator.cpp
Log:
Schema: xsi:type support
Revision Changes Path
1.62 +17 -5 xml-xerces/c/src/internal/XMLScanner.cpp
Index: XMLScanner.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/internal/XMLScanner.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- XMLScanner.cpp 2001/08/23 11:54:25 1.61
+++ XMLScanner.cpp 2001/08/29 20:52:35 1.62
@@ -55,7 +55,7 @@
*/
/*
- * $Id: XMLScanner.cpp,v 1.61 2001/08/23 11:54:25 tng Exp $
+ * $Id: XMLScanner.cpp,v 1.62 2001/08/29 20:52:35 tng Exp $
*/
@@ -1721,6 +1721,10 @@
);
}
}
+
+ // reset xsi:type ComplexTypeInfo
+ if (fGrammar->getGrammarType() == Grammar::SchemaGrammarType)
+ ((SchemaElementDecl*)topElem->fThisElement)->setXsiComplexTypeInfo(0);
}
// If this was the root, then done with content
@@ -2186,6 +2190,10 @@
fElemStack.addLevel(elemDecl, fReaderMgr.getCurrentReaderNum());
fElemStack.setValidationFlag(fValidate);
+ // Validate the element
+ if (fValidate)
+ fValidator->validateElement(elemDecl);
+
//
// If this is the first element and we are validating, check the root
// element. This may or may not have any meaning for the installed
@@ -3026,6 +3034,10 @@
fElemStack.setElement(elemDecl, fReaderMgr.getCurrentReaderNum());
fElemStack.setCurrentURI(uriId);
+ // Validate the element
+ if (fValidate)
+ fValidator->validateElement(elemDecl);
+
if (fGrammar->getGrammarType() == Grammar::SchemaGrammarType) {
ComplexTypeInfo* typeinfo = ((SchemaElementDecl*)elemDecl)->getComplexTypeInfo();
if (typeinfo)
@@ -3077,10 +3089,6 @@
//
attCount = buildAttList(*fRawAttrList, attCount, *elemDecl, *fAttrList);
- // Validate the element
- if (fValidate)
- fValidator->validateElement(elemDecl);
-
//
// If empty, validate content right now if we are validating and then
// pop the element stack top. Else, we have to update the current stack
@@ -3104,6 +3112,10 @@
, elemDecl->getFormattedContentModel()
);
}
+
+ // reset xsi:type ComplexTypeInfo
+ if (fGrammar->getGrammarType() == Grammar::SchemaGrammarType)
+ ((SchemaElementDecl*)elemDecl)->setXsiComplexTypeInfo(0);
}
// If the elem stack is empty, then it was an empty root
1.20 +1 -2 xml-xerces/c/src/validators/DTD/DTDValidator.cpp
Index: DTDValidator.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/DTD/DTDValidator.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- DTDValidator.cpp 2001/07/24 21:23:39 1.19
+++ DTDValidator.cpp 2001/08/29 20:52:35 1.20
@@ -55,7 +55,7 @@
*/
/*
- * $Id: DTDValidator.cpp,v 1.19 2001/07/24 21:23:39 tng Exp $
+ * $Id: DTDValidator.cpp,v 1.20 2001/08/29 20:52:35 tng Exp $
*/
@@ -178,7 +178,6 @@
// There is a colon, so we have to split apart the name and prefix
// part.
//
- XMLBuffer bufTmp;
XMLCh* tmpNameBuf = XMLString::replicate(fullName);
ArrayJanitor<XMLCh> janNameBuf(tmpNameBuf);
1.13 +56 -22 xml-xerces/c/src/validators/schema/SchemaElementDecl.cpp
Index: SchemaElementDecl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/SchemaElementDecl.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SchemaElementDecl.cpp 2001/08/21 16:06:11 1.12
+++ SchemaElementDecl.cpp 2001/08/29 20:52:35 1.13
@@ -56,6 +56,9 @@
/*
* $Log: SchemaElementDecl.cpp,v $
+ * Revision 1.13 2001/08/29 20:52:35 tng
+ * Schema: xsi:type support
+ *
* Revision 1.12 2001/08/21 16:06:11 tng
* Schema: Unique Particle Attribution Constraint Checking.
*
@@ -119,6 +122,7 @@
, fSubstitutionGroupName(0)
, fTypeFromAnotherSchemaURI(0)
, fComplexTypeInfo(0)
+ , fXsiComplexTypeInfo(0)
, fAttDefs(0)
{
}
@@ -139,6 +143,7 @@
, fSubstitutionGroupName(0)
, fTypeFromAnotherSchemaURI(0)
, fComplexTypeInfo(0)
+ , fXsiComplexTypeInfo(0)
, fAttDefs(0)
{
setElementName(prefix, localPart, uriId);
@@ -158,6 +163,7 @@
, fSubstitutionGroupName(0)
, fTypeFromAnotherSchemaURI(0)
, fComplexTypeInfo(0)
+ , fXsiComplexTypeInfo(0)
, fAttDefs(0)
{
setElementName(elementName);
@@ -182,7 +188,13 @@
, const LookupOpts options
, bool& wasAdded) const
{
- if (fComplexTypeInfo == 0) {
+ if (fXsiComplexTypeInfo) {
+ return fXsiComplexTypeInfo->findAttr(qName, uriId, baseName, prefix, options, wasAdded);
+ }
+ else if (fComplexTypeInfo) {
+ return fComplexTypeInfo->findAttr(qName, uriId, baseName, prefix, options, wasAdded);
+ }
+ else {
if (options == XMLElementDecl::AddIfNotFound) {
SchemaAttDef* retVal = 0;
@@ -215,18 +227,20 @@
return 0;
}
}
-
- return fComplexTypeInfo->findAttr(qName, uriId, baseName, prefix, options, wasAdded);
}
XMLAttDefList& SchemaElementDecl::getAttDefList() const
{
- if (fComplexTypeInfo == 0) {
+ if (fXsiComplexTypeInfo) {
+ return fXsiComplexTypeInfo->getAttDefList();
+ }
+ else if (fComplexTypeInfo) {
+ return fComplexTypeInfo->getAttDefList();
+ }
+ else {
throw; // REVISIT: add proper error message
}
-
- return fComplexTypeInfo->getAttDefList();
}
@@ -253,50 +267,70 @@
bool SchemaElementDecl::hasAttDefs() const
{
+ if (fXsiComplexTypeInfo) {
+ return fXsiComplexTypeInfo->hasAttDefs();
+ }
+ else if (fComplexTypeInfo) {
+ return fComplexTypeInfo->hasAttDefs();
+ }
+
// If the collection hasn't been faulted in, then no att defs
- if (fComplexTypeInfo == 0)
- return false;
+ return false;
- return fComplexTypeInfo->hasAttDefs();
}
bool SchemaElementDecl::resetDefs()
{
- if (fComplexTypeInfo == 0) {
- return false;
+ if (fXsiComplexTypeInfo) {
+ return fXsiComplexTypeInfo->resetDefs();
}
+ else if (fComplexTypeInfo) {
+ return fComplexTypeInfo->resetDefs();
+ }
- return fComplexTypeInfo->resetDefs();
+ return false;
}
const XMLCh*
SchemaElementDecl::getFormattedContentModel() const
{
- if (fComplexTypeInfo != 0) {
+ if (fXsiComplexTypeInfo) {
+ return fXsiComplexTypeInfo->getFormattedContentModel();
+ }
+ else if (fComplexTypeInfo) {
return fComplexTypeInfo->getFormattedContentModel();
}
- return 0;
-}
+ return 0;
+}
// ---------------------------------------------------------------------------
// SchemaElementDecl: Getter methods
// ---------------------------------------------------------------------------
const SchemaAttDef* SchemaElementDecl::getAttDef(const XMLCh* const baseName, const int uriId) const
{
+ if (fXsiComplexTypeInfo) {
+ return fXsiComplexTypeInfo->getAttDef(baseName, uriId);
+ }
+ else if (fComplexTypeInfo) {
+ return fComplexTypeInfo->getAttDef(baseName, uriId);
+ }
+
// If no complex type, then return a null
- if (fComplexTypeInfo == 0)
- return 0;
+ return 0;
- return fComplexTypeInfo->getAttDef(baseName, uriId);
}
SchemaAttDef* SchemaElementDecl::getAttDef(const XMLCh* const baseName, const int uriId)
{
- // If no complex type, then return a null
- if (fComplexTypeInfo == 0)
- return 0;
+ if (fXsiComplexTypeInfo) {
+ return fXsiComplexTypeInfo->getAttDef(baseName, uriId);
+ }
+ else if (fComplexTypeInfo) {
+ return fComplexTypeInfo->getAttDef(baseName, uriId);
+ }
- return fComplexTypeInfo->getAttDef(baseName, uriId);
+ // If no complex type, then return a null
+ return 0;
}
1.12 +42 -9 xml-xerces/c/src/validators/schema/SchemaElementDecl.hpp
Index: SchemaElementDecl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/SchemaElementDecl.hpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- SchemaElementDecl.hpp 2001/08/21 16:06:11 1.11
+++ SchemaElementDecl.hpp 2001/08/29 20:52:35 1.12
@@ -56,6 +56,9 @@
/*
* $Log: SchemaElementDecl.hpp,v $
+ * Revision 1.12 2001/08/29 20:52:35 tng
+ * Schema: xsi:type support
+ *
* Revision 1.11 2001/08/21 16:06:11 tng
* Schema: Unique Particle Attribution Constraint Checking.
*
@@ -173,8 +176,8 @@
virtual ContentSpecNode* getContentSpec();
virtual void setContentSpec(ContentSpecNode* toAdopt);
virtual XMLContentModel* getContentModel();
- virtual void setContentModel(XMLContentModel* const newModelToAdopt);
- virtual const XMLCh* getFormattedContentModel () const;
+ virtual void setContentModel(XMLContentModel* const newModelToAdopt);
+ virtual const XMLCh* getFormattedContentModel () const;
// -----------------------------------------------------------------------
@@ -211,6 +214,7 @@
void setSubstitutionGroupName(const XMLCh* const name);
void setTypeFromAnotherSchemaURI(const XMLCh* const uriStr);
void setComplexTypeInfo(ComplexTypeInfo* const typeInfo);
+ void setXsiComplexTypeInfo(ComplexTypeInfo* const typeInfo);
private :
// -----------------------------------------------------------------------
@@ -256,7 +260,10 @@
// when ComplexTypeInfo does not exist. We want to keep track
// of these faulted in attributes to avoid duplicate redundant
// error.
-
+ //
+ // fXsiComplexTypeInfo
+ // Temporary store the xsi:type ComplexType here for validation
+ // If it presents, then it takes precedence than its own fComplexTypeInfo.
// -----------------------------------------------------------------------
ModelTypes fModelType;
DatatypeValidator* fDatatypeValidator;
@@ -270,6 +277,7 @@
XMLCh* fTypeFromAnotherSchemaURI;
ComplexTypeInfo* fComplexTypeInfo;
RefHash2KeysTableOf<SchemaAttDef>* fAttDefs;
+ ComplexTypeInfo* fXsiComplexTypeInfo;
};
// ---------------------------------------------------------------------------
@@ -277,7 +285,10 @@
// ---------------------------------------------------------------------------
inline ContentSpecNode* SchemaElementDecl::getContentSpec()
{
- if (fComplexTypeInfo != 0) {
+ if (fXsiComplexTypeInfo != 0) {
+ return fXsiComplexTypeInfo->getContentSpec();
+ }
+ else if (fComplexTypeInfo != 0) {
return fComplexTypeInfo->getContentSpec();
}
@@ -286,7 +297,10 @@
inline const ContentSpecNode* SchemaElementDecl::getContentSpec() const
{
- if (fComplexTypeInfo != 0) {
+ if (fXsiComplexTypeInfo != 0) {
+ return fXsiComplexTypeInfo->getContentSpec();
+ }
+ else if (fComplexTypeInfo != 0) {
return fComplexTypeInfo->getContentSpec();
}
@@ -301,10 +315,13 @@
inline XMLContentModel* SchemaElementDecl::getContentModel()
{
- if (fComplexTypeInfo != 0) {
+ if (fXsiComplexTypeInfo != 0) {
+ return fXsiComplexTypeInfo->getContentModel();
+ }
+ else if (fComplexTypeInfo != 0) {
return fComplexTypeInfo->getContentModel();
}
- return 0;
+ return 0;
}
inline void
@@ -370,12 +387,19 @@
inline ComplexTypeInfo* SchemaElementDecl::getComplexTypeInfo() const
{
+ if (fXsiComplexTypeInfo) {
+ return fXsiComplexTypeInfo;
+ }
+
return fComplexTypeInfo;
}
inline const SchemaAttDef* SchemaElementDecl::getAttWildCard() const {
- if (fComplexTypeInfo) {
+ if (fXsiComplexTypeInfo) {
+ return fXsiComplexTypeInfo->getAttWildCard();
+ }
+ else if (fComplexTypeInfo) {
return fComplexTypeInfo->getAttWildCard();
}
@@ -384,7 +408,10 @@
inline SchemaAttDef* SchemaElementDecl::getAttWildCard() {
- if (fComplexTypeInfo) {
+ if (fXsiComplexTypeInfo) {
+ return fXsiComplexTypeInfo->getAttWildCard();
+ }
+ else if (fComplexTypeInfo) {
return fComplexTypeInfo->getAttWildCard();
}
@@ -462,6 +489,12 @@
SchemaElementDecl::setComplexTypeInfo(ComplexTypeInfo* const typeInfo)
{
fComplexTypeInfo = typeInfo;
+}
+
+inline void
+SchemaElementDecl::setXsiComplexTypeInfo(ComplexTypeInfo* const typeInfo)
+{
+ fXsiComplexTypeInfo = typeInfo;
}
#endif
1.15 +19 -3 xml-xerces/c/src/validators/schema/SchemaValidator.cpp
Index: SchemaValidator.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/SchemaValidator.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- SchemaValidator.cpp 2001/08/28 19:20:54 1.14
+++ SchemaValidator.cpp 2001/08/29 20:52:35 1.15
@@ -56,6 +56,9 @@
/*
* $Log: SchemaValidator.cpp,v $
+ * Revision 1.15 2001/08/29 20:52:35 tng
+ * Schema: xsi:type support
+ *
* Revision 1.14 2001/08/28 19:20:54 tng
* Schema: xsi:type support
*
@@ -592,8 +595,12 @@
if (typeInfo) {
// typeInfo is found
- if (typeInfo->getAbstract())
+ bool error = false;
+
+ if (typeInfo->getAbstract()) {
emitError(XMLValid::NoAbstractInXsiType, aBuffer.getRawBuffer());
+ error = true;
+ }
ComplexTypeInfo* destType = ((SchemaElementDecl*)elemDef)->getComplexTypeInfo();
ComplexTypeInfo* tempType = typeInfo;
@@ -603,12 +610,16 @@
break;
tempType = tempType->getBaseComplexTypeInfo();
}
- if (!tempType)
+ if (!tempType) {
emitError(XMLValid::NonDerivedXsiType, fXsiType->getRawName(), elemDef->getFullName());
+ error = true;
+ }
else {
int derivationMethod = typeInfo->getDerivedBy();
- if ((((SchemaElementDecl*)elemDef)->getBlockSet() & derivationMethod) != 0)
+ if ((((SchemaElementDecl*)elemDef)->getBlockSet() & derivationMethod) != 0) {
emitError(XMLValid::NoSubforBlock, fXsiType->getRawName(), elemDef->getFullName());
+ error = true;
+ }
}
}
else {
@@ -617,8 +628,12 @@
if (ancestorValidator && !ancestorValidator->isSubstitutableBy(fXsiTypeValidator)) {
// the type is not derived from ancestor
emitError(XMLValid::NonDerivedXsiType, fXsiType->getRawName(), elemDef->getFullName());
+ error = true;
}
}
+
+ if (!error)
+ ((SchemaElementDecl*)elemDef)->setXsiComplexTypeInfo(typeInfo);
}
else {
// typeInfo not found
@@ -958,3 +973,4 @@
fDatatypeBuffer.set(toFill.getRawBuffer());
}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org