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/27 17:14:18 UTC
cvs commit: xml-xalan/c/src/XSLT ElemTemplateElement.cpp StylesheetExecutionContext.hpp StylesheetHandler.cpp XSLTEngineImpl.cpp XSLTEngineImpl.hpp
dbertoni 00/04/27 08:14:18
Modified: c/src/XSLT ElemTemplateElement.cpp
StylesheetExecutionContext.hpp
StylesheetHandler.cpp XSLTEngineImpl.cpp
XSLTEngineImpl.hpp
Log:
Removed deprecated CSS support, and created objects to safely set and restore execution state.
Revision Changes Path
1.17 +29 -74 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.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ElemTemplateElement.cpp 2000/04/20 18:22:51 1.16
+++ ElemTemplateElement.cpp 2000/04/27 15:14:15 1.17
@@ -318,57 +318,19 @@
XalanNode* sourceTree,
XalanNode* sourceNode,
const QName& mode) const
-{
- FormatterListener* const savedFListener = executionContext.getFormatterListener();
-
+{
+ // Create a print writer and formatter to generate the children as
+ // a string.
DOMStringPrintWriter thePrintWriter;
FormatterToText theFormatter(thePrintWriter);
-
- try
- {
- executionContext.setFormatterListener(&theFormatter);
-
- const XalanDOMString savedPendingName = executionContext.getPendingElementName();
-
- try
- {
- executionContext.setPendingElementName(XalanDOMString());
-
- const AttributeListImpl savedPendingAttributes(executionContext.getPendingAttributes());
-
- try
- {
- executionContext.setPendingAttributes(AttributeListImpl());
- executeChildren(executionContext, sourceTree, sourceNode, mode);
- }
- catch(...)
- {
- executionContext.setPendingAttributes(savedPendingAttributes);
-
- throw;
- }
-
- executionContext.setPendingAttributes(savedPendingAttributes);
- }
- catch(...)
- {
- executionContext.setPendingElementName(savedPendingName);
-
- throw;
- }
-
- executionContext.setPendingElementName(savedPendingName);
- }
- catch(...)
- {
- executionContext.setFormatterListener(savedFListener);
-
- throw;
- }
+ // Create an object to set and restore the execution state.
+ StylesheetExecutionContext::ExecutionStateSetAndRestore theStateSetAndRestore(
+ executionContext,
+ &theFormatter);
- executionContext.setFormatterListener(savedFListener);
+ executeChildren(executionContext, sourceTree, sourceNode, mode);
return thePrintWriter.getString();
}
@@ -654,7 +616,7 @@
}
// @@ JMD: Now in method processSortKeys in java ...
- MutableNodeRefList sourceNodes;
+ MutableNodeRefList sourceNodes = executionContext.createMutableNodeRefList();
/*
@@@ JMD: This is newer java code that is not implemented in C++; so, the
@@ -704,6 +666,7 @@
result));
}
}
+
executionContext.setCurrentStackFrameIndex(savedCurrentStackFrameIndex);
}
else if (keys.size() > 0)
@@ -724,30 +687,31 @@
executionContext.setCurrentStackFrameIndex(savedCurrentStackFrameIndex);
}
- const MutableNodeRefList savedContextNodeList(executionContext.getContextNodeList());
+ // Create an object to set and restore the context node list...
+ StylesheetExecutionContext::ContextNodeListSetAndRestore theSetAndRestore(
+ executionContext,
+ sourceNodes);
- executionContext.setContextNodeList(sourceNodes);
-
- try
+ if(executionContext.isTraceSelect())
{
- if(executionContext.isTraceSelect())
- executionContext.traceSelect(
- xslInstruction,
- sourceNodes);
+ executionContext.traceSelect(
+ xslInstruction,
+ sourceNodes);
+ }
- for(unsigned int i = 0; i < nNodes; i++)
- {
- XalanNode* childNode = sourceNodes.item(i);
- assert(childNode != 0);
+ for(unsigned int i = 0; i < nNodes; i++)
+ {
+ XalanNode* childNode = sourceNodes.item(i);
+ assert(childNode != 0);
- XalanDocument* const ownerDoc = childNode->getOwnerDocument();
+ XalanDocument* const ownerDoc = childNode->getOwnerDocument();
- if(XalanNode::DOCUMENT_NODE != childNode->getNodeType() && ownerDoc == 0)
- {
- error(XalanDOMString("Child node does not have an owner document!"));
- }
+ if(XalanNode::DOCUMENT_NODE != childNode->getNodeType() && ownerDoc == 0)
+ {
+ error(XalanDOMString("Child node does not have an owner document!"));
+ }
- transformChild(
+ transformChild(
executionContext,
stylesheetTree,
&xslInstruction,
@@ -757,16 +721,7 @@
childNode,
mode,
xslToken);
- }
}
- catch(...)
- {
- executionContext.setContextNodeList(savedContextNodeList);
-
- throw;
- }
-
- executionContext.setContextNodeList(savedContextNodeList);
}
}
1.9 +167 -28 xml-xalan/c/src/XSLT/StylesheetExecutionContext.hpp
Index: StylesheetExecutionContext.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContext.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- StylesheetExecutionContext.hpp 2000/04/25 19:54:14 1.8
+++ StylesheetExecutionContext.hpp 2000/04/27 15:14:15 1.9
@@ -83,7 +83,10 @@
-class AttributeList;
+#include <PlatformSupport/AttributeListImpl.hpp>
+
+
+
class ElemTemplateElement;
class FormatterListener;
class PrefixResolver;
@@ -220,14 +223,6 @@
const void* theKey) = 0;
/**
- * Retrieve list of attributes yet to be processed
- *
- * @return attribute list
- */
- virtual const AttributeList&
- getPendingAttributes() const = 0;
-
- /**
* Retrieve name of the pending element currently being processed.
*
* @return element name
@@ -236,6 +231,22 @@
getPendingElementName() const = 0;
/**
+ * Changes the currently pending element name.
+ *
+ * @param elementName new name of element
+ */
+ virtual void
+ setPendingElementName(const XalanDOMString& elementName) = 0;
+
+ /**
+ * Retrieve list of attributes yet to be processed
+ *
+ * @return attribute list
+ */
+ virtual const AttributeList&
+ getPendingAttributes() const = 0;
+
+ /**
* Sets a list of attributes yet to be processed.
*
* @param pendingAttributes attribute list
@@ -258,13 +269,157 @@
const XalanDOMChar* theNewValue) = 0;
/**
- * Changes the currently pending element name.
+ * Get the current formatter listener.
*
- * @param elementName new name of element
+ * @return pointer to formatter listener
*/
+ virtual FormatterListener*
+ getFormatterListener() const = 0;
+
+ /**
+ * Set the current formatter listener.
+ *
+ * @param flistener pointer to new formatter listener
+ */
virtual void
- setPendingElementName(const XalanDOMString& elementName) = 0;
+ setFormatterListener(FormatterListener* flistener) = 0;
+
+ // These next four classes are used to save and restore
+ // the execution state in an automated, and exception-safe
+ // manner.
+
+ class FormatterListenerSetAndRestore
+ {
+ public:
+
+ /**
+ * Construct an object to set and restore the current formatter listener.
+ *
+ * @param theExecutionContext a reference to the current execution context
+ * @param theNewListener the new listener to set.
+ */
+ FormatterListenerSetAndRestore(
+ StylesheetExecutionContext& theExecutionContext,
+ FormatterListener* theNewListener = 0) :
+ m_executionContext(theExecutionContext),
+ m_savedListener(theExecutionContext.getFormatterListener())
+ {
+ theExecutionContext.setFormatterListener(theNewListener);
+ }
+
+ ~FormatterListenerSetAndRestore()
+ {
+ m_executionContext.setFormatterListener(m_savedListener);
+ }
+
+ private:
+
+ StylesheetExecutionContext& m_executionContext;
+
+ FormatterListener* const m_savedListener;
+ };
+
+ class PendingElementNameSetAndRestore
+ {
+ public:
+
+ /**
+ * Construct an object to set and restore the current pending element name.
+ *
+ * @param theExecutionContext a reference to the current execution context
+ * @param theNewPendingElementName the new pending element name to set.
+ */
+ PendingElementNameSetAndRestore(
+ StylesheetExecutionContext& theExecutionContext,
+ const XalanDOMString& theNewPendingElementName = XalanDOMString()) :
+ m_executionContext(theExecutionContext),
+ m_savedPendingElementName(theExecutionContext.getPendingElementName())
+ {
+ theExecutionContext.setPendingElementName(theNewPendingElementName);
+ }
+
+ ~PendingElementNameSetAndRestore()
+ {
+ m_executionContext.setPendingElementName(m_savedPendingElementName);
+ }
+
+ private:
+
+ StylesheetExecutionContext& m_executionContext;
+
+ const DOMString m_savedPendingElementName;
+ };
+
+ class PendingAttributesSetAndRestore
+ {
+ public:
+
+ /**
+ * Construct an object to set and restore the current pending attributes.
+ *
+ * @param theExecutionContext a reference to the current execution context
+ * @param theNewPendingAttributes the new pending attributes to set.
+ */
+ PendingAttributesSetAndRestore(
+ StylesheetExecutionContext& theExecutionContext,
+ const AttributeListImpl& theNewPendingAttributes = AttributeListImpl()) :
+ m_executionContext(theExecutionContext),
+ m_savedPendingAttributes(theExecutionContext.getPendingAttributes())
+ {
+ theExecutionContext.setPendingAttributes(theNewPendingAttributes);
+ }
+
+ ~PendingAttributesSetAndRestore()
+ {
+ m_executionContext.setPendingAttributes(m_savedPendingAttributes);
+ }
+
+ private:
+
+ StylesheetExecutionContext& m_executionContext;
+
+ const AttributeListImpl m_savedPendingAttributes;
+ };
+
+ class ExecutionStateSetAndRestore
+ {
+ public:
+
+ /**
+ * Construct an object to set and restore the current execution state.
+ *
+ * @param theExecutionContext a reference to the current execution context
+ * @param theNewListener the new listener to set.
+ * @param theNewPendingElementName the new pending element name to set.
+ * @param theNewPendingAttributes the new pending attributes to set.
+ */
+ ExecutionStateSetAndRestore(
+ StylesheetExecutionContext& theExecutionContext,
+ FormatterListener* theNewListener = 0,
+ const XalanDOMString& theNewPendingElementName = XalanDOMString(),
+ const AttributeListImpl& theNewPendingAttributes = AttributeListImpl()) :
+ m_formatterListenerSetAndRestore(theExecutionContext,
+ theNewListener),
+ m_pendingElementNameSetAndRestore(theExecutionContext,
+ theNewPendingElementName),
+ m_pendingAttributesSetAndRestore(theExecutionContext,
+ theNewPendingAttributes)
+ {
+ }
+
+ ~ExecutionStateSetAndRestore()
+ {
+ }
+
+ private:
+ FormatterListenerSetAndRestore m_formatterListenerSetAndRestore;
+
+ PendingElementNameSetAndRestore m_pendingElementNameSetAndRestore;
+
+ PendingAttributesSetAndRestore m_pendingAttributesSetAndRestore;
+ };
+
/**
* Add a result attribute to the list of pending attributes.
*
@@ -311,22 +466,6 @@
*/
virtual XalanDOMString
getUniqueNameSpaceValue() const = 0;
-
- /**
- * Get the current formatter listener.
- *
- * @return pointer to formatter listener
- */
- virtual FormatterListener*
- getFormatterListener() const = 0;
-
- /**
- * Set the current formatter listener.
- *
- * @param flistener pointer to new formatter listener
- */
- virtual void
- setFormatterListener(FormatterListener* flistener) = 0;
/**
* Retrieve the current number of spaces to indent.
1.21 +0 -4 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.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- StylesheetHandler.cpp 2000/04/20 16:47:35 1.20
+++ StylesheetHandler.cpp 2000/04/27 15:14:15 1.21
@@ -312,10 +312,6 @@
m_stylesheet.addTemplate(m_pTemplate);
break;
- case Constants::ELEMNAME_CSSSTYLECONVERSION:
- m_processor.setTranslateCSS(true);
- break;
-
case Constants::ELEMNAME_EXTENSION:
if(!equalsIgnoreCase(ns, m_processor.getXalanXSLNameSpaceURL()))
{
1.30 +207 -369 xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp
Index: XSLTEngineImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- XSLTEngineImpl.cpp 2000/04/25 19:54:17 1.29
+++ XSLTEngineImpl.cpp 2000/04/27 15:14:15 1.30
@@ -197,8 +197,6 @@
m_resultNameSpaceURL(),
m_stylesheets(),
m_currentNode(),
- m_cssKeys(),
- m_translateCSS(false),
m_pendingElementName(),
m_pendingAttributes(),
m_resultNameSpaces(),
@@ -230,7 +228,7 @@
m_xpathSupport(xpathSupport),
m_xpathEnvSupport(xpathEnvSupport),
m_flistener(0),
- m_contextNodeList(),
+ m_contextNodeList(&xpathSupport),
m_namedTemplates(),
m_topLevelVariables(),
m_needToCheckForInfiniteLoops(false),
@@ -342,7 +340,7 @@
void
XSLTEngineImpl::setPendingElementName(const XalanDOMString& elementName)
{
- m_pendingElementName = elementName;
+ m_pendingElementName = elementName;
}
@@ -2016,6 +2014,52 @@
}
+
+class StatePushPop
+{
+public:
+
+ StatePushPop(
+ FormatterListener*& theCurrentListener,
+ FormatterListener* theNewListener,
+ DOMString& thePendingElementName,
+ AttributeListImpl& thePendingAttributes) :
+ m_listener(theCurrentListener),
+ m_savedListener(theCurrentListener),
+ m_pendingElementName(thePendingElementName),
+ m_savedPendingElementName(thePendingElementName),
+ m_pendingAttributes(thePendingAttributes),
+ m_savedPendingAttributes(thePendingAttributes)
+ {
+ theCurrentListener = theNewListener;
+
+ clear(m_pendingElementName);
+
+ m_pendingAttributes.clear();
+ }
+
+ ~StatePushPop()
+ {
+ m_listener = m_savedListener;
+ m_pendingElementName = m_savedPendingElementName;
+ m_pendingAttributes = m_savedPendingAttributes;
+ }
+
+private:
+
+ FormatterListener*& m_listener;
+ FormatterListener* const m_savedListener;
+
+ DOMString& m_pendingElementName;
+ const DOMString m_savedPendingElementName;
+
+ AttributeListImpl& m_pendingAttributes;
+ const AttributeListImpl m_savedPendingAttributes;
+};
+
+
+
+
// @@ java: DocumentFragment
ResultTreeFragBase*
XSLTEngineImpl::createResultTreeFrag(
@@ -2025,8 +2069,6 @@
XalanNode* sourceNode,
const QName& mode)
{
- FormatterListener* const savedFormatterListener = m_flistener;
-
#if !defined(XALAN_NO_NAMESPACES)
using std::auto_ptr;
#endif
@@ -2035,25 +2077,21 @@
FormatterToDOM tempFormatter(m_resultTreeFactory,
pfrag.get());
-
- const XalanDOMString savedPendingName = m_pendingElementName;
- clear(m_pendingElementName);
-
- AttributeListImpl savedPendingAttributes(m_pendingAttributes);
- m_pendingAttributes.clear();
- m_flistener = &tempFormatter;
+ StatePushPop theStateSaver(
+ m_flistener,
+ &tempFormatter,
+ m_pendingElementName,
+ m_pendingAttributes);
templateChild.executeChildren(executionContext, sourceTree, sourceNode, mode);
- // flushPending();
- m_flistener = savedFormatterListener;
- m_pendingElementName = savedPendingName;
- m_pendingAttributes = savedPendingAttributes;
-
return pfrag.release();
}
+
+
+// $$$ ToDo: This is not called anywhere, can it be removed?
void
XSLTEngineImpl::writeChildren(
FormatterListener* flistener,
@@ -2065,22 +2103,19 @@
{
flushPending();
- FormatterListener* const savedFormatterListener = m_flistener;
- XalanDOMString savedPendingName = m_pendingElementName;
- m_pendingElementName = 0;
- AttributeListImpl savedPendingAttributes = m_pendingAttributes;
- m_pendingAttributes.clear();
- m_flistener = flistener;
-
+ StatePushPop theStateSaver(
+ m_flistener,
+ flistener,
+ m_pendingElementName,
+ m_pendingAttributes);
+
templateParent.executeChildren(executionContext, &sourceTree, &sourceNode, mode);
flushPending();
- m_flistener = savedFormatterListener;
- m_pendingElementName = savedPendingName;
- m_pendingAttributes = savedPendingAttributes;
}
+
void
XSLTEngineImpl::outputResultTreeFragment(const XObject& theTree)
{
@@ -2144,11 +2179,9 @@
}
-/**
- * Tell if a given element name should output its text as cdata.
- */
+
bool
-XSLTEngineImpl::isCDataResultElem(const XalanDOMString& elementName)
+XSLTEngineImpl::isCDataResultElem(const XalanDOMString& elementName)
{
typedef Stylesheet::QNameVectorType QNameVectorType;
@@ -2189,22 +2222,23 @@
elemLocalName = substring(elementName, indexOfNSSep + 1);
}
- for(Stylesheet::QNameVectorType::size_type i = 0; i < theSize; i++)
+ for(Stylesheet::QNameVectorType::size_type i = 0; i < theSize && is == false; i++)
{
const QName& qname = cdataElems[i];
is = qname.equals(QName(elemNS, elemLocalName));
-
- if(is)
- break;
}
}
return is;
}
+
-bool XSLTEngineImpl::qnameEqualsResultElemName(const QName& qname, const XalanDOMString& elementName)
+bool
+XSLTEngineImpl::qnameEqualsResultElemName(
+ const QName& qname,
+ const XalanDOMString& elementName)
{
XalanDOMString elemNS;
XalanDOMString elemLocalName;
@@ -2223,19 +2257,24 @@
{
elemNS = getResultNamespaceForPrefix(prefix);
}
+
if(0 == elemNS.length())
{
error(XalanDOMString("Prefix must resolve to a namespace: ") + prefix);
- // throw new RuntimeException(+prefix);
}
+
elemLocalName = substring(elementName, indexOfNSSep+1);
}
else
+ {
elemLocalName = elementName;
+ }
return qname.equals(QName(elemNS, elemLocalName));
}
+
+
XalanDOMString
XSLTEngineImpl::getResultNamespaceForPrefix(const XalanDOMString& prefix) const
{
@@ -2453,7 +2492,7 @@
*/
XPath*
XSLTEngineImpl::createXPath(
- const XalanDOMString& str,
+ const XalanDOMString& str,
const PrefixResolver& resolver)
{
XPath* const xpath = m_xpathFactory.create();
@@ -2513,12 +2552,13 @@
XPath* XSLTEngineImpl::getExpression(
- AttributeList& attrs,
- const XalanDOMString& key,
- const PrefixResolver& resolver)
+ const AttributeList& attrs,
+ const XalanDOMString& key,
+ const PrefixResolver& resolver)
{
- const XMLCh* val = attrs.getValue(c_wstr(key));
- return (0 != val) ? createXPath(XalanDOMString(val), resolver) : 0;
+ const XMLCh* const val = attrs.getValue(c_wstr(key));
+
+ return 0 != val ? createXPath(XalanDOMString(val), resolver) : 0;
}
@@ -2529,7 +2569,6 @@
const XalanDOMString& key,
const XalanNode& /* contextNode */ )
{
- // @@ JMD: context not used
return getAttrVal(el, key);
}
@@ -2537,10 +2576,10 @@
XalanDOMString
XSLTEngineImpl::getAttrVal(
- const XalanElement& el,
+ const XalanElement& el,
const XalanDOMString& key)
{
- const XalanAttr* a = el.getAttributeNode(key);
+ const XalanAttr* const a = el.getAttributeNode(key);
return 0 == a ? XalanDOMString() : a->getValue();
}
@@ -2803,191 +2842,6 @@
-void
-XSLTEngineImpl::translateCSSAttrsToStyleAttr(AttributeListImpl& attList)
-{
- if(m_translateCSS == true)
- {
-#if !defined(XALAN_NO_NAMESPACES)
- using std::vector;
-#endif
-
- XalanDOMString styleAttrValueString;
- vector<const XMLCh*> toBeRemoved;
- const unsigned int nAttributes = attList.getLength();
- for(unsigned int i = 0; i < nAttributes; i++)
- {
- const XMLCh* const attrName = attList.getName(i);
- if(isCSSAttribute(attrName) == true)
- {
- toBeRemoved.push_back(attrName);
- if(0 == length(styleAttrValueString))
- {
- // $$$ ToDo: Fix this when XalanDOMString::operator+() is const.
- styleAttrValueString = attrName;
- styleAttrValueString += ":";
- styleAttrValueString += attList.getValue(i);
-// styleAttrValueString = attrName+":"+attList.getValue(i);
- }
- else
- {
- // $$$ ToDo: Fix this when XalanDOMString::operator+() is const.
- styleAttrValueString += "; ";
- styleAttrValueString += attrName;
- styleAttrValueString += ":";
- styleAttrValueString += attList.getValue(i);
-// styleAttrValueString += "; "+attrName+":"+attList.getValue(i);
- }
- }
- }
- const unsigned int nAttrsToRemove = toBeRemoved.size();
- for(unsigned int j = 0; j < nAttrsToRemove; j++)
- {
- attList.removeAttribute(toBeRemoved[j]);
- }
- if(0 != length(styleAttrValueString))
- {
- addResultAttribute(attList, "style", styleAttrValueString);
- }
- }
-}
-
-
-
-bool
-XSLTEngineImpl::isCSSAttribute(const XalanDOMString& name) const
-{
- if(m_cssKeys.size() == 0)
- {
- // Cast away const to initialize the table.
- const_cast<XSLTEngineImpl*>(this)->initCSS2Table();
- }
- return (m_cssKeys.find(name) != m_cssKeys.end() ? true : false);
-}
-
-
-
-void
-XSLTEngineImpl::initCSS2Table()
-{
- m_cssKeys.insert("azimuth");
- m_cssKeys.insert("background");
- m_cssKeys.insert("background-attachment");
- m_cssKeys.insert("background-color");
- m_cssKeys.insert("background-image");
- m_cssKeys.insert("background-position");
- m_cssKeys.insert("background-repeat");
- m_cssKeys.insert("border");
- m_cssKeys.insert("border-bottom");
- m_cssKeys.insert("border-bottom-color");
- m_cssKeys.insert("border-bottom-style");
- m_cssKeys.insert("border-bottom-width");
- m_cssKeys.insert("border-color");
- m_cssKeys.insert("border-left");
- m_cssKeys.insert("border-left-color");
- m_cssKeys.insert("border-left-style");
- m_cssKeys.insert("border-left-width");
- m_cssKeys.insert("border-right");
- m_cssKeys.insert("border-right-color");
- m_cssKeys.insert("border-right-style");
- m_cssKeys.insert("border-right-width");
- m_cssKeys.insert("border-spacing");
- m_cssKeys.insert("border-style");
- m_cssKeys.insert("border-top");
- m_cssKeys.insert("border-top-color");
- m_cssKeys.insert("border-top-style");
- m_cssKeys.insert("border-top-width");
- m_cssKeys.insert("border-width");
- m_cssKeys.insert("bottom");
- m_cssKeys.insert("caption-side");
- m_cssKeys.insert("clear");
- m_cssKeys.insert("clip");
- m_cssKeys.insert("color");
- m_cssKeys.insert("column-span");
- m_cssKeys.insert("content");
- m_cssKeys.insert("cue");
- m_cssKeys.insert("cue-after");
- m_cssKeys.insert("cue-before");
- m_cssKeys.insert("cursor");
- m_cssKeys.insert("direction");
- m_cssKeys.insert("display");
- m_cssKeys.insert("elevation");
- m_cssKeys.insert("float");
- m_cssKeys.insert("font");
- m_cssKeys.insert("font-family");
- m_cssKeys.insert("font-size");
- m_cssKeys.insert("font-size-adjust");
- m_cssKeys.insert("font-style");
- m_cssKeys.insert("font-variant");
- m_cssKeys.insert("font-weight");
- m_cssKeys.insert("height");
- m_cssKeys.insert("left");
- m_cssKeys.insert("letter-spacing");
- m_cssKeys.insert("line-height");
- m_cssKeys.insert("list-style");
- m_cssKeys.insert("list-style-image");
- m_cssKeys.insert("list-style-position");
- m_cssKeys.insert("list-style-type");
- m_cssKeys.insert("margin");
- m_cssKeys.insert("margin-bottom");
- m_cssKeys.insert("margin-left");
- m_cssKeys.insert("margin-right");
- m_cssKeys.insert("margin-top");
- m_cssKeys.insert("marks");
- m_cssKeys.insert("max-height");
- m_cssKeys.insert("max-width");
- m_cssKeys.insert("min-height");
- m_cssKeys.insert("min-width");
- m_cssKeys.insert("orphans");
- m_cssKeys.insert("overflow");
- m_cssKeys.insert("padding");
- m_cssKeys.insert("padding-bottom");
- m_cssKeys.insert("padding-left");
- m_cssKeys.insert("padding-right");
- m_cssKeys.insert("padding-top");
- m_cssKeys.insert("page-break-after");
- m_cssKeys.insert("page-break-before");
- m_cssKeys.insert("pause");
- m_cssKeys.insert("pause-after");
- m_cssKeys.insert("pause-before");
- m_cssKeys.insert("pitch");
- m_cssKeys.insert("pitch-range");
- m_cssKeys.insert("play-during");
- m_cssKeys.insert("position");
- m_cssKeys.insert("quotes");
- m_cssKeys.insert("richness");
- m_cssKeys.insert("right");
- m_cssKeys.insert("row-span");
- m_cssKeys.insert("size");
- m_cssKeys.insert("speak");
- m_cssKeys.insert("speak-date");
- m_cssKeys.insert("speak-header");
- m_cssKeys.insert("speak-numeral");
- m_cssKeys.insert("speak-punctuation");
- m_cssKeys.insert("speak-time");
- m_cssKeys.insert("speech-rate");
- m_cssKeys.insert("stress");
- m_cssKeys.insert("table-layout");
- m_cssKeys.insert("text-align");
- m_cssKeys.insert("text-decoration");
- m_cssKeys.insert("text-indent");
- m_cssKeys.insert("text-shadow");
- m_cssKeys.insert("text-transform");
- m_cssKeys.insert("top");
- m_cssKeys.insert("unicode-bidi");
- m_cssKeys.insert("vertical-align");
- m_cssKeys.insert("visibility");
- m_cssKeys.insert("voice-family");
- m_cssKeys.insert("volume");
- m_cssKeys.insert("white-space");
- m_cssKeys.insert("widows");
- m_cssKeys.insert("width");
- m_cssKeys.insert("word-spacing");
- m_cssKeys.insert("z-index");
-}
-
-
-
XalanElement*
XSLTEngineImpl::getElementByID(
const XalanDOMString& id,
@@ -3327,56 +3181,6 @@
-#if 0
-XObject* XSLTEngineImpl::createXString(const XalanDOMString& s)
-{
- return m_xobjectFactory->createString(s);
-}
-
-
-
-XObject* XSLTEngineImpl::createXNumber(double d)
-{
- return m_xobjectFactory->createNumber(d);
-}
-
-
-
-XObject* XSLTEngineImpl::createXBoolean(bool b)
-{
- return m_xobjectFactory->createBoolean(b);
-}
-
-
-
-XObject* XSLTEngineImpl::createXNodeSet(const NodeRefListBase& nl)
-{
- return m_xobjectFactory->createNodeSet(nl);
-}
-
-
-
-XObject* XSLTEngineImpl::createXResultTreeFrag(const ResultTreeFragBase& r)
-{
- return m_xobjectFactory->createResultTreeFrag(r);
-}
-
-
-
-XObject* XSLTEngineImpl::createXNodeSet(const XalanNode& n)
-{
- return m_xobjectFactory->createNodeSet(n);
-}
-
-
-
-XObject* XSLTEngineImpl::createXNull()
-{
- return m_xobjectFactory->createNull();
-}
-#endif
-
-
/**
* Given a name, locate a variable in the current context, and return
* the Object.
@@ -3467,6 +3271,7 @@
else
{
assert((*i).second != 0);
+
return (*i).second;
}
}
@@ -3488,9 +3293,9 @@
const XalanNode* child = sourceTree.getFirstChild();
- // $$$ ToDo: is this first one style valid?
- const XalanDOMString stylesheetNodeName1("xml-stylesheet");
- const XalanDOMString stylesheetNodeName2("xml:stylesheet");
+ // $$$ ToDo: is this first one still valid?
+ const XalanDOMString stylesheetNodeName1(XALAN_STATIC_UCODE_STRING("xml-stylesheet"));
+ const XalanDOMString stylesheetNodeName2(XALAN_STATIC_UCODE_STRING("xml:stylesheet"));
// $$$ ToDo: This code is much like that in process().
// Why is it repeated???
@@ -3884,7 +3689,6 @@
XSLTEngineImpl::StackGuard::~StackGuard()
{
- m_processor = 0;
}
@@ -4116,20 +3920,86 @@
{
const int nElems = m_stack.size();
bool fFound = false;
+
// Sub 1 extra for the context marker.
for(int i = (nElems - 1); i >= 0 && fFound == false; i--)
{
const StackEntry* const theEntry = m_stack[i];
assert(theEntry != 0);
- int type = theEntry->getType();
- assert(type <4 && type >= 0);
- fFound = (type == StackEntry::eContextMarker);
+
+ const StackEntry::eStackEntryType type = theEntry->getType();
+ assert(type < 4 && type >= 0);
+
+ fFound = type == StackEntry::eContextMarker ? true : false;
+
pop();
}
}
+class PopPushStackEntry
+{
+public:
+
+ PopPushStackEntry(
+ XSLTEngineImpl::VariableStack& theVariableStack) :
+ m_variableStack(theVariableStack),
+ m_stackEntry(theVariableStack.back())
+ {
+ theVariableStack.pop();
+ }
+
+ ~PopPushStackEntry()
+ {
+ m_variableStack.push(m_stackEntry);
+ }
+
+private:
+
+ XSLTEngineImpl::VariableStack& m_variableStack;
+
+ StackEntry* const m_stackEntry;
+};
+
+
+
+class CommitPushElementMarker
+{
+public:
+
+ CommitPushElementMarker(
+ XSLTEngineImpl::VariableStack& theVariableStack,
+ const XalanNode* targetTemplate) :
+ m_variableStack(&theVariableStack),
+ m_targetTemplate(targetTemplate)
+ {
+ theVariableStack.pushElementMarker(targetTemplate);
+ }
+
+ ~CommitPushElementMarker()
+ {
+ if (m_variableStack != 0)
+ {
+ m_variableStack->popElementMarker(m_targetTemplate);
+ }
+ }
+
+ void
+ commit()
+ {
+ m_variableStack = 0;
+ }
+
+private:
+
+ XSLTEngineImpl::VariableStack* m_variableStack;
+
+ const XalanNode* const m_targetTemplate;
+};
+
+
+
void
XSLTEngineImpl::VariableStack::pushParams(
StylesheetExecutionContext& executionContext,
@@ -4150,122 +4020,92 @@
VariableStackStackType tempStack;
- ContextMarker* const cm =
-#if defined(XALAN_OLD_STYLE_CASTS)
- (ContextMarker*)theStackEntry;
-#else
- static_cast<ContextMarker*>(theStackEntry);
-#endif
+ const ElemTemplateElement* child =
+ xslCallTemplateElement.getFirstChildElem();
- try
+ if (0 != child)
{
- // If we do a pop, the current stack index may point to the last
- // element, in which case it will be changed when the push happens, so
- // we need to preserve the current index
- const ElemTemplateElement* child =
- xslCallTemplateElement.getFirstChildElem();
- if (0 != child)
+ // This object will take care of popping, then
+ // pushing the context marker at the top of the
+ // stack, even if an exception is thrown...
+ PopPushStackEntry thePopPush(*this);
+
+ while(0 != child)
{
- try
+ if(Constants::ELEMNAME_WITHPARAM == child->getXSLToken())
{
- pop();
- while(0 != child)
- {
- if(Constants::ELEMNAME_WITHPARAM == child->getXSLToken())
- {
- const ElemWithParam* const xslParamElement =
+ const ElemWithParam* const xslParamElement =
#if defined(XALAN_OLD_STYLE_CASTS)
(ElemWithParam*)child;
#else
- static_cast<const ElemWithParam*>(child);
+ static_cast<const ElemWithParam*>(child);
#endif
- Arg* theArg = 0;
+ Arg* theArg = 0;
- const XPath* const pxpath = xslParamElement->getSelectPattern();
+ const XPath* const pxpath = xslParamElement->getSelectPattern();
- if(0 != pxpath)
- {
- XObject* const theXObject =
+ if(0 != pxpath)
+ {
+ XObject* const theXObject =
pxpath->execute(sourceNode,
*xslParamElement,
executionContext);
- theArg = new Arg(xslParamElement->getQName(), theXObject, true);
- }
- else
- {
- ResultTreeFragBase* const theDocFragment =
+ theArg = new Arg(xslParamElement->getQName(), theXObject, true);
+ }
+ else
+ {
+ ResultTreeFragBase* const theDocFragment =
m_processor.createResultTreeFrag(executionContext,
*xslParamElement,
sourceTree,
sourceNode,
mode);
- assert(theDocFragment != 0);
+ assert(theDocFragment != 0);
#if !defined(XALAN_NO_NAMESPACES)
- using std::auto_ptr;
+ using std::auto_ptr;
#endif
- // Make sure this sucker gets cleaned up...
- auto_ptr<ResultTreeFragBase> theGuard(theDocFragment);
+ // Make sure this sucker gets cleaned up...
+ auto_ptr<ResultTreeFragBase> theGuard(theDocFragment);
- XObject* var = m_processor.createXResultTreeFrag(*theDocFragment);
+ XObject* const var = m_processor.createXResultTreeFrag(*theDocFragment);
- theArg = new Arg(xslParamElement->getQName(), var, true);
- }
- assert(theArg != 0);
-
- m_stackEntries.insert(theArg);
+ theArg = new Arg(xslParamElement->getQName(), var, true);
+ }
+ assert(theArg != 0);
- tempStack.push_back(theArg);
- }
+ m_stackEntries.insert(theArg);
- child = child->getNextSiblingElem();
- }
- }
- catch(...)
- {
- push(cm);
- throw;
+ tempStack.push_back(theArg);
}
- push(cm);
- }
- try
- {
- pushElementMarker(targetTemplate);
- const int nParams = tempStack.size();
- for(int i = 0; i < nParams; i++)
- {
- push(tempStack.back());
- tempStack.pop_back();
- }
- }
- catch(...)
- {
- popElementMarker(targetTemplate);
- throw;
+ child = child->getNextSiblingElem();
}
}
- catch(...)
- {
-#if !defined(XALAN_NO_NAMESPACES)
- using std::for_each;
-#endif
- // Delete all temp entries not yet transferred.
- // Any transferred ones will have been deleted
- // by popElementMarker();
- for_each(tempStack.begin(),
- tempStack.end(),
- DeleteFunctor<StackEntry>());
+ // This object will push an element marker, and pop it
+ // if we don't call it's commit() member function. So
+ // if an exception is thrown will transferring the
+ // parameters, the element marker will be popped.
+ // This keeps the stack in a consistent state.
+ CommitPushElementMarker thePusher(*this,
+ targetTemplate);
- throw;
+ const VariableStackStackType::size_type nParams = tempStack.size();
+
+ for(VariableStackStackType::size_type i = 0; i < nParams; ++i)
+ {
+ push(tempStack[i]);
}
+
+ thePusher.commit();
}
+
void
XSLTEngineImpl::VariableStack::pushVariable(
const QName& name,
@@ -4532,8 +4372,6 @@
void
XSLTEngineImpl::InitializeXSLT4JElementKeys()
{
- s_XSLT4JElementKeys[Constants::ELEMNAME_CSSSTYLECONVERSION_STRING] = Constants::ELEMNAME_CSSSTYLECONVERSION;
-
s_XSLT4JElementKeys[Constants::ELEMNAME_COMPONENT_STRING] = Constants::ELEMNAME_COMPONENT;
s_XSLT4JElementKeys[Constants::ELEMNAME_SCRIPT_STRING] = Constants::ELEMNAME_SCRIPT;
}
1.27 +20 -68 xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp
Index: XSLTEngineImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- XSLTEngineImpl.hpp 2000/04/25 19:54:18 1.26
+++ XSLTEngineImpl.hpp 2000/04/27 15:14:16 1.27
@@ -1112,10 +1112,11 @@
* @param resolver resolver for namespace resolution
* @return pointer to XPath for expression
*/
- XPath* getExpression(
- AttributeList& attrs,
- const XalanDOMString& key,
- const PrefixResolver& resolver);
+ XPath*
+ getExpression(
+ const AttributeList& attrs,
+ const XalanDOMString& key,
+ const PrefixResolver& resolver);
/**
* Given an element, return an attribute value in the form of a string.
@@ -1127,9 +1128,9 @@
*/
XalanDOMString
getAttrVal(
- const XalanElement& el,
+ const XalanElement& el,
const XalanDOMString& key,
- const XalanNode& contextNode);
+ const XalanNode& contextNode);
/**
* Given an element, return an attribute value in the form of a string.
@@ -1140,7 +1141,7 @@
*/
static XalanDOMString
getAttrVal(
- const XalanElement& el,
+ const XalanElement& el,
const XalanDOMString& key);
/**
@@ -1161,34 +1162,8 @@
const Stylesheet* stylesheetTree,
AttributeListImpl& attrList,
const XalanElement& namespaceContext);
-
- /**
- * Determine whether to translate CSS attributes on the output to a "style"
- * attribute, for old submission support.
- *
- * @return true to translate CSS attributes
- * @deprecated
- */
- bool
- getTranslateCSS()
- {
- return m_translateCSS;
- }
/**
- * Set whether to translate CSS attributes on the output to a "style"
- * attribute, for old submission support.
- *
- * @param b true to translate CSS attributes
- * @deprecated
- */
- void
- setTranslateCSS(bool b)
- {
- m_translateCSS = b;
- }
-
- /**
* Determine the value of the default-space attribute.
*
* @return true if the default-space attribute is "strip," false if
@@ -1724,6 +1699,14 @@
m_stack.pop_back();
}
+ StackEntry*
+ back() const
+ {
+ assert(m_stack.empty() == false);
+
+ return m_stack.back();
+ }
+
private:
XObject*
@@ -1889,8 +1872,8 @@
const XMLCh* const name);
virtual void characters (
- const XMLCh* const chars,
- const unsigned int length);
+ const XMLCh* const chars,
+ const unsigned int length);
virtual void
ignorableWhitespace(
@@ -1902,7 +1885,8 @@
const XMLCh* const target,
const XMLCh* const data);
- virtual void resetDocument();
+ virtual void
+ resetDocument();
protected:
@@ -1923,25 +1907,7 @@
const XalanDOMString& targetAttributeName,
const XalanDOMString& targetAttributeValue);
-
/**
- * Returns whether or not an attribute key
- * is a CSS2 attribute.
- * @deprecated
- */
- bool
- isCSSAttribute(const XalanDOMString& name) const;
-
- /**
- * Stuff a hash table with CSS2 keys & dummy values
- * in order to quickly look up if a template child
- * attribute is a CSS attribute or not.
- * @deprecated
- */
- void
- initCSS2Table();
-
- /**
* Copy the attributes from the XSL element to the created
* output element, executing attribute templates and
* processing the xsl:use attribute as need be.
@@ -1954,20 +1920,6 @@
const Stylesheet* stylesheetTree,
const XalanElement& templateChild,
AttributeListImpl& attList);
-
- /**
- * Keyed on CSS2 property names, and holding dummy
- * values for quickly looking up if a result tree element
- * attribute is a CSS attribute or not.
- * @deprecated
- */
- TranslateCSSSetType m_cssKeys;
-
- /*
- * If this is true, translate CSS attributes on the output to a "style"
- * attribute.
- */
- bool m_translateCSS;
public: