dbertoni 2002/07/10 17:36:20
Modified: c/src/XSLT XSLTEngineImpl.cpp XSLTEngineImpl.hpp
Log:
Removed unused return values. Removed unused prefix resolver.
Revision Changes Path
1.149 +62 -140 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.148
retrieving revision 1.149
diff -u -r1.148 -r1.149
--- XSLTEngineImpl.cpp 10 Jul 2002 07:31:02 -0000 1.148
+++ XSLTEngineImpl.cpp 11 Jul 2002 00:36:19 -0000 1.149
@@ -195,7 +195,9 @@
m_resultNamespacesStack(),
m_dummyAttributesList(),
m_scratchString(),
- m_hasStripOrPreserveSpace(false)
+ m_hasStripOrPreserveSpace(false),
+ m_attributeNamesVisited(),
+ m_attributeNamesVisitedEnd(m_attributeNamesVisited.end())
{
m_outputContextStack.pushContext();
}
@@ -230,6 +232,8 @@
m_resultNamespacesStack.clear();
m_hasStripOrPreserveSpace = false;
+
+ m_attributeNamesVisited.clear();
}
@@ -1320,7 +1324,16 @@
const XalanNode* sourceNode,
const ElemTemplateElement* styleNode) const
{
- problem(msg, ProblemListener::eWARNING, sourceNode, styleNode);
+ const Locator* const locator = styleNode == 0 ? 0 :
styleNode->getLocator();
+
+ if (locator != 0)
+ {
+ problem(msg, ProblemListener::eWARNING, *locator, sourceNode);
+ }
+ else
+ {
+ problem(msg, ProblemListener::eWARNING, sourceNode, styleNode);
+ }
}
@@ -1348,6 +1361,17 @@
void
+XSLTEngineImpl::warn(
+ const char* msg,
+ const XalanNode* sourceNode,
+ const ElemTemplateElement* styleNode) const
+{
+ warn(TranscodeFromLocalCodePage(msg), sourceNode, styleNode);
+}
+
+
+
+void
XSLTEngineImpl::error(
const XalanDOMString& msg,
const XalanNode* sourceNode,
@@ -2193,6 +2217,19 @@
void
+XSLTEngineImpl::warnCopyTextNodesOnly(
+ const XalanNode* sourceNode,
+ const ElemTemplateElement* styleNode) const
+{
+ warn(
+ "Only text nodes can be copied in this context. The
node is ignored",
+ sourceNode,
+ styleNode);
+}
+
+
+
+void
XSLTEngineImpl::cloneToResultTree(
const XalanText& node,
bool isLiteral,
@@ -2244,29 +2281,9 @@
if (cloneTextNodesOnly == true &&
posNodeType != XalanNode::TEXT_NODE)
{
- const Locator* theLocator = 0;
- const char* const theErrorMessage =
- "Only text nodes can be copied in this
context. The node is ignored";
-
- if (styleNode != 0)
- {
- theLocator = styleNode->getLocator();
- }
-
- if (theLocator != 0)
- {
- warn(
- XalanDOMString(theErrorMessage),
- *theLocator,
- &node);
- }
- else
- {
- warn(
- XalanDOMString(theErrorMessage),
- &node,
- styleNode);
- }
+ warnCopyTextNodesOnly(
+ &node,
+ styleNode);
}
else
{
@@ -2351,29 +2368,9 @@
{
if (nodeType != XalanNode::TEXT_NODE)
{
- const Locator* theLocator = 0;
- const char* const theErrorMessage =
- "Only text nodes can be copied in this
context. The node is ignored";
-
- if (styleNode != 0)
- {
- theLocator = styleNode->getLocator();
- }
-
- if (theLocator != 0)
- {
- warn(
- XalanDOMString(theErrorMessage),
- *theLocator,
- &node);
- }
- else
- {
- warn(
- XalanDOMString(theErrorMessage),
+ warnCopyTextNodesOnly(
&node,
styleNode);
- }
}
else
{
@@ -2442,29 +2439,10 @@
}
else
{
- const Locator* theLocator = 0;
- const char* const theErrorMessage =
- "Attempting to add an attribute when
there is no open element. The attribute will be ignored";
-
- if (styleNode != 0)
- {
- theLocator = styleNode->getLocator();
- }
-
- if (theLocator != 0)
- {
- warn(
- XalanDOMString(theErrorMessage),
- *theLocator,
- &node);
- }
- else
- {
- warn(
- XalanDOMString(theErrorMessage),
- &node,
- styleNode);
- }
+ warn(
+ "Attempting to add an attribute when
there is no open element. The attribute will be ignored",
+ &node,
+ styleNode);
}
break;
@@ -2537,29 +2515,9 @@
if (outputTextNodesOnly == true &&
posNodeType != XalanNode::TEXT_NODE)
{
- const Locator* theLocator = 0;
- const char* const theErrorMessage
=
- "Only text nodes can be
copied in this context. The node is ignored";
-
- if (styleNode != 0)
- {
- theLocator =
styleNode->getLocator();
- }
-
- if (theLocator != 0)
- {
- warn(
-
XalanDOMString(theErrorMessage),
- *theLocator,
- pos);
- }
- else
- {
- warn(
-
XalanDOMString(theErrorMessage),
+ warnCopyTextNodesOnly(
pos,
styleNode);
- }
}
else
{
@@ -2656,29 +2614,9 @@
if (outputTextNodesOnly == true &&
posNodeType != XalanNode::TEXT_NODE)
{
- const Locator* theLocator = 0;
- const char* const theErrorMessage =
- "Only text nodes can be copied in this
context. The node is ignored";
-
- if (styleNode != 0)
- {
- theLocator = styleNode->getLocator();
- }
-
- if (theLocator != 0)
- {
- warn(
- XalanDOMString(theErrorMessage),
- *theLocator,
- pos);
- }
- else
- {
- warn(
- XalanDOMString(theErrorMessage),
+ warnCopyTextNodesOnly(
pos,
styleNode);
- }
}
else
{
@@ -2985,7 +2923,7 @@
-bool
+void
XSLTEngineImpl::addResultNamespace(
const XalanDOMString& thePrefix,
const XalanDOMString& theName,
@@ -3003,23 +2941,13 @@
{
addResultAttribute(thePendingAttributes, theName,
srcURI);
addResultNamespaceDecl(thePrefix, srcURI);
-
- return true;
- }
- else
- {
- return false;
}
}
- else
- {
- return false;
- }
}
-bool
+void
XSLTEngineImpl::addResultNamespace(
const XalanNode& theNode,
AttributeListImpl& thePendingAttributes,
@@ -3033,7 +2961,7 @@
if (equals(aname, DOMServices::s_XMLNamespace) == true)
{
// Default namespace declaration...
- return addResultNamespace(s_emptyString, aname, theNode,
thePendingAttributes, fOnlyIfPrefixNotPresent);
+ addResultNamespace(s_emptyString, aname, theNode,
thePendingAttributes, fOnlyIfPrefixNotPresent);
}
else if (startsWith(aname, DOMServices::s_XMLNamespaceWithSeparator))
{
@@ -3043,11 +2971,7 @@
substring(aname, thePrefix,
DOMServices::s_XMLNamespaceWithSeparatorLength);
- return addResultNamespace(thePrefix, aname, theNode,
thePendingAttributes, fOnlyIfPrefixNotPresent);
- }
- else
- {
- return false;
+ addResultNamespace(thePrefix, aname, theNode,
thePendingAttributes, fOnlyIfPrefixNotPresent);
}
}
@@ -3056,11 +2980,9 @@
void
XSLTEngineImpl::copyNamespaceAttributes(const XalanNode& src)
{
- const XalanNode* parent = &src;
-
- XalanDOMStringPointerSetType names;
+ assert(m_attributeNamesVisited.empty() == true);
- XalanDOMStringPointerSetType::iterator end = names.end();
+ const XalanNode* parent = &src;
while (parent != 0 &&
parent->getNodeType() == XalanNode::ELEMENT_NODE)
@@ -3083,16 +3005,18 @@
const XalanDOMString& nodeName = attr->getNodeName();
- if (names.find(&nodeName) == end)
+ if (m_attributeNamesVisited.find(&nodeName) ==
m_attributeNamesVisitedEnd)
{
addResultNamespace(*attr, thePendingAttributes,
true);
- names.insert(&nodeName);
+ m_attributeNamesVisited.insert(&nodeName);
}
}
parent = parent->getParentNode();
}
+
+ m_attributeNamesVisited.clear();
}
@@ -3236,7 +3160,7 @@
}
else
{
- bool strip = false; // return value
+ bool strip = false;
assert(m_stylesheetRoot->getWhitespacePreservingElements().size() > 0 ||
m_stylesheetRoot->getWhitespaceStrippingElements().size() > 0);
@@ -3282,8 +3206,6 @@
XPath::eMatchScore
highPreserveScore = XPath::eMatchScoreNone;
XPath::eMatchScore highStripScore
= XPath::eMatchScoreNone;
- ElementPrefixResolverProxy
theProxy(parentElem, m_xpathEnvSupport, m_domSupport);
-
{
// $$$ ToDo: All of this
should be moved into a member of
// Stylesheet, so as not to
expose these two data members...
@@ -3300,7 +3222,7 @@
const XPath* const
matchPat = theElements[i];
assert(matchPat != 0);
- const
XPath::eMatchScore score = matchPat->getMatchScore(parent, theProxy,
executionContext);
+ const
XPath::eMatchScore score = matchPat->getMatchScore(parent,
executionContext);
if(score >
highPreserveScore)
highPreserveScore = score;
@@ -3322,7 +3244,7 @@
theElements[i];
assert(matchPat != 0);
- const
XPath::eMatchScore score = matchPat->getMatchScore(parent, theProxy,
executionContext);
+ const
XPath::eMatchScore score = matchPat->getMatchScore(parent,
executionContext);
if(score >
highStripScore)
highStripScore
= score;
1.90 +25 -12 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.89
retrieving revision 1.90
diff -u -r1.89 -r1.90
--- XSLTEngineImpl.hpp 10 Jul 2002 07:31:02 -0000 1.89
+++ XSLTEngineImpl.hpp 11 Jul 2002 00:36:19 -0000 1.90
@@ -158,7 +158,7 @@
typedef clock_t ClockType;
#endif
- struct CompareXalanDOMStringPointers
+ struct LessXalanDOMStringPointers
{
bool
operator()(
@@ -194,7 +194,7 @@
typedef vector<TraceListener*> TraceListenerVectorType;
typedef vector<bool> BoolVectorType;
typedef set<const XalanDOMString*,
- CompareXalanDOMStringPointers>
XalanDOMStringPointerSetType;
+ LessXalanDOMStringPointers>
XalanDOMStringPointerSetType;
#else
typedef std::map<XalanDOMString, int> AttributeKeysMapType;
typedef std::map<XalanDOMString, int> ElementKeysMapType;
@@ -203,7 +203,7 @@
typedef std::vector<TraceListener*>
TraceListenerVectorType;
typedef std::vector<bool>
BoolVectorType;
typedef std::set<const XalanDOMString*,
- CompareXalanDOMStringPointers>
XalanDOMStringPointerSetType;
+ LessXalanDOMStringPointers>
XalanDOMStringPointerSetType;
#endif
typedef XalanAutoPtr<XPathProcessor>
XPathProcessorPtrType;
@@ -824,13 +824,12 @@
const XalanNode* sourceNode,
const ElemTemplateElement* styleNode) const;
- /**
- * Report a warning.
- *
- * @param msg text of message to output
- * @param sourceNode node in source where error occurred
- * @param styleNode node in stylesheet where error occurred
- */
+ virtual void
+ warn(
+ const char* msg,
+ const XalanNode* sourceNode,
+ const ElemTemplateElement* styleNode) const;
+
virtual void
warn(
const char* msg,
@@ -1497,6 +1496,17 @@
private:
/**
+ * Issue a warning that only text nodes can be copied.
+ *
+ * @param sourceNode node in source where error occurred
+ * @param styleNode node in stylesheet where error occurred
+ */
+ void
+ warnCopyTextNodesOnly(
+ const XalanNode* sourceNode,
+ const ElemTemplateElement* styleNode) const;
+
+ /**
* Clone a text node to the result tree
*
* @param node node to clone
@@ -1516,7 +1526,7 @@
bool
pendingAttributesHasDefaultNS() const;
- bool
+ void
addResultNamespace(
const XalanDOMString& thePrefix,
const XalanDOMString& theName,
@@ -1524,7 +1534,7 @@
AttributeListImpl& thePendingAttributes,
bool
fOnlyIfPrefixNotPresent);
- bool
+ void
addResultNamespace(
const XalanNode& theNode,
AttributeListImpl& thePendingAttributes,
@@ -1724,6 +1734,9 @@
bool
m_hasStripOrPreserveSpace;
+ XalanDOMStringPointerSetType m_attributeNamesVisited;
+
+ const XalanDOMStringPointerSetType::iterator
m_attributeNamesVisitedEnd;
static void
installFunctions();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]