dbertoni 00/12/08 14:20:51
Modified: c/src/XSLT StylesheetHandler.cpp StylesheetHandler.hpp
Log:
Fixed bug where stylesheet text nodes were incorrectly preserved.
Revision Changes Path
1.48 +102 -77 xml-xalan/c/src/XSLT/StylesheetHandler.cpp
Index: StylesheetHandler.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetHandler.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- StylesheetHandler.cpp 2000/12/01 22:04:26 1.47
+++ StylesheetHandler.cpp 2000/12/08 22:20:50 1.48
@@ -1280,6 +1280,17 @@
if (m_exceptionPending == true)
return;
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::for_each;
+#endif
+
+ // Clean up the whitespace elements.
+ for_each(m_whiteSpaceElems.begin(),
+ m_whiteSpaceElems.end(),
+ DeleteFunctor<ElemTextLiteral>());
+
+ m_whiteSpaceElems.clear();
+
m_stylesheet.popNamespaces();
assert(m_elemStack.empty() == false);
@@ -1361,6 +1372,9 @@
if (m_exceptionPending == true)
return;
+ processText(chars, length);
+
+#if 0
if(m_inTemplate)
{
ElemTemplateElement* parent = m_elemStack.back();
@@ -1440,6 +1454,7 @@
}
// END SANJIVA CODE
// TODO: Flag error if text inside of stylesheet
+#endif
}
@@ -1452,85 +1467,9 @@
// if we have apending exception, we don't want to even try to process
this
if (m_exceptionPending == true)
return;
-
- if(m_inTemplate)
- {
- ElemTemplateElement* parent = m_elemStack.back();
-
- bool preserveSpace = false;
- bool disableOutputEscaping =
false;
-
- if(Constants::ELEMNAME_TEXT == parent->getXSLToken())
- {
-#if defined(XALAN_OLD_STYLE_CASTS)
- disableOutputEscaping =
((ElemText*)parent)->getDisableOutputEscaping();
-#else
- disableOutputEscaping =
static_cast<ElemText*>(parent)->getDisableOutputEscaping();
-#endif
- parent = m_elemStack[m_elemStack.size()-2];
- preserveSpace = true;
- }
-
- const Locator* const locator =
m_constructionContext.getLocatorFromStack();
-
- const int lineNumber = (0 != locator) ?
locator->getLineNumber() : 0;
- const int columnNumber = (0 != locator) ?
locator->getColumnNumber() : 0;
-
- ElemTextLiteral* elem = new
ElemTextLiteral(m_constructionContext,
- m_stylesheet,
- lineNumber, columnNumber,
- chars, 0, length,
- true, preserveSpace,
- disableOutputEscaping);
-
- const bool isWhite = isXMLWhitespace(chars, 0, length);
-
- if(preserveSpace || (!preserveSpace && !isWhite))
- {
- while(!m_whiteSpaceElems.empty())
- {
-
parent->appendChildElem(m_whiteSpaceElems.back());
-
- m_whiteSpaceElems.pop_back();
- }
-
- parent->appendChildElem(elem);
- }
- else if(isWhite)
- {
- bool
shouldPush = true;
-
- ElemTemplateElement* const last =
parent->getLastChildElem();
-
- if(0 != last)
- {
- // If it was surrounded by xsl:text, it will
count as an element.
- const bool isPrevCharData =
- Constants::ELEMNAME_TEXTLITERALRESULT
== last->getXSLToken();
-
- const bool isLastPoppedXSLText =
(m_lastPopped != 0) &&
- (Constants::ELEMNAME_TEXT ==
m_lastPopped->getXSLToken());
- if(isPrevCharData && ! isLastPoppedXSLText)
- {
- parent->appendChildElem(elem);
+ processText(chars, length);
- shouldPush = false;
- }
- }
-
- if(shouldPush)
- m_whiteSpaceElems.push_back(elem);
- }
- }
- // BEGIN SANJIVA CODE
- else if (m_inLXSLTScript)
- {
- append(m_LXSLTScriptBody, chars);
- }
- // END SANJIVA CODE
- // TODO: Flag error if text inside of stylesheet
-
m_lastPopped = 0;
}
@@ -1611,6 +1550,92 @@
return;
// No action for the moment.
+}
+
+
+
+void
+StylesheetHandler::processText(
+ const XMLCh* const chars,
+ const unsigned int length)
+{
+ if(m_inTemplate)
+ {
+ ElemTemplateElement* parent = m_elemStack.back();
+
+ bool preserveSpace = false;
+ bool disableOutputEscaping =
false;
+
+ if(Constants::ELEMNAME_TEXT == parent->getXSLToken())
+ {
+#if defined(XALAN_OLD_STYLE_CASTS)
+ disableOutputEscaping =
((ElemText*)parent)->getDisableOutputEscaping();
+#else
+ disableOutputEscaping =
static_cast<ElemText*>(parent)->getDisableOutputEscaping();
+#endif
+ parent = m_elemStack[m_elemStack.size()-2];
+ preserveSpace = true;
+ }
+
+ const Locator* const locator =
m_constructionContext.getLocatorFromStack();
+
+ const int lineNumber = (0 != locator) ?
locator->getLineNumber() : 0;
+ const int columnNumber = (0 != locator) ?
locator->getColumnNumber() : 0;
+
+ ElemTextLiteral* elem = new
ElemTextLiteral(m_constructionContext,
+ m_stylesheet,
+ lineNumber, columnNumber,
+ chars, 0, length,
+ true, preserveSpace,
+ disableOutputEscaping);
+
+ const bool isWhite = isXMLWhitespace(chars, 0, length);
+
+ if(preserveSpace || (!preserveSpace && !isWhite))
+ {
+ while(!m_whiteSpaceElems.empty())
+ {
+
parent->appendChildElem(m_whiteSpaceElems.back());
+
+ m_whiteSpaceElems.pop_back();
+ }
+
+ parent->appendChildElem(elem);
+ }
+ else if(isWhite)
+ {
+ bool
shouldPush = true;
+
+ ElemTemplateElement* const last =
parent->getLastChildElem();
+
+ if(0 != last)
+ {
+ // If it was surrounded by xsl:text, it will
count as an element.
+ const bool isPrevCharData =
+ Constants::ELEMNAME_TEXTLITERALRESULT
== last->getXSLToken();
+
+ const bool isLastPoppedXSLText =
(m_lastPopped != 0) &&
+ (Constants::ELEMNAME_TEXT ==
m_lastPopped->getXSLToken());
+
+ if(isPrevCharData && ! isLastPoppedXSLText)
+ {
+ parent->appendChildElem(elem);
+
+ shouldPush = false;
+ }
+ }
+
+ if(shouldPush)
+ m_whiteSpaceElems.push_back(elem);
+ }
+ }
+ // BEGIN SANJIVA CODE
+ else if (m_inLXSLTScript)
+ {
+ append(m_LXSLTScriptBody, chars);
+ }
+ // END SANJIVA CODE
+ // TODO: Flag error if text inside of stylesheet
}
1.20 +12 -2 xml-xalan/c/src/XSLT/StylesheetHandler.hpp
Index: StylesheetHandler.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetHandler.hpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- StylesheetHandler.hpp 2000/11/02 01:46:28 1.19
+++ StylesheetHandler.hpp 2000/12/08 22:20:50 1.20
@@ -402,10 +402,20 @@
private:
// not implemented
- StylesheetHandler(const StylesheetHandler &);
- StylesheetHandler& operator=(const StylesheetHandler &);
+ StylesheetHandler(const StylesheetHandler&);
+ StylesheetHandler&
+ operator=(const StylesheetHandler&);
+
+ // Utility function...
+ void
+ processText(
+ const XMLCh* const chars,
+ const unsigned int length);
+
+ // Data members...
XalanDOMString m_pendingException;
+
bool m_exceptionPending;
/**