You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2002/04/03 23:48:31 UTC
cvs commit: xml-xerces/c/src/xercesc/internal XMLScanner2.cpp
knoaman 02/04/03 13:48:31
Modified: c/src/xercesc/internal XMLScanner2.cpp
Log:
Fix for bug 7565.
Revision Changes Path
1.5 +72 -106 xml-xerces/c/src/xercesc/internal/XMLScanner2.cpp
Index: XMLScanner2.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLScanner2.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XMLScanner2.cpp 21 Mar 2002 15:35:54 -0000 1.4
+++ XMLScanner2.cpp 3 Apr 2002 21:48:31 -0000 1.5
@@ -55,7 +55,7 @@
*/
/*
- * $Id: XMLScanner2.cpp,v 1.4 2002/03/21 15:35:54 knoaman Exp $
+ * $Id: XMLScanner2.cpp,v 1.5 2002/04/03 21:48:31 knoaman Exp $
*/
@@ -225,60 +225,60 @@
bool skipThisOne = false;
XMLAttDef* attDefForWildCard = 0;
-
XMLAttDef* attDef = 0;
+
if (fGrammarType == Grammar::SchemaGrammarType) {
- SchemaAttDef* attWildCard = ((SchemaElementDecl*)elemDecl)->getAttWildCard();
-
- if (attWildCard) {
- //if schema, see if we should lax or skip the validation of this attribute
- if (anyAttributeValidation(attWildCard, uriId, skipThisOne, laxThisOne)) {
- SchemaGrammar* sGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(getURIText(uriId));
- if (sGrammar && sGrammar->getGrammarType() == Grammar::SchemaGrammarType) {
- RefHashTableOf<XMLAttDef>* attRegistry = sGrammar->getAttributeDeclRegistry();
- if (attRegistry) {
- attDefForWildCard = attRegistry->get(suffPtr);
- }
- }
- }
- }
-
//retrieve the att def
attDef = ((SchemaElementDecl*)elemDecl)->getAttDef(suffPtr, uriId);
- if (!attDef) {
- // not find, see if the attDef should be qualified or not
- if (uriId == fEmptyNamespaceId) {
- attDef = ((SchemaElementDecl*)elemDecl)->getAttDef(suffPtr, fURIStringPool->getId(fGrammar->getTargetNamespace()));
- if (fValidate
- && attDef
- && !attDefForWildCard
- && !skipThisOne
- && !laxThisOne
- && attDef->getCreateReason() != XMLAttDef::JustFaultIn) {
- // the attribute should be qualified
- fValidator->emitError
- (
- XMLValid::AttributeNotQualified
- , attDef->getFullName()
- );
+ // if not found or faulted in - check for a matching wildcard attribute
+ // if no matching wildcard attribute, check (un)qualifed cases and flag
+ // appropriate errors
+ if (!attDef || (attDef->getCreateReason() == XMLAttDef::JustFaultIn)) {
+
+ SchemaAttDef* attWildCard = ((SchemaElementDecl*)elemDecl)->getAttWildCard();
+
+ if (attWildCard) {
+ //if schema, see if we should lax or skip the validation of this attribute
+ if (anyAttributeValidation(attWildCard, uriId, skipThisOne, laxThisOne)) {
+
+ SchemaGrammar* sGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(getURIText(uriId));
+ if (sGrammar && sGrammar->getGrammarType() == Grammar::SchemaGrammarType) {
+ RefHashTableOf<XMLAttDef>* attRegistry = sGrammar->getAttributeDeclRegistry();
+ if (attRegistry) {
+ attDefForWildCard = attRegistry->get(suffPtr);
+ }
+ }
}
}
else {
- attDef = ((SchemaElementDecl*)elemDecl)->getAttDef(suffPtr, fEmptyNamespaceId);
- if (fValidate
- && attDef
- && !attDefForWildCard
- && !skipThisOne
- && !laxThisOne
- && attDef->getCreateReason() != XMLAttDef::JustFaultIn) {
- // the attribute should be qualified
- fValidator->emitError
- (
- XMLValid::AttributeNotUnQualified
- , attDef->getFullName()
- );
+ // not found, see if the attDef should be qualified or not
+ if (uriId == fEmptyNamespaceId) {
+ attDef = ((SchemaElementDecl*)elemDecl)->getAttDef(suffPtr, fURIStringPool->getId(fGrammar->getTargetNamespace()));
+ if (fValidate
+ && attDef
+ && attDef->getCreateReason() != XMLAttDef::JustFaultIn) {
+ // the attribute should be qualified
+ fValidator->emitError
+ (
+ XMLValid::AttributeNotQualified
+ , attDef->getFullName()
+ );
+ }
+ }
+ else {
+ attDef = ((SchemaElementDecl*)elemDecl)->getAttDef(suffPtr, fEmptyNamespaceId);
+ if (fValidate
+ && attDef
+ && attDef->getCreateReason() != XMLAttDef::JustFaultIn) {
+ // the attribute should be qualified
+ fValidator->emitError
+ (
+ XMLValid::AttributeNotUnQualified
+ , attDef->getFullName()
+ );
+ }
}
}
}
@@ -309,69 +309,36 @@
attDef->setCreateReason(XMLAttDef::JustFaultIn);
}
- if (!attDefForWildCard) {
- if (wasAdded)
- {
- 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
- && !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 (fValidate && !attDefForWildCard && !skipThisOne && !laxThisOne &&
+ attDef->getCreateReason() == XMLAttDef::JustFaultIn && !attDef->getProvided())
+ {
+ //
+ // 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()
+ );
}
//
// If its already provided, then there are more than one of
// this attribute in this start tag, so emit an error.
//
-
if (attDef->getProvided())
{
emitError
@@ -391,8 +358,7 @@
// don't care about the return status here. If it failed, an error
// was issued, which is all we care about.
//
-
- if (attDefForWildCard && (wasAdded || (!wasAdded && attDef->getCreateReason() == XMLAttDef::JustFaultIn))) {
+ if (attDefForWildCard) {
normalizeAttValue
(
attDefForWildCard
@@ -434,7 +400,7 @@
//
// If we found an attdef for this one, then lets validate it.
//
- if (!wasAdded && attDef->getCreateReason() != XMLAttDef::JustFaultIn)
+ if (attDef->getCreateReason() != XMLAttDef::JustFaultIn)
{
if (fValidate && !skipThisOne)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org