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...@locus.apache.org on 2000/04/13 18:49:01 UTC
cvs commit: xml-xalan/c/src/XSLT StylesheetHandler.cpp StylesheetHandler.hpp
dbertoni 00/04/13 09:49:01
Modified: c/src/XSLT StylesheetHandler.cpp StylesheetHandler.hpp
Log:
Fixed handling of ElemTextLiteral.
Revision Changes Path
1.18 +32 -14 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.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- StylesheetHandler.cpp 2000/04/13 16:11:01 1.17
+++ StylesheetHandler.cpp 2000/04/13 16:49:00 1.18
@@ -118,12 +118,15 @@
Stylesheet& stylesheetTree,
StylesheetConstructionContext& constructionContext) :
FormatterListener(),
+ m_includeBase(stylesheetTree.getBaseIdentifier()),
m_pendingException(),
m_exceptionPending(false),
m_processor(processor),
m_stylesheet(stylesheetTree),
m_constructionContext(constructionContext),
- m_includeBase(stylesheetTree.getBaseIdentifier()),
+ m_elemStack(),
+ m_strayElements(),
+ m_whiteSpaceElems(),
m_pTemplate(0),
m_lastPopped(0),
m_inTemplate(false),
@@ -133,8 +136,7 @@
m_LXSLTScriptBody(),
m_LXSLTScriptLang(),
m_LXSLTScriptSrcURL(),
- m_pLXSLTExtensionNSH(0),
- m_elemStack()
+ m_pLXSLTExtensionNSH(0)
{
}
@@ -155,6 +157,11 @@
for_each(m_whiteSpaceElems.begin(),
m_whiteSpaceElems.end(),
DeleteFunctor<ElemTemplateElement>());
+
+ // Clean up the stray elements.
+ for_each(m_strayElements.begin(),
+ m_strayElements.end(),
+ DeleteFunctor<ElemTemplateElement>());
}
@@ -1170,7 +1177,6 @@
PushPopIncludeState theStateHandler(*this);
- m_lastPopped = 0;
const XalanDOMString href = atts.getValue(i);
assert(m_stylesheet.getIncludeStack().back() != 0);
@@ -1186,9 +1192,8 @@
m_stylesheet.getIncludeStack().push_back(hrefUrl);
m_processor.parseXML(*hrefUrl, this, &m_stylesheet);
-
- m_stylesheet.getIncludeStack().pop_back();
+ m_stylesheet.getIncludeStack().pop_back();
}
else if(!isAttrOK(aname, atts, i))
{
@@ -1242,8 +1247,9 @@
else if (tok == Constants::ELEMNAME_UNDEFINED ||
tok == Constants::ELEMNAME_TEXT)
{
- // These are stray elements, so delete them...
- delete m_lastPopped;
+ // These are stray elements, so stuff them away
+ // to be deleted when we're finished...
+ m_strayElements.push_back(m_lastPopped);
}
// BEGIN SANJIVA CODE
@@ -1304,7 +1310,7 @@
m_stylesheet,
lineNumber, columnNumber,
chars, 0, length,
- true, preserveSpace,
+ false, preserveSpace,
disableOutputEscaping);
const bool isWhite = isWhiteSpace(chars, 0, length);
@@ -1330,10 +1336,9 @@
if(0 != last)
{
- ElemTemplateElement* lastElem = dynamic_cast<ElemTemplateElement*>(last);
// If it was surrounded by xsl:text, it will count as an element.
bool isPrevCharData =
- Constants::ELEMNAME_TEXTLITERALRESULT == lastElem->getXSLToken();
+ Constants::ELEMNAME_TEXTLITERALRESULT == last->getXSLToken();
bool isLastPoppedXSLText = (m_lastPopped != 0) &&
(Constants::ELEMNAME_TEXT == m_lastPopped->getXSLToken());
@@ -1357,9 +1362,12 @@
}
// END SANJIVA CODE
// TODO: Flag error if text inside of stylesheet
+
+// m_lastPopped = 0;
}
+
void StylesheetHandler::cdata(const XMLCh* const chars, const unsigned int length)
{
// if we have apending exception, we don't want to even try to process this
@@ -1413,10 +1421,16 @@
if(0 != last)
{
- if(Constants::ELEMNAME_TEXTLITERALRESULT == last->getXSLToken() &&
- static_cast<ElemTextLiteral*>(last)->isPreserveSpace() == false)
+ // If it was surrounded by xsl:text, it will count as an element.
+ bool isPrevCharData =
+ Constants::ELEMNAME_TEXTLITERALRESULT == last->getXSLToken();
+ bool isLastPoppedXSLText = (m_lastPopped != 0) &&
+ (Constants::ELEMNAME_TEXT == m_lastPopped->getXSLToken());
+
+ if(isPrevCharData && ! isLastPoppedXSLText)
{
parent->appendChildElem(elem);
+
shouldPush = false;
}
}
@@ -1432,6 +1446,8 @@
}
// END SANJIVA CODE
// TODO: Flag error if text inside of stylesheet
+
+ m_lastPopped = 0;
}
@@ -1442,6 +1458,8 @@
return;
// Ignore!
+
+ m_lastPopped = 0;
}
@@ -1451,7 +1469,7 @@
if (m_exceptionPending == true)
return;
- // No action for the moment.
+ m_lastPopped = 0;
}
1.11 +5 -0 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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- StylesheetHandler.hpp 2000/04/12 19:41:02 1.10
+++ StylesheetHandler.hpp 2000/04/13 16:49:00 1.11
@@ -424,6 +424,11 @@
ElemTemplateStackType m_elemStack;
/**
+ * The stack of stray elements, to be delete when finished.
+ */
+ ElemTemplateStackType m_strayElements;
+
+ /**
* Need to keep a stack of found whitespace elements so that
* whitespace elements next to non-whitespace elements can
* be merged. For instance: <out> <![CDATA[test]]> </out>