From 2ed67e2a9dca4141054ca3468c52ae39637f967e Mon Sep 17 00:00:00 2001 From: David Abram Cargill <cargilld@apache.org> Date: Tue, 26 Apr 2005 17:37:50 +0000 Subject: [PATCH] Prefix mapping update to handle schema correctly. git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@176392 13f79535-47bb-0310-9956-ffa450edef68 --- src/xercesc/internal/ElemStack.hpp | 17 +++++++++++++++++ src/xercesc/internal/IGXMLScanner.cpp | 14 ++++++++++++-- src/xercesc/internal/SGXMLScanner.cpp | 12 +++++++++++- src/xercesc/internal/XSAXMLScanner.cpp | 9 +++++++-- 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/xercesc/internal/ElemStack.hpp b/src/xercesc/internal/ElemStack.hpp index 812c89d07..83bcdc7de 100644 --- a/src/xercesc/internal/ElemStack.hpp +++ b/src/xercesc/internal/ElemStack.hpp @@ -16,6 +16,9 @@ /* * $Log$ + * Revision 1.12 2005/04/26 17:37:50 cargilld + * Prefix mapping update to handle schema correctly. + * * Revision 1.11 2004/09/08 13:56:13 peiyongz * Apache License Version 2.0 * @@ -192,6 +195,8 @@ public : unsigned int fCurrentURI; XMLCh * fSchemaElemName; unsigned int fSchemaElemNameMaxLen; + + int fPrefixColonPos; }; enum MapModes @@ -244,6 +249,9 @@ public : inline void setCurrentSchemaElemName(const XMLCh * const schemaElemName); inline XMLCh *getCurrentSchemaElemName(); + void setPrefixColonPos(int colonPos); + int getPrefixColonPos() const; + // ----------------------------------------------------------------------- // Prefix map methods // ----------------------------------------------------------------------- @@ -623,6 +631,15 @@ inline const XMLCh* ElemStack::getPrefixForId(unsigned int prefId) const return fPrefixPool.getValueForId(prefId); } +inline void ElemStack::setPrefixColonPos(int colonPos) +{ + fStack[fStackTop-1]->fPrefixColonPos = colonPos; +} + +inline int ElemStack::getPrefixColonPos() const { + return fStack[fStackTop-1]->fPrefixColonPos; +} + // --------------------------------------------------------------------------- // WFElemStack: Miscellaneous methods // --------------------------------------------------------------------------- diff --git a/src/xercesc/internal/IGXMLScanner.cpp b/src/xercesc/internal/IGXMLScanner.cpp index 77bc86edf..0ce93db9e 100644 --- a/src/xercesc/internal/IGXMLScanner.cpp +++ b/src/xercesc/internal/IGXMLScanner.cpp @@ -1160,13 +1160,22 @@ void IGXMLScanner::scanEndTag(bool& gotData) // If we have a doc handler, tell it about the end tag if (fDocHandler) - { + { + if (fGrammarType == Grammar::SchemaGrammarType) { + if (topElem->fPrefixColonPos != -1) + fPrefixBuf.set(elemName, topElem->fPrefixColonPos); + else + fPrefixBuf.reset(); + } + else { + fPrefixBuf.set(topElem->fThisElement->getElementName()->getPrefix()); + } fDocHandler->endElement ( *topElem->fThisElement , uriId , isRoot - , topElem->fThisElement->getElementName()->getPrefix() + , fPrefixBuf.getRawBuffer() ); } @@ -2203,6 +2212,7 @@ bool IGXMLScanner::scanStartTagNS(bool& gotData) // to expand up to get ready. unsigned int elemDepth = fElemStack.addLevel(); fElemStack.setValidationFlag(fValidate); + fElemStack.setPrefixColonPos(prefixColonPos); // Check if there is any external schema location specified, and if we are at root, // go through them first before scanning those specified in the instance document diff --git a/src/xercesc/internal/SGXMLScanner.cpp b/src/xercesc/internal/SGXMLScanner.cpp index 2c420ad29..c1a4cff67 100644 --- a/src/xercesc/internal/SGXMLScanner.cpp +++ b/src/xercesc/internal/SGXMLScanner.cpp @@ -1013,12 +1013,21 @@ void SGXMLScanner::scanEndTag(bool& gotData) // If we have a doc handler, tell it about the end tag if (fDocHandler) { + if (fGrammarType == Grammar::SchemaGrammarType) { + if (topElem->fPrefixColonPos != -1) + fPrefixBuf.set(elemName, topElem->fPrefixColonPos); + else + fPrefixBuf.reset(); + } + else { + fPrefixBuf.set(topElem->fThisElement->getElementName()->getPrefix()); + } fDocHandler->endElement ( *topElem->fThisElement , uriId , isRoot - , topElem->fThisElement->getElementName()->getPrefix() + , fPrefixBuf.getRawBuffer() ); } @@ -1155,6 +1164,7 @@ bool SGXMLScanner::scanStartTag(bool& gotData) // to expand up to get ready. unsigned int elemDepth = fElemStack.addLevel(); fElemStack.setValidationFlag(fValidate); + fElemStack.setPrefixColonPos(prefixColonPos); // Check if there is any external schema location specified, and if we are at root, // go through them first before scanning those specified in the instance document diff --git a/src/xercesc/internal/XSAXMLScanner.cpp b/src/xercesc/internal/XSAXMLScanner.cpp index 609018395..2358a2b8b 100644 --- a/src/xercesc/internal/XSAXMLScanner.cpp +++ b/src/xercesc/internal/XSAXMLScanner.cpp @@ -156,13 +156,17 @@ void XSAXMLScanner::scanEndTag(bool& gotData) // If we have a doc handler, tell it about the end tag if (fDocHandler) - { + { + if (topElem->fPrefixColonPos != -1) + fPrefixBuf.set(elemName, topElem->fPrefixColonPos); + else + fPrefixBuf.reset(); fDocHandler->endElement ( *topElem->fThisElement , uriId , isRoot - , topElem->fThisElement->getElementName()->getPrefix() + , fPrefixBuf.getRawBuffer() ); } @@ -259,6 +263,7 @@ bool XSAXMLScanner::scanStartTag(bool& gotData) // to expand up to get ready. unsigned int elemDepth = fElemStack.addLevel(); fElemStack.setValidationFlag(fValidate); + fElemStack.setPrefixColonPos(prefixColonPos); // Make an initial pass through the list and find any xmlns attributes or // schema attributes. -- GitLab