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/09/14 16:50:22 UTC
cvs commit: xml-xerces/c/src/validators/schema SchemaElementDecl.cpp SchemaGrammar.cpp SchemaGrammar.hpp
tng 01/09/14 07:50:22
Modified: c/src/internal XMLScanner.cpp XMLScanner2.cpp
c/src/validators/DTD DTDGrammar.cpp DTDGrammar.hpp
c/src/validators/common DFAContentModel.cpp Grammar.hpp
c/src/validators/schema SchemaElementDecl.cpp
SchemaGrammar.cpp SchemaGrammar.hpp
Log:
Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems.
Revision Changes Path
1.66 +102 -70 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.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- XMLScanner.cpp 2001/09/10 15:16:04 1.65
+++ XMLScanner.cpp 2001/09/14 14:50:22 1.66
@@ -55,7 +55,7 @@
*/
/*
- * $Id: XMLScanner.cpp,v 1.65 2001/09/10 15:16:04 tng Exp $
+ * $Id: XMLScanner.cpp,v 1.66 2001/09/14 14:50:22 tng Exp $
*/
@@ -2857,8 +2857,7 @@
);
if (!elemDecl && fURIStringPool->getId(fGrammar->getTargetNamespace()) != uriId) {
-
- // switch grammar first
+ // not found, switch to the specified grammar
const XMLCh* uriStr = getURIText(uriId);
if (!switchGrammar(uriStr) && fValidate && !laxThisOne)
{
@@ -2878,9 +2877,18 @@
);
}
- if (!elemDecl) {
- if (currentScope != Grammar::TOP_LEVEL_SCOPE) {
- // Not found in specified uri
+ if (!elemDecl && currentScope != Grammar::TOP_LEVEL_SCOPE) {
+ // if not found, then it may be a reference, try TOP_LEVEL_SCOPE
+ elemDecl = fGrammar->getElemDecl
+ (
+ uriId
+ , nameRawBuf
+ , qnameRawBuf
+ , Grammar::TOP_LEVEL_SCOPE
+ );
+
+ if(!elemDecl) {
+ // still not found in specified uri
// try emptyNamesapce see if element should be un-qualified.
elemDecl = fGrammar->getElemDecl
(
@@ -2889,28 +2897,26 @@
, qnameRawBuf
, currentScope
);
- }
- if (elemDecl && fValidate) {
- fValidator->emitError
- (
- XMLValid::ElementNotUnQualified
- , elemDecl->getFullName()
- );
- }
- else {
- // if not found, then it may be a reference, try TOP_LEVEL_SCOPE
- elemDecl = fGrammar->findOrAddElemDecl
- (
- uriId
- , nameRawBuf
- , fPrefixBuf.getRawBuffer()
- , qnameRawBuf
- , Grammar::TOP_LEVEL_SCOPE
- , wasAdded
- );
+ if (elemDecl && elemDecl->getCreateReason() != XMLElementDecl::JustFaultIn && fValidate) {
+ fValidator->emitError
+ (
+ XMLValid::ElementNotUnQualified
+ , elemDecl->getFullName()
+ );
+ }
}
}
+
+ if (!elemDecl) {
+ // still not found, fault this in and issue error later
+ elemDecl = fGrammar->putElemDecl(uriId
+ , nameRawBuf
+ , fPrefixBuf.getRawBuffer()
+ , qnameRawBuf
+ , currentScope);
+ wasAdded = true;
+ }
}
else
{
@@ -2927,59 +2933,78 @@
, currentScope
);
- if (!elemDecl) {
- // Not found in specified uri
- // use target namespace URI id to see if element needs to be fully qualified.
+ unsigned orgGrammarUri = fURIStringPool->getId(fGrammar->getTargetNamespace());
+
+ if (!elemDecl && orgGrammarUri != fEmptyNamespaceId) {
+ //not found, switch grammar and try globalNS
+ if (!switchGrammar(XMLUni::fgZeroLenString) && fValidate && !laxThisOne)
+ {
+ fValidator->emitError
+ (
+ XMLValid::GrammarNotFound
+ , XMLUni::fgZeroLenString
+ );
+ }
+
+ elemDecl = fGrammar->getElemDecl
+ (
+ uriId
+ , nameRawBuf
+ , qnameRawBuf
+ , currentScope
+ );
+ }
+
+ if (!elemDecl && currentScope != Grammar::TOP_LEVEL_SCOPE) {
+ // if not found, then it may be a reference, try TOP_LEVEL_SCOPE
elemDecl = fGrammar->getElemDecl
(
- fURIStringPool->getId(fGrammar->getTargetNamespace())
+ uriId
, nameRawBuf
, qnameRawBuf
- , currentScope
+ , Grammar::TOP_LEVEL_SCOPE
);
- if (elemDecl && fValidate) {
- fValidator->emitError
- (
- XMLValid::ElementNotQualified
- , elemDecl->getFullName()
- );
- }
- else {
- //still not found, now try globalNS
- if (fURIStringPool->getId(fGrammar->getTargetNamespace()) != fEmptyNamespaceId) {
- if (!switchGrammar(XMLUni::fgZeroLenString) && fValidate && !laxThisOne)
- {
- fValidator->emitError
- (
- XMLValid::GrammarNotFound
- , XMLUni::fgZeroLenString
- );
- }
+ if (!elemDecl && orgGrammarUri != fEmptyNamespaceId) {
+ // still Not found in specified uri
+ // go to original Grammar again to see if element needs to be fully qualified.
+ const XMLCh* uriStr = getURIText(orgGrammarUri);
+ if (!switchGrammar(uriStr) && fValidate && !laxThisOne)
+ {
+ fValidator->emitError
+ (
+ XMLValid::GrammarNotFound
+ ,uriStr
+ );
}
elemDecl = fGrammar->getElemDecl
(
- uriId
- , nameRawBuf
- , qnameRawBuf
- , currentScope
- );
-
- if (!elemDecl) {
- // if not found, then it may be a reference, try TOP_LEVEL_SCOPE
- elemDecl = fGrammar->findOrAddElemDecl
+ orgGrammarUri
+ , nameRawBuf
+ , qnameRawBuf
+ , currentScope
+ );
+
+ if (elemDecl && elemDecl->getCreateReason() != XMLElementDecl::JustFaultIn && fValidate) {
+ fValidator->emitError
(
- uriId
- , nameRawBuf
- , fPrefixBuf.getRawBuffer()
- , qnameRawBuf
- , Grammar::TOP_LEVEL_SCOPE
- , wasAdded
+ XMLValid::ElementNotQualified
+ , elemDecl->getFullName()
);
}
}
}
+
+ if (!elemDecl) {
+ // still not found, fault this in and issue error later
+ elemDecl = fGrammar->putElemDecl(uriId
+ , nameRawBuf
+ , fPrefixBuf.getRawBuffer()
+ , qnameRawBuf
+ , currentScope);
+ wasAdded = true;
+ }
}
//
@@ -3018,13 +3043,20 @@
else
{
// If its not marked declared and validating, then emit an error
- if (!elemDecl->isDeclared() && fValidate)
- {
- fValidator->emitError
- (
- XMLValid::ElementNotDefined
- , elemDecl->getFullName()
- );
+ if (!elemDecl->isDeclared()) {
+ if (laxThisOne) {
+ fValidate = false;
+ fElemStack.setValidationFlag(fValidate);
+ }
+
+ if (fValidate)
+ {
+ fValidator->emitError
+ (
+ XMLValid::ElementNotDefined
+ , elemDecl->getFullName()
+ );
+ }
}
}
1.61 +60 -53 xml-xerces/c/src/internal/XMLScanner2.cpp
Index: XMLScanner2.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/internal/XMLScanner2.cpp,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- XMLScanner2.cpp 2001/09/11 12:35:10 1.60
+++ XMLScanner2.cpp 2001/09/14 14:50:22 1.61
@@ -55,7 +55,7 @@
*/
/*
- * $Id: XMLScanner2.cpp,v 1.60 2001/09/11 12:35:10 tng Exp $
+ * $Id: XMLScanner2.cpp,v 1.61 2001/09/14 14:50:22 tng Exp $
*/
@@ -263,63 +263,70 @@
, wasAdded
);
- if (wasAdded && !attDefForWildCard)
+ if (wasAdded)
{
- //
- // Its not valid for this element, so issue an error if we are
- // validating.
- //
- if (fValidate && !skipThisOne && !laxThisOne)
+ // This is to tell the Validator that this attribute was
+ // faulted-in, was not an attribute in the attdef originally
+ attDef->setCreateReason(XMLAttDef::JustFaultIn);
+ }
+
+ if (!attDefForWildCard) {
+ if (wasAdded)
{
- // This is to tell the Validator that this attribute was
- // faulted-in, was not an attribute in the attdef originally
- attDef->setCreateReason(XMLAttDef::JustFaultIn);
- XMLBufBid bbURI(&fBufMgr);
- XMLBuffer& bufURI = bbURI.getBuffer();
-
- getURIText(uriId, bufURI);
-
- XMLBufBid bbMsg(&fBufMgr);
- XMLBuffer& bufMsg = bbMsg.getBuffer();
- bufMsg.append(chOpenCurly);
- bufMsg.append(bufURI.getRawBuffer());
- bufMsg.append(chCloseCurly);
- bufMsg.append(suffPtr);
- fValidator->emitError
- (
- XMLValid::AttNotDefinedForElement
- , bufMsg.getRawBuffer()
- , elemDecl->getFullName()
- );
+ if (fValidate && !skipThisOne && !laxThisOne)
+ {
+ //
+ // Its not valid for this element, so issue an error if we are
+ // validating.
+ //
+ XMLBufBid bbURI(&fBufMgr);
+ XMLBuffer& bufURI = bbURI.getBuffer();
+
+ getURIText(uriId, bufURI);
+
+ XMLBufBid bbMsg(&fBufMgr);
+ XMLBuffer& bufMsg = bbMsg.getBuffer();
+ bufMsg.append(chOpenCurly);
+ bufMsg.append(bufURI.getRawBuffer());
+ bufMsg.append(chCloseCurly);
+ bufMsg.append(suffPtr);
+ fValidator->emitError
+ (
+ XMLValid::AttNotDefinedForElement
+ , bufMsg.getRawBuffer()
+ , elemDecl->getFullName()
+ );
+ }
}
- }
- else
- {
- // If this attribute was faulted-in and first occurence,
- // then emit an error
- if (fValidate
- && attDef->getCreateReason() == XMLAttDef::JustFaultIn
- && !attDef->getProvided()
- && !skipThisOne)
+ else
{
- XMLBufBid bbURI(&fBufMgr);
- XMLBuffer& bufURI = bbURI.getBuffer();
- getURIText(uriId, bufURI);
-
- XMLBufBid bbMsg(&fBufMgr);
- XMLBuffer& bufMsg = bbMsg.getBuffer();
- bufMsg.append(chOpenCurly);
- bufMsg.append(bufURI.getRawBuffer());
- bufMsg.append(chCloseCurly);
- bufMsg.append(suffPtr);
- fValidator->emitError
- (
- XMLValid::AttNotDefinedForElement
- , bufMsg.getRawBuffer()
- , elemDecl->getFullName()
- );
+ // If this attribute was faulted-in and first occurence,
+ // then emit an error
+ if (fValidate
+ && attDef->getCreateReason() == XMLAttDef::JustFaultIn
+ && !attDef->getProvided()
+ && !skipThisOne
+ && !laxThisOne)
+ {
+ XMLBufBid bbURI(&fBufMgr);
+ XMLBuffer& bufURI = bbURI.getBuffer();
+ getURIText(uriId, bufURI);
+
+ XMLBufBid bbMsg(&fBufMgr);
+ XMLBuffer& bufMsg = bbMsg.getBuffer();
+ bufMsg.append(chOpenCurly);
+ bufMsg.append(bufURI.getRawBuffer());
+ bufMsg.append(chCloseCurly);
+ bufMsg.append(suffPtr);
+ fValidator->emitError
+ (
+ XMLValid::AttNotDefinedForElement
+ , bufMsg.getRawBuffer()
+ , elemDecl->getFullName()
+ );
+ }
}
- }
+ }
//
// If its already provided, then there are more than one of
1.4 +15 -0 xml-xerces/c/src/validators/DTD/DTDGrammar.cpp
Index: DTDGrammar.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/DTD/DTDGrammar.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DTDGrammar.cpp 2001/05/11 13:27:08 1.3
+++ DTDGrammar.cpp 2001/09/14 14:50:22 1.4
@@ -56,6 +56,9 @@
/*
* $Log: DTDGrammar.cpp,v $
+ * Revision 1.4 2001/09/14 14:50:22 tng
+ * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems.
+ *
* Revision 1.3 2001/05/11 13:27:08 tng
* Copyright update.
*
@@ -130,6 +133,18 @@
{
wasAdded = false;
}
+ return retVal;
+}
+
+XMLElementDecl* DTDGrammar::putElemDecl (const unsigned int uriId
+ , const XMLCh* const baseName
+ , const XMLCh* const prefixName
+ , const XMLCh* const qName
+ , unsigned int scope)
+{
+ DTDElementDecl* retVal = new DTDElementDecl(qName, uriId, DTDElementDecl::Any);
+ const unsigned int elemId = fElemDeclPool->put(retVal);
+ retVal->setId(elemId);
return retVal;
}
1.5 +12 -0 xml-xerces/c/src/validators/DTD/DTDGrammar.hpp
Index: DTDGrammar.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/DTD/DTDGrammar.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DTDGrammar.hpp 2001/05/28 20:56:17 1.4
+++ DTDGrammar.hpp 2001/09/14 14:50:22 1.5
@@ -56,6 +56,9 @@
/*
* $Log: DTDGrammar.hpp,v $
+ * Revision 1.5 2001/09/14 14:50:22 tng
+ * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems.
+ *
* Revision 1.4 2001/05/28 20:56:17 tng
* Schema: Move getTargetNamespace as virtual function in base class Grammar
*
@@ -158,6 +161,15 @@
virtual XMLNotationDecl* getNotationDecl
(
const XMLCh* const notName
+ );
+
+ virtual XMLElementDecl* putElemDecl
+ (
+ const unsigned int uriId
+ , const XMLCh* const baseName
+ , const XMLCh* const prefixName
+ , const XMLCh* const qName
+ , unsigned int scope
);
virtual unsigned int putElemDecl
1.24 +7 -2 xml-xerces/c/src/validators/common/DFAContentModel.cpp
Index: DFAContentModel.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/common/DFAContentModel.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- DFAContentModel.cpp 2001/08/24 12:48:48 1.23
+++ DFAContentModel.cpp 2001/09/14 14:50:22 1.24
@@ -56,6 +56,9 @@
/*
* $Log: DFAContentModel.cpp,v $
+ * Revision 1.24 2001/09/14 14:50:22 tng
+ * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems.
+ *
* Revision 1.23 2001/08/24 12:48:48 tng
* Schema: AllContentModel
*
@@ -590,7 +593,8 @@
}
}
else {
- if ((inElem->getURI() == element->getURI()) &&
+ if ((fElemMapType[inIndex] == fLeafListType[outIndex]) &&
+ (inElem->getURI() == element->getURI()) &&
(!XMLString::compareString(inElem->getLocalPart(), element->getLocalPart()))) {
break;
}
@@ -634,7 +638,8 @@
}
}
else {
- if ((leaf->getURI() == element->getURI()) &&
+ if ((fElemMapType[elemIndex] == fLeafListType[leafIndex]) &&
+ (leaf->getURI() == element->getURI()) &&
(!XMLString::compareString(leaf->getLocalPart(), element->getLocalPart()))) {
fLeafSorter[fSortCount++] = leafIndex;
}
1.6 +12 -0 xml-xerces/c/src/validators/common/Grammar.hpp
Index: Grammar.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/common/Grammar.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Grammar.hpp 2001/05/28 20:56:18 1.5
+++ Grammar.hpp 2001/09/14 14:50:22 1.6
@@ -56,6 +56,9 @@
/*
* $Log: Grammar.hpp,v $
+ * Revision 1.6 2001/09/14 14:50:22 tng
+ * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems.
+ *
* Revision 1.5 2001/05/28 20:56:18 tng
* Schema: Move getTargetNamespace as virtual function in base class Grammar
*
@@ -184,6 +187,15 @@
// -----------------------------------------------------------------------
// Virtual Setter methods
// -----------------------------------------------------------------------
+ virtual XMLElementDecl* putElemDecl
+ (
+ const unsigned int uriId
+ , const XMLCh* const baseName
+ , const XMLCh* const prefixName
+ , const XMLCh* const qName
+ , unsigned int scope
+ ) = 0;
+
virtual unsigned int putElemDecl
(
XMLElementDecl* const elemDecl
1.15 +10 -1 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.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- SchemaElementDecl.cpp 2001/09/11 13:02:40 1.14
+++ SchemaElementDecl.cpp 2001/09/14 14:50:22 1.15
@@ -56,6 +56,9 @@
/*
* $Log: SchemaElementDecl.cpp,v $
+ * Revision 1.15 2001/09/14 14:50:22 tng
+ * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems.
+ *
* Revision 1.14 2001/09/11 13:02:40 tng
* [Bug 3523] SchemaElementDecl.cpp(242) : error C2202 : not all control paths return a value
*
@@ -242,7 +245,7 @@
return fComplexTypeInfo->getAttDefList();
}
else {
- throw; // REVISIT: add proper error message
+ ThrowXML(RuntimeException, XMLExcepts::DV_InvalidOperation);
}
return *(XMLAttDefList*)0 ;
@@ -292,6 +295,12 @@
}
else if (fComplexTypeInfo) {
return fComplexTypeInfo->resetDefs();
+ }
+ else if (fAttDefs) {
+ //all the attdefs here are faulted-in, so just reset the fAttDefs
+ //but still return false to indicate there is no real att defs
+ // defined in this element
+ fAttDefs->removeAll();
}
return false;
1.8 +15 -0 xml-xerces/c/src/validators/schema/SchemaGrammar.cpp
Index: SchemaGrammar.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/SchemaGrammar.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SchemaGrammar.cpp 2001/08/21 16:06:11 1.7
+++ SchemaGrammar.cpp 2001/09/14 14:50:22 1.8
@@ -56,6 +56,9 @@
/*
* $Log: SchemaGrammar.cpp,v $
+ * Revision 1.8 2001/09/14 14:50:22 tng
+ * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems.
+ *
* Revision 1.7 2001/08/21 16:06:11 tng
* Schema: Unique Particle Attribution Constraint Checking.
*
@@ -171,6 +174,18 @@
{
wasAdded = false;
}
+ return retVal;
+}
+
+XMLElementDecl* SchemaGrammar::putElemDecl (const unsigned int uriId
+ , const XMLCh* const baseName
+ , const XMLCh* const prefixName
+ , const XMLCh* const qName
+ , unsigned int scope)
+{
+ SchemaElementDecl* retVal = new SchemaElementDecl(prefixName, baseName, uriId, SchemaElementDecl::Any);
+ const unsigned int elemId = fElemDeclPool->put((void*)baseName, uriId, scope, retVal);
+ retVal->setId(elemId);
return retVal;
}
1.10 +20 -8 xml-xerces/c/src/validators/schema/SchemaGrammar.hpp
Index: SchemaGrammar.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/SchemaGrammar.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SchemaGrammar.hpp 2001/08/21 16:06:11 1.9
+++ SchemaGrammar.hpp 2001/09/14 14:50:22 1.10
@@ -56,6 +56,9 @@
/*
* $Log: SchemaGrammar.hpp,v $
+ * Revision 1.10 2001/09/14 14:50:22 tng
+ * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems.
+ *
* Revision 1.9 2001/08/21 16:06:11 tng
* Schema: Unique Particle Attribution Constraint Checking.
*
@@ -192,6 +195,15 @@
const XMLCh* const notName
);
+ virtual XMLElementDecl* putElemDecl
+ (
+ const unsigned int uriId
+ , const XMLCh* const baseName
+ , const XMLCh* const prefixName
+ , const XMLCh* const qName
+ , unsigned int scope
+ );
+
virtual unsigned int putElemDecl
(
XMLElementDecl* const elemDecl
@@ -283,8 +295,8 @@
// Valid list of elements that can substitute a given element
//
// fUPAChecked
- // Indicates if this Grammar has already been validated for
- // schema unique particle attribute constraint checking.
+ // Indicates if this Grammar has already been validated for
+ // schema unique particle attribute constraint checking.
// -----------------------------------------------------------------------
XMLCh* fTargetNamespace;
RefHash3KeysIdPool<SchemaElementDecl>* fElemDeclPool;
@@ -395,7 +407,7 @@
fNamespaceScope = nsScope;
}
-inline void
+inline void
SchemaGrammar::setValidSubstitutionGroups(RefHash2KeysTableOf<ElemVector>* const other) {
fValidSubstitutionGroups = other;
@@ -431,7 +443,7 @@
decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope);
- if (!decl)
+ if (!decl)
return XMLElementDecl::fgInvalidElemId;
}
return decl->getId();
@@ -444,7 +456,7 @@
{
const SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope);
- if (!decl)
+ if (!decl)
decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope);
return decl;
@@ -457,7 +469,7 @@
{
SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope);
- if (!decl)
+ if (!decl)
decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope);
return decl;
@@ -470,7 +482,7 @@
if (!decl)
decl = fGroupElemDeclPool->getById(elemId);
-
+
return decl;
}
@@ -481,7 +493,7 @@
if (!decl)
decl = fGroupElemDeclPool->getById(elemId);
-
+
return decl;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org