neilg 2004/06/21 11:02:13
Modified: c/src/xercesc/internal IGXMLScanner.cpp SGXMLScanner.cpp
Log:
If the namespace of an element is the same as that of the
grammar we're using, we don't switch grammars. Therefore,
under these conditions we should not switch back--if we do, the GrammarResolver
may present us with a different grammar, and this produces very bad results.
Revision Changes Path
1.72 +18 -8 xml-xerces/c/src/xercesc/internal/IGXMLScanner.cpp
Index: IGXMLScanner.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/IGXMLScanner.cpp,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- IGXMLScanner.cpp 15 Jun 2004 21:28:02 -0000 1.71
+++ IGXMLScanner.cpp 21 Jun 2004 18:02:13 -0000 1.72
@@ -2372,9 +2372,13 @@
else if (fGrammarType == Grammar::SchemaGrammarType)
{
elemDecl = fSchemaElemNonDeclPool->getByKey(nameRawBuf, uriId,
currentScope);
- }
-
- if (!elemDecl && ( fURIStringPool->getId(original_uriStr) != uriId)) {
+ }
+ // this is initialized correctly only if there is
+ // no element decl. The other uses in this scope will only
+ // be encountered if there continues to be no element decl--which
+ // implies that this will have been initialized correctly.
+ unsigned orgGrammarUri = uriId;
+ if (!elemDecl && ( orgGrammarUri = fURIStringPool->getId(original_uriStr))
!= uriId) {
// not found, switch to the specified grammar
const XMLCh* uriStr = getURIText(uriId);
bool errorCondition = !switchGrammar(uriStr) && fValidate;
@@ -2442,8 +2446,11 @@
if (!elemDecl) {
// still not found, fault this in and issue error later
- // switch back to original grammar first
- switchGrammar(original_uriStr);
+ // switch back to original grammar first if necessary
+ if(orgGrammarUri != uriId)
+ {
+ switchGrammar(original_uriStr);
+ }
if(fGrammarType == Grammar::DTDGrammarType)
{
elemDecl = new (fMemoryManager) DTDElementDecl
@@ -2579,8 +2586,11 @@
if (!elemDecl) {
// still not found, fault this in and issue error later
- // switch back to original grammar first
- switchGrammar(original_uriStr);
+ // switch back to original grammar first (if necessary)
+ if(orgGrammarUri != fEmptyNamespaceId)
+ {
+ switchGrammar(original_uriStr);
+ }
if(fGrammarType == Grammar::DTDGrammarType)
{
elemDecl = new (fMemoryManager) DTDElementDecl
1.85 +17 -6 xml-xerces/c/src/xercesc/internal/SGXMLScanner.cpp
Index: SGXMLScanner.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/SGXMLScanner.cpp,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- SGXMLScanner.cpp 21 Jun 2004 12:10:18 -0000 1.84
+++ SGXMLScanner.cpp 21 Jun 2004 18:02:13 -0000 1.85
@@ -1297,7 +1297,12 @@
// before we made grammars stateless:
elemDecl = fElemNonDeclPool->getByKey(nameRawBuf, uriId, currentScope);
}
- if (!elemDecl && ( fURIStringPool->getId(original_uriStr) != uriId)) {
+ // this is initialized correctly only if there is
+ // no element decl. The other uses in this scope will only
+ // be encountered if there continues to be no element decl--which
+ // implies that this will have been initialized correctly.
+ unsigned orgGrammarUri = uriId;
+ if (!elemDecl && ( orgGrammarUri = fURIStringPool->getId(original_uriStr))
!= uriId) {
// not found, switch to the specified grammar
const XMLCh* uriStr = getURIText(uriId);
bool errorCondition = !switchGrammar(uriStr) && fValidate;
@@ -1364,8 +1369,11 @@
if (!elemDecl) {
// still not found, fault this in and issue error later
- // switch back to original grammar first
- switchGrammar(original_uriStr);
+ // switch back to original grammar first (if necessary)
+ if(orgGrammarUri != uriId)
+ {
+ switchGrammar(original_uriStr);
+ }
elemDecl = new (fMemoryManager) SchemaElementDecl
(
fPrefixBuf.getRawBuffer()
@@ -1480,8 +1488,11 @@
if (!elemDecl) {
// still not found, fault this in and issue error later
- // switch back to original grammar first
- switchGrammar(original_uriStr);
+ // switch back to original grammar first (if necessary)
+ if(orgGrammarUri != fEmptyNamespaceId)
+ {
+ switchGrammar(original_uriStr);
+ }
elemDecl = new (fMemoryManager) SchemaElementDecl
(
fPrefixBuf.getRawBuffer()
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]