dbertoni 01/06/25 14:58:57
Modified: c/src/XSLT ElemAttribute.cpp ElemComment.cpp ElemPI.cpp
ElemTemplateElement.cpp ElemTemplateElement.hpp
Log:
Generate attributes, comments, and PIs through ElemTemplateElement, to avoid
unnecessary use of cached strings.
Revision Changes Path
1.27 +3 -5 xml-xalan/c/src/XSLT/ElemAttribute.cpp
Index: ElemAttribute.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemAttribute.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- ElemAttribute.cpp 2001/06/25 20:17:17 1.26
+++ ElemAttribute.cpp 2001/06/25 21:58:51 1.27
@@ -370,11 +370,9 @@
// the result attribute.
if (indexOfNSSep == origAttrNameLength ||
!isEmpty(attrNameSpace))
{
- StylesheetExecutionContext::GetAndReleaseCachedString
theResult(executionContext);
-
- executionContext.addResultAttribute(
- attrName,
- childrenToString(executionContext,
theResult.get()));
+ childrenToResultAttribute(
+ executionContext,
+ attrName);
}
}
}
1.11 +1 -4 xml-xalan/c/src/XSLT/ElemComment.cpp
Index: ElemComment.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemComment.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ElemComment.cpp 2001/06/06 21:55:20 1.10
+++ ElemComment.cpp 2001/06/25 21:58:52 1.11
@@ -118,11 +118,8 @@
{
ElemTemplateElement::execute(executionContext);
- StylesheetExecutionContext::GetAndReleaseCachedString
theResult(executionContext);
-
-
executionContext.comment(c_wstr(childrenToString(executionContext,theResult.get())));
+ childrenToResultComment(executionContext);
}
-
1.15 +3 -3 xml-xalan/c/src/XSLT/ElemPI.cpp
Index: ElemPI.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemPI.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ElemPI.cpp 2001/06/06 21:55:26 1.14
+++ ElemPI.cpp 2001/06/25 21:58:52 1.15
@@ -150,9 +150,9 @@
StylesheetExecutionContext::GetAndReleaseCachedString
theResult(executionContext);
- executionContext.processingInstruction(
- c_wstr(piName),
- c_wstr(childrenToString(executionContext,theResult.get())));
+ childrenToResultPI(
+ executionContext,
+ piName);
}
1.60 +104 -21 xml-xalan/c/src/XSLT/ElemTemplateElement.cpp
Index: ElemTemplateElement.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTemplateElement.cpp,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- ElemTemplateElement.cpp 2001/06/22 17:15:55 1.59
+++ ElemTemplateElement.cpp 2001/06/25 21:58:53 1.60
@@ -344,6 +344,42 @@
+XalanDOMString&
+ElemTemplateElement::doChildrenToString(
+ StylesheetExecutionContext&
executionContext,
+ XalanDOMString& result)
const
+{
+ reserve(result, length(result) + 1024);
+
+ // Create a print writer and formatter to generate the children as
+ // a string.
+ DOMStringPrintWriter thePrintWriter(result);
+
+ // Borrow a FormatterToText, and don't normalize CR/LF, since we don't
want
+ // this text to be normalized. Finally, have the formatter handle any
ignorable
+ // whitespace events.
+ StylesheetExecutionContext::BorrowReturnFormatterToText theFormatter(
+ executionContext,
+ thePrintWriter,
+ false,
+ true);
+
+ // Create an object to set and restore the execution state.
+ StylesheetExecutionContext::OutputContextPushPop
theOutputContextPushPop(
+ executionContext,
+ theFormatter.get());
+
+ theFormatter->startDocument();
+
+ executeChildren(executionContext);
+
+ theFormatter->endDocument();
+
+ return result;
+}
+
+
+
const XalanDOMString&
ElemTemplateElement::childrenToString(
StylesheetExecutionContext&
executionContext,
@@ -351,37 +387,84 @@
{
if (hasSingleTextChild() == true)
{
+ assert(m_firstChild != 0);
+
return m_firstChild->getNodeValue();
}
else
{
- reserve(result, length(result) + 1024);
+ doChildrenToString(executionContext, result);
- // Create a print writer and formatter to generate the children
as
- // a string.
- DOMStringPrintWriter thePrintWriter(result);
-
- // Borrow a FormatterToText, and don't normalize CR/LF, since
we don't want
- // this text to be normalized. Finally, have the formatter
handle any ignorable
- // whitespace events.
- StylesheetExecutionContext::BorrowReturnFormatterToText
theFormatter(
- executionContext,
- thePrintWriter,
- false,
- true);
+ return result;
+ }
+}
- // Create an object to set and restore the execution state.
- StylesheetExecutionContext::OutputContextPushPop
theOutputContextPushPop(
- executionContext,
- theFormatter.get());
- theFormatter->startDocument();
- executeChildren(executionContext);
+void
+ElemTemplateElement::childrenToResultAttribute(
+ StylesheetExecutionContext&
executionContext,
+ const XalanDOMString& theName) const
+{
+ if (hasSingleTextChild() == true)
+ {
+ assert(m_firstChild != 0);
- theFormatter->endDocument();
+ executionContext.addResultAttribute(
+ theName,
+ m_firstChild->getNodeValue());
+ }
+ else
+ {
+ StylesheetExecutionContext::GetAndReleaseCachedString
theResult(executionContext);
- return result;
+ executionContext.addResultAttribute(
+ theName,
+ doChildrenToString(executionContext, theResult.get()));
+ }
+}
+
+
+
+void
+ElemTemplateElement::childrenToResultComment(StylesheetExecutionContext&
executionContext) const
+{
+ if (hasSingleTextChild() == true)
+ {
+ assert(m_firstChild != 0);
+
+ executionContext.comment(c_wstr(m_firstChild->getNodeValue()));
+ }
+ else
+ {
+ StylesheetExecutionContext::GetAndReleaseCachedString
theResult(executionContext);
+
+
executionContext.comment(c_wstr(doChildrenToString(executionContext,
theResult.get())));
+ }
+}
+
+
+
+void
+ElemTemplateElement::childrenToResultPI(
+ StylesheetExecutionContext&
executionContext,
+ const XalanDOMString& theTarget) const
+{
+ if (hasSingleTextChild() == true)
+ {
+ assert(m_firstChild != 0);
+
+ executionContext.processingInstruction(
+ c_wstr(theTarget),
+ c_wstr(m_firstChild->getNodeValue()));
+ }
+ else
+ {
+ StylesheetExecutionContext::GetAndReleaseCachedString
theResult(executionContext);
+
+ executionContext.processingInstruction(
+ c_wstr(theTarget),
+ c_wstr(doChildrenToString(executionContext,
theResult.get())));
}
}
1.31 +51 -2 xml-xalan/c/src/XSLT/ElemTemplateElement.hpp
Index: ElemTemplateElement.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTemplateElement.hpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- ElemTemplateElement.hpp 2001/06/06 21:55:28 1.30
+++ ElemTemplateElement.hpp 2001/06/25 21:58:54 1.31
@@ -222,7 +222,7 @@
StylesheetExecutionContext&
executionContext,
XalanNode*
sourceNode) const;
- /**
+ /**
* Take the contents of a template element, process it, and
* convert it to a string. Returns a const reference to
* the resulting string value. Note that this may _not_ be
@@ -235,9 +235,45 @@
*/
const XalanDOMString&
childrenToString(
- StylesheetExecutionContext&
executionContext,
+ StylesheetExecutionContext&
executionContext,
XalanDOMString& result)
const;
+ /**
+ * Take the contents of a template element, process it, and
+ * convert it to a string. Then, add an attribute to the
+ * result tree using the provided name and the string value.
+ *
+ * @param executionContext The current execution context
+ * @param theName The name for the result attribute
+ */
+ void
+ childrenToResultAttribute(
+ StylesheetExecutionContext&
executionContext,
+ const XalanDOMString& theName) const;
+
+ /**
+ * Take the contents of a template element, process it, and
+ * convert it to a string. Then, add a comment to the
+ * result tree using the string value.
+ *
+ * @param executionContext The current execution context
+ */
+ void
+ childrenToResultComment(StylesheetExecutionContext&
executionContext) const;
+
+ /**
+ * Take the contents of a template element, process it, and
+ * convert it to a string. Then, add a processing instruction
+ * to the result tree using the string value, and the provided
+ * target.
+ *
+ * @param executionContext The current execution context
+ * @param theName The name for the result attribute
+ */
+ void
+ childrenToResultPI(
+ StylesheetExecutionContext&
executionContext,
+ const XalanDOMString& theTarget)
const;
/**
* Get an integer representation of the element type.
@@ -760,6 +796,19 @@
static const XalanDOMString s_emptyString;
private:
+
+ /**
+ * Take the contents of a template element, process it, and
+ * convert it to a string.
+ *
+ * @param executionContext The current execution context
+ * @param result result of executing the elements children
+ * @result a reference to a string containing the result.
+ */
+ XalanDOMString&
+ doChildrenToString(
+ StylesheetExecutionContext&
executionContext,
+ XalanDOMString& result)
const;
Stylesheet& m_stylesheet;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]