You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2001/08/13 19:14:45 UTC
cvs commit: xml-xalan/c/src/XalanSourceTree XalanSourceTreeContentHandler.cpp XalanSourceTreeContentHandler.hpp
dbertoni 01/08/13 10:14:45
Modified: c/src/XalanSourceTree XalanSourceTreeContentHandler.cpp
XalanSourceTreeContentHandler.hpp
Log:
Make sure comments in DTDs are not passed through to the source tree.
Revision Changes Path
1.8 +49 -10 xml-xalan/c/src/XalanSourceTree/XalanSourceTreeContentHandler.cpp
Index: XalanSourceTreeContentHandler.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanSourceTree/XalanSourceTreeContentHandler.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XalanSourceTreeContentHandler.cpp 2001/08/07 18:41:49 1.7
+++ XalanSourceTreeContentHandler.cpp 2001/08/13 17:14:45 1.8
@@ -84,7 +84,8 @@
m_lastChild(0),
m_lastChildStack(),
m_accumulateText(fAccumulateText),
- m_textBuffer()
+ m_textBuffer(),
+ m_inDTD(false)
{
}
@@ -101,6 +102,8 @@
const XMLCh* const chars,
const unsigned int length)
{
+ assert(m_inDTD == false);
+
if (m_currentElement == 0)
{
if (isXMLWhitespace(chars) == false)
@@ -123,6 +126,8 @@
void
XalanSourceTreeContentHandler::endDocument()
{
+ assert(m_inDTD == false);
+
// Pop off the dummy value that we pushed in
// startDocument()...
m_elementStack.pop_back();
@@ -143,6 +148,8 @@
const XMLCh* const /* localname */,
const XMLCh* const /* qname */)
{
+ assert(m_inDTD == false);
+
// Process any text that we may have accumulated...
processAccumulatedText();
@@ -224,6 +231,8 @@
const XMLCh* const chars,
const unsigned int length)
{
+ assert(m_inDTD == false);
+
// Ignore any whitespace reported before the document element has been parsed.
if (m_elementStack.empty() == false)
{
@@ -245,6 +254,8 @@
const XMLCh* const target,
const XMLCh* const data)
{
+ assert(m_inDTD == false);
+
processAccumulatedText();
XalanSourceTreeProcessingInstruction* const theNewPI =
@@ -269,6 +280,8 @@
void
XalanSourceTreeContentHandler::startDocument()
{
+ assert(m_inDTD == false);
+
m_currentElement = 0;
m_elementStack.clear();
@@ -302,6 +315,15 @@
const XMLCh* const qname,
const Attributes& attrs)
{
+ // $$$ ToDo: This is a workaround for a bug in Xerces 1.5.1.
+#if 1
+ if (m_currentElement == 0 && m_inDTD == true)
+ {
+ m_inDTD = false;
+ }
+#endif
+ assert(m_inDTD == false);
+
processAccumulatedText();
XalanSourceTreeElement* const theNewElement =
@@ -329,6 +351,7 @@
const XMLCh* const /* prefix */,
const XMLCh* const /* uri */)
{
+ assert(m_inDTD == false);
}
@@ -336,6 +359,7 @@
void
XalanSourceTreeContentHandler::endPrefixMapping(const XMLCh* const /* prefix */)
{
+ assert(m_inDTD == false);
}
@@ -385,16 +409,19 @@
{
assert(m_document != 0);
- processAccumulatedText();
+ if (m_inDTD == false)
+ {
+ processAccumulatedText();
- XalanSourceTreeComment* const theNewComment =
- m_document->createCommentNode(chars, length, m_currentElement);
+ XalanSourceTreeComment* const theNewComment =
+ m_document->createCommentNode(chars, length, m_currentElement);
- doAppendChildNode(
- m_document,
- m_currentElement,
- m_lastChild,
- theNewComment);
+ doAppendChildNode(
+ m_document,
+ m_currentElement,
+ m_lastChild,
+ theNewComment);
+ }
}
@@ -402,6 +429,7 @@
void
XalanSourceTreeContentHandler::endCDATA()
{
+ assert(m_inDTD == false);
}
@@ -409,8 +437,9 @@
void
XalanSourceTreeContentHandler::endDTD()
{
- assert(m_document != 0);
+ m_inDTD = false;
+ assert(m_document != 0);
}
@@ -425,6 +454,7 @@
void
XalanSourceTreeContentHandler::startCDATA()
{
+ assert(m_inDTD == false);
}
@@ -435,7 +465,10 @@
const XMLCh* const publicId,
const XMLCh* const systemId)
{
+ assert(m_inDTD == false);
assert(m_document != 0);
+
+ m_inDTD = true;
}
@@ -464,6 +497,8 @@
const Attributes& attrs,
XalanSourceTreeElement* theOwnerElement)
{
+ assert(m_inDTD == false);
+
if (length(uri) != 0)
{
return m_document->createElementNode(uri, localname, qname, attrs, theOwnerElement);
@@ -479,6 +514,8 @@
void
XalanSourceTreeContentHandler::processAccumulatedText()
{
+ assert(m_inDTD == false);
+
if (isEmpty(m_textBuffer) == false)
{
doCharacters(c_wstr(m_textBuffer), length(m_textBuffer));
@@ -494,6 +531,8 @@
const XMLCh* chars,
unsigned int length)
{
+ assert(m_inDTD == false);
+
assert(m_currentElement != 0);
XalanSourceTreeText* theNewTextNode =
1.6 +3 -0 xml-xalan/c/src/XalanSourceTree/XalanSourceTreeContentHandler.hpp
Index: XalanSourceTreeContentHandler.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanSourceTree/XalanSourceTreeContentHandler.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XalanSourceTreeContentHandler.hpp 2001/08/06 01:37:01 1.5
+++ XalanSourceTreeContentHandler.hpp 2001/08/13 17:14:45 1.6
@@ -277,6 +277,9 @@
// A buffer to hold accumulated text.
XalanDOMString m_textBuffer;
+
+ // A flag to determine if the DTD is being processed.
+ bool m_inDTD;
};
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org