dbertoni 00/05/24 12:39:33
Modified: c/src/XSLT ElemApplyTemplates.cpp ElemChoose.cpp
ElemCopy.cpp ElemCopyOf.cpp ElemElement.cpp
ElemIf.cpp ElemLiteralResult.cpp
ElemLiteralResult.hpp ElemMessage.cpp
ElemMessage.hpp ElemPI.cpp ElemPI.hpp ElemParam.cpp
ElemTemplateElement.cpp ElemTemplateElement.hpp
ElemTextLiteral.hpp ElemValueOf.cpp
ElemVariable.cpp SelectionEvent.hpp
StylesheetExecutionContext.hpp
StylesheetExecutionContextDefault.cpp
StylesheetExecutionContextDefault.hpp
StylesheetHandler.cpp StylesheetRoot.cpp
StylesheetRoot.hpp TraceListener.hpp
XSLTEngineImpl.cpp XSLTEngineImpl.hpp
XSLTProcessor.hpp XSLTProcessorEnvSupport.hpp
XSLTProcessorEnvSupportDefault.cpp
XSLTProcessorEnvSupportDefault.hpp
XSLTProcessorException.cpp
Log:
Removed trace listeners from the stylesheet root. Added default
implementation for trace listener. Fixed bugs in several stylesheet elements.
Revision Changes Path
1.7 +2 -2 xml-xalan/c/src/XSLT/ElemApplyTemplates.cpp
Index: ElemApplyTemplates.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemApplyTemplates.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ElemApplyTemplates.cpp 2000/05/15 15:57:44 1.6
+++ ElemApplyTemplates.cpp 2000/05/24 19:38:47 1.7
@@ -137,9 +137,9 @@
XalanNode*
sourceNode,
const QName& mode)
const
{
- if(0 != getStylesheet().getStylesheetRoot().getTraceListeners())
+ if(0 != executionContext.getTraceListeners())
{
- getStylesheet().getStylesheetRoot().fireTraceEvent(TracerEvent(
+ executionContext.fireTraceEvent(TracerEvent(
executionContext, sourceTree, sourceNode, mode, *this));
}
if (0 != sourceNode)
1.5 +2 -2 xml-xalan/c/src/XSLT/ElemChoose.cpp
Index: ElemChoose.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemChoose.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ElemChoose.cpp 2000/04/20 16:47:34 1.4
+++ ElemChoose.cpp 2000/05/24 19:38:47 1.5
@@ -134,9 +134,9 @@
executionContext);
assert(test != 0);
- if(0 !=
getStylesheet().getStylesheetRoot().getTraceListeners())
+ if(0 != executionContext.getTraceListeners())
{
-
getStylesheet().getStylesheetRoot().fireSelectedEvent(
+ executionContext.fireSelectEvent(
SelectionEvent(executionContext,
sourceNode,
*when,
1.4 +4 -4 xml-xalan/c/src/XSLT/ElemCopy.cpp
Index: ElemCopy.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemCopy.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ElemCopy.cpp 2000/04/11 15:09:23 1.3
+++ ElemCopy.cpp 2000/05/24 19:38:47 1.4
@@ -145,9 +145,9 @@
}
else
{
- if(0 !=
getStylesheet().getStylesheetRoot().getTraceListeners())
+ if(0 != executionContext.getTraceListeners())
{
-
getStylesheet().getStylesheetRoot().fireTraceEvent(TracerEvent(executionContext,
+
executionContext.fireTraceEvent(TracerEvent(executionContext,
sourceTree,
sourceNode,
mode,
@@ -157,9 +157,9 @@
}
else
{
- if(0 != getStylesheet().getStylesheetRoot().getTraceListeners())
+ if(0 != executionContext.getTraceListeners())
{
-
getStylesheet().getStylesheetRoot().fireTraceEvent(TracerEvent(executionContext,
+
executionContext.fireTraceEvent(TracerEvent(executionContext,
sourceTree,
sourceNode,
mode,
1.5 +2 -2 xml-xalan/c/src/XSLT/ElemCopyOf.cpp
Index: ElemCopyOf.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemCopyOf.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ElemCopyOf.cpp 2000/04/20 16:47:34 1.4
+++ ElemCopyOf.cpp 2000/05/24 19:38:47 1.5
@@ -126,9 +126,9 @@
m_pSelectPattern->execute(sourceNode, *this, executionContext);
assert(pValue != 0);
- if(0 != getStylesheet().getStylesheetRoot().getTraceListeners())
+ if(0 != executionContext.getTraceListeners())
{
- getStylesheet().getStylesheetRoot().fireSelectedEvent(
+ executionContext.fireSelectEvent(
SelectionEvent(executionContext, sourceNode,
*this,
XalanDOMString(XALAN_STATIC_UCODE_STRING("select")), *m_pSelectPattern,
pValue));
}
1.6 +51 -4 xml-xalan/c/src/XSLT/ElemElement.cpp
Index: ElemElement.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemElement.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ElemElement.cpp 2000/04/20 16:47:34 1.5
+++ ElemElement.cpp 2000/05/24 19:38:48 1.6
@@ -136,14 +136,53 @@
XalanNode*
sourceTree,
XalanNode*
sourceNode,
const QName& mode)
const
-{
+{
XalanDOMString elemName;
assert(m_nameAVT != 0);
m_nameAVT->evaluate(elemName, sourceNode, *this, executionContext);
- if(!isEmpty(elemName))
+ bool isIllegalAttribute = false;
+ unsigned int len = length(elemName);
+ const unsigned int indexOfNSSep = indexOf(elemName, ':');
+ const bool haveNamespace = indexOfNSSep == len ?
false : true;
+
+ XalanDOMString ns;
+
+ if(haveNamespace == true)
+ {
+ if (indexOfNSSep + 1 == len ||
+ isValidNCName(substring(elemName, indexOfNSSep + 1)) ==
false)
+ {
+ isIllegalAttribute = true;
+ }
+ }
+ else if(len == 0 || isValidNCName(elemName) == false)
+ {
+ isIllegalAttribute = true;
+ }
+
+ if (isIllegalAttribute == true)
+ {
+ XalanDOMString msg("Illegal attribute name: ");
+ msg += elemName;
+
+ executionContext.warn(msg, sourceNode, this);
+
+ clear(elemName);
+ len = 0;
+ }
+ else if (haveNamespace == true)
+ {
+ const XalanDOMString nsprefix = substring(elemName, 0,
indexOfNSSep);
+
+ ns = getNamespaceForPrefixInternal(nsprefix, false);
+ }
+
+ const unsigned int nsLength = length(ns);
+
+ if (len != 0 && (haveNamespace == false || nsLength != 0))
{
if(0 != m_namespaceAVT)
{
@@ -165,16 +204,24 @@
executionContext.addResultAttribute(nsDecl, elemNameSpace);
}
+ if(indexOfNSSep < len)
+ {
+ elemName = substring(elemName,
indexOfNSSep + 1);
+ }
+
elemName = prefix +
XALAN_STATIC_UCODE_STRING(":") + elemName;
}
}
executionContext.startElement(toCharArray(elemName));
+ }
- ElemUse::execute(executionContext, sourceTree, sourceNode,
mode);
+ ElemUse::execute(executionContext, sourceTree, sourceNode, mode);
- executeChildren(executionContext, sourceTree, sourceNode, mode);
+ executeChildren(executionContext, sourceTree, sourceNode, mode);
+ if (len != 0 && (haveNamespace == false || nsLength != 0))
+ {
executionContext.endElement(toCharArray(elemName));
}
}
1.6 +2 -2 xml-xalan/c/src/XSLT/ElemIf.cpp
Index: ElemIf.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemIf.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ElemIf.cpp 2000/04/20 16:47:34 1.5
+++ ElemIf.cpp 2000/05/24 19:38:48 1.6
@@ -143,9 +143,9 @@
const XObject* const test =
m_test->execute(sourceNode, *this, executionContext);
- if(0 != getStylesheet().getStylesheetRoot().getTraceListeners())
+ if(0 != executionContext.getTraceListeners())
{
- getStylesheet().getStylesheetRoot().fireSelectedEvent(
+ executionContext.fireSelectEvent(
SelectionEvent(executionContext,
sourceNode,
*this,
1.12 +63 -30 xml-xalan/c/src/XSLT/ElemLiteralResult.cpp
Index: ElemLiteralResult.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemLiteralResult.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ElemLiteralResult.cpp 2000/05/01 15:13:09 1.11
+++ ElemLiteralResult.cpp 2000/05/24 19:38:48 1.12
@@ -82,9 +82,6 @@
#include "StylesheetConstructionContext.hpp"
#include "StylesheetExecutionContext.hpp"
-#if !defined(XALAN_NO_NAMESPACES)
- using std::make_pair;
-#endif
ElemLiteralResult::ElemLiteralResult(
@@ -141,8 +138,10 @@
}
}
else
+ {
// don't process namespace decls
needToProcess = false;
+ }
}
if(needToProcess == true)
@@ -283,41 +282,75 @@
executionContext.endElement(toCharArray(m_QName));
}
-/**
- * Process the exclude-result-prefixes or the extension-element-prefixes
- * attributes, for the purpose of prefix exclusion.
- */
-void ElemLiteralResult::processPrefixControl(const DOMString& localName,
- const DOMString& attrValue)
-{
-/*
- OLD:
- if(equals(localName, Constants::ATTRNAME_EXTENSIONELEMENTPREFIXES))
- {
- needToProcess = false;
- const DOMString qnames = attrValue;
- StringTokenizer tokenizer(qnames, " \t\n\r", false);
- m_extensionElementPrefixes.reserve(tokenizer.countTokens());
- while(tokenizer.hasMoreTokens())
+
+
+bool
+ElemLiteralResult::isAttrOK(
+ const XalanDOMChar*
attrName,
+ const AttributeList& /* atts */,
+ int
/* which */,
+ StylesheetConstructionContext& constructionContext)
const
+{
+ bool isAttrOK = equals(attrName, DOMServices::s_XMLNamespace) ||
+ startsWith(attrName,
DOMServices::s_XMLNamespaceWithSeparator);
+
+ if(isAttrOK == false)
+ {
+ unsigned int indexOfNSSep = indexOf(attrName, ':');
+
+ if(indexOfNSSep < length(attrName))
{
-
m_extensionElementPrefixes.push_back(tokenizer.nextToken());
+ const XalanDOMString prefix = substring(attrName, 0,
indexOfNSSep);
+
+ const XalanDOMString ns =
getStylesheet().getNamespaceForPrefixFromStack(prefix);
+
+ if (equals(ns,
constructionContext.getXSLTNamespaceURI()) == true)
+ {
+ isAttrOK = false;
+ }
}
- }
-*/
+ else
+ {
+ // An empty namespace is OK.
+ isAttrOK = true;
+ }
+ }
+
+ // TODO: Well, process it...
+ return isAttrOK;
+}
+
+
+
+void
+ElemLiteralResult::processPrefixControl(
+ const XalanDOMString& localName,
+ const XalanDOMString& attrValue)
+{
if(equals(localName, Constants::ATTRNAME_EXTENSIONELEMENTPREFIXES) ||
equals(localName,
Constants::ATTRNAME_EXCLUDE_RESULT_PREFIXES))
{
- const DOMString qnames = attrValue;
+ const XalanDOMString qnames = attrValue;
+
StringTokenizer tokenizer(qnames, " \t\n\r", false);
- while(tokenizer.hasMoreTokens())
+
+ while(tokenizer.hasMoreTokens() == true)
{
- DOMString prefix = tokenizer.nextToken();
- if(equalsIgnoreCase(prefix, "#default")) prefix="";
- DOMString ns =
getStylesheet().getNamespaceForPrefixFromStack(prefix);
- if(isEmpty(ns))
+ XalanDOMString prefix = tokenizer.nextToken();
+
+ if(equalsIgnoreCase(prefix,
XALAN_STATIC_UCODE_STRING("#default")) == true)
+ {
+ clear(prefix);
+ }
+
+ const XalanDOMString ns =
getStylesheet().getNamespaceForPrefixFromStack(prefix);
+
+ if(isEmpty(ns) == true)
+ {
throw SAXException("Invalid prefix in
exclude-result-prefixes");
- m_excludeResultPrefixes.insert(make_pair(prefix, ns));
+ }
+
+
m_excludeResultPrefixes.insert(String2StringMapType::value_type(prefix, ns));
}
}
}
-
1.7 +15 -6 xml-xalan/c/src/XSLT/ElemLiteralResult.hpp
Index: ElemLiteralResult.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemLiteralResult.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ElemLiteralResult.hpp 2000/04/12 19:40:59 1.6
+++ ElemLiteralResult.hpp 2000/05/24 19:38:48 1.7
@@ -101,6 +101,13 @@
// These methods are inherited from ElemUse ...
+ virtual bool
+ isAttrOK(
+ const XalanDOMChar*
attrName,
+ const AttributeList& atts,
+ int
which,
+ StylesheetConstructionContext& constructionContext)
const;
+
virtual void
execute(
StylesheetExecutionContext&
executionContext,
@@ -143,12 +150,14 @@
*/
String2StringMapType m_excludeResultPrefixes;
-/**
- * Process the exclude-result-prefixes or the extension-element-prefixes
- * attributes, for the purpose of prefix exclusion.
- */
-void ElemLiteralResult::processPrefixControl(const DOMString& localName,
- const DOMString& attrValue);
+ /**
+ * Process the exclude-result-prefixes or the extension-element-prefixes
+ * attributes, for the purpose of prefix exclusion.
+ */
+ void
+ ElemLiteralResult::processPrefixControl(
+ const DOMString& localName,
+ const DOMString& attrValue);
};
1.4 +36 -2 xml-xalan/c/src/XSLT/ElemMessage.cpp
Index: ElemMessage.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemMessage.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ElemMessage.cpp 2000/04/11 15:09:24 1.3
+++ ElemMessage.cpp 2000/05/24 19:38:48 1.4
@@ -84,7 +84,8 @@
name,
lineNumber,
columnNumber,
- Constants::ELEMNAME_MESSAGE)
+ Constants::ELEMNAME_MESSAGE),
+ m_terminate(false)
{
const unsigned int nAttrs = atts.getLength();
@@ -92,8 +93,22 @@
{
const XalanDOMChar* const aname = atts.getName(i);
- if(isAttrOK(aname, atts, i, constructionContext) == false ||
processSpaceAttr(aname, atts, i))
+ if (equals(aname, Constants::ATTRNAME_TERMINATE) == true)
{
+ const XalanDOMChar* const avalue =
atts.getValue(i);
+
+ if (equals(avalue, Constants::ATTRVAL_YES) == true)
+ {
+ m_terminate = true;
+ }
+ else if (equals(avalue, Constants::ATTRVAL_NO) == false)
+ {
+
constructionContext.error(XalanDOMString("Attribute terminate has an illegal
value: ") +
+
XalanDOMString(avalue));
+ }
+ }
+ else if(isAttrOK(aname, atts, i, constructionContext) == false
|| processSpaceAttr(aname, atts, i))
+ {
constructionContext.error(XalanDOMString(name) +
" has an illegal attribute: " +
XalanDOMString(aname));
@@ -115,4 +130,23 @@
const XalanDOMString data = childrenToString(executionContext,
sourceTree, sourceNode, mode);
executionContext.message(data, sourceNode, this);
+
+ if (m_terminate == true)
+ {
+ throw ElemMessageTerminateException(data);
+ }
+}
+
+
+
+ElemMessage::ElemMessageTerminateException::ElemMessageTerminateException(const
DOMString& theMessage) :
+ XSLTProcessorException(theMessage,
+
XALAN_STATIC_UCODE_STRING("ElemMessageTerminateException"))
+{
+}
+
+
+
+ElemMessage::ElemMessageTerminateException::~ElemMessageTerminateException()
+{
}
1.5 +21 -1 xml-xalan/c/src/XSLT/ElemMessage.hpp
Index: ElemMessage.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemMessage.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ElemMessage.hpp 2000/04/11 15:09:25 1.4
+++ ElemMessage.hpp 2000/05/24 19:38:48 1.5
@@ -64,9 +64,9 @@
-
// Base class header file.
#include "ElemTemplateElement.hpp"
+#include "XSLTProcessorException.hpp"
@@ -100,6 +100,26 @@
XalanNode*
sourceTree,
XalanNode*
sourceNode,
const QName& mode)
const;
+
+ class ElemMessageTerminateException : public XSLTProcessorException
+ {
+ public:
+
+ /**
+ * Construct an ElemMessageTerminateException object
+ *
+ * @param theMessage message to print when exception thrown
+ */
+ ElemMessageTerminateException(const DOMString& theMessage);
+
+
+ virtual
+ ~ElemMessageTerminateException();
+ };
+
+private:
+
+ bool m_terminate;
};
1.4 +1 -1 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ElemPI.cpp 2000/04/11 15:09:25 1.3
+++ ElemPI.cpp 2000/05/24 19:38:48 1.4
@@ -139,7 +139,7 @@
{
error("processing-instruction name must be a valid NCName: " +
piName);
}
-
+
const XalanDOMString data = childrenToString(executionContext,
sourceTree, sourceNode, mode);
executionContext.processingInstruction(toCharArray(piName),
toCharArray(data));
1.5 +6 -3 xml-xalan/c/src/XSLT/ElemPI.hpp
Index: ElemPI.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemPI.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ElemPI.hpp 2000/04/11 15:09:25 1.4
+++ ElemPI.hpp 2000/05/24 19:38:48 1.5
@@ -58,7 +58,7 @@
#define XALAN_ELEMPI_HEADER_GUARD
/**
- * $Id: ElemPI.hpp,v 1.4 2000/04/11 15:09:25 dbertoni Exp $
+ * $Id: ElemPI.hpp,v 1.5 2000/05/24 19:38:48 dbertoni Exp $
*
* $State: Exp $
*
@@ -93,7 +93,7 @@
ElemPI(
StylesheetConstructionContext& constructionContext,
Stylesheet&
stylesheetTree,
- const DOMString& name,
+ const XalanDOMString& name,
const AttributeList& atts,
int
lineNumber,
int
columnNumber);
@@ -117,6 +117,9 @@
private:
- DOMString m_name_atv;
+ XalanDOMString m_name_atv;
};
+
+
+
#endif // XALAN_ELEMPI_HEADER_GUARD
1.4 +2 -2 xml-xalan/c/src/XSLT/ElemParam.cpp
Index: ElemParam.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemParam.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ElemParam.cpp 2000/04/11 15:09:26 1.3
+++ ElemParam.cpp 2000/05/24 19:38:48 1.4
@@ -100,9 +100,9 @@
}
else
{
- if(0 != getStylesheet().getStylesheetRoot().getTraceListeners())
+ if(0 != executionContext.getTraceListeners())
{
- getStylesheet().getStylesheetRoot().fireTraceEvent(
+ executionContext.fireTraceEvent(
TracerEvent(
executionContext,
sourceTree,
1.20 +64 -39 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.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ElemTemplateElement.cpp 2000/05/15 15:57:45 1.19
+++ ElemTemplateElement.cpp 2000/05/24 19:38:48 1.20
@@ -99,9 +99,6 @@
#include "SelectionEvent.hpp"
#include "TracerEvent.hpp"
-#if !defined(XALAN_NO_NAMESPACES)
- using std::make_pair;
-#endif
/**
@@ -141,22 +138,27 @@
*/
const Stylesheet::NamespacesStackType& stylesheetNamespaces =
m_stylesheet.getNamespaces();
- int n = stylesheetNamespaces.size();
+
+ const int n = stylesheetNamespaces.size();
+
for(int i = (n-1); i >= 0; i--)
{
const Stylesheet::NamespaceVectorType& nsVector =
stylesheetNamespaces[i];
+
for(unsigned int j = 0; j < nsVector.size(); j++)
{
- NameSpace ns = nsVector[j];
- if(isEmpty(ns.getURI()))
- continue;
- if(!shouldExcludeResultNamespaceNode(ns.getPrefix(),
ns.getURI()))
- {
- m_namespaces.push_back(ns);
- }
- else
+ const NameSpace& ns = nsVector[j];
+
+ if(isEmpty(ns.getURI()) == false)
{
-
m_excludedNamespaces.insert(make_pair(ns.getPrefix(), ns.getURI()));
+
if(!shouldExcludeResultNamespaceNode(ns.getPrefix(), ns.getURI()))
+ {
+ m_namespaces.push_back(ns);
+ }
+ else
+ {
+
m_excludedNamespaces.insert(String2StringMapType::value_type(ns.getPrefix(),
ns.getURI()));
+ }
}
}
}
@@ -183,8 +185,6 @@
bool isXMLNS = (Constants::TATTRNAME_XMLNSDEF == tok)
|| startsWith(attrName, Constants::ATTRNAME_XMLNS);
- // TODO: Well, process it...
-
return isXMLNS;
}
@@ -288,9 +288,9 @@
XalanNode*
sourceNode,
const QName& mode)
const
{
- if(0 != getStylesheet().getStylesheetRoot().getTraceListeners())
+ if(0 != executionContext.getTraceListeners())
{
- getStylesheet().getStylesheetRoot().fireTraceEvent(
+ executionContext.fireTraceEvent(
TracerEvent(executionContext, sourceTree, sourceNode,
mode, *this));
}
}
@@ -580,11 +580,11 @@
(Constants::ELEMNAME_FOREACH == tok))
{
const ElemForEach* foreach = static_cast<const ElemForEach
*>(&xslInstruction);
- int nChildren = foreach->getSortElems().size();
+ const unsigned int nChildren = foreach->getSortElems().size();
// March backwards, performing a sort on each xsl:sort child.
// Probably not the most efficient method.
- for(int i = 0; i < nChildren; i++)
+ for(unsigned int i = 0; i < nChildren; i++)
{
ElemSort* sort = foreach->getSortElems()[i];
assert(sort != 0);
@@ -655,9 +655,9 @@
{
sourceNodes = result->mutableNodeset();
- if(0 !=
getStylesheet().getStylesheetRoot().getTraceListeners())
+ if(0 != executionContext.getTraceListeners())
{
-
getStylesheet().getStylesheetRoot().fireSelectedEvent(
+ executionContext.fireSelectEvent(
SelectionEvent(executionContext,
sourceNodeContext,
*this,
@@ -692,7 +692,7 @@
executionContext,
sourceNodes);
- if(executionContext.isTraceSelect())
+ if(executionContext.getTraceSelects() == true)
{
executionContext.traceSelect(
xslInstruction,
@@ -731,7 +731,7 @@
ElemTemplateElement::transformChild(
StylesheetExecutionContext& executionContext,
const Stylesheet&
stylesheet_tree,
- const ElemTemplateElement* xslInstruction,
+ const ElemTemplateElement* /* xslInstruction */,
const ElemTemplateElement* theTemplate,
XalanNode*
sourceTree,
XalanNode*
selectContext,
@@ -837,7 +837,7 @@
}
else
{
- if(0 !=
getStylesheet().getStylesheetRoot().getTraceListeners())
+ if(0 !=
executionContext.getTraceListeners())
{
TracerEvent te(executionContext,
sourceTree,
@@ -845,7 +845,7 @@
mode,
*theTemplate);
-
getStylesheet().getStylesheetRoot().fireTraceEvent(te);
+
executionContext.fireTraceEvent(te);
}
theTemplate->executeChildren(executionContext,
@@ -1166,30 +1166,44 @@
}
-void ElemTemplateElement::removeExcludedPrefixes(
- const String2StringMapType& excludeResultPrefixes)
+void
+ElemTemplateElement::removeExcludedPrefixes(const String2StringMapType&
excludeResultPrefixes)
{
if(0 !=excludeResultPrefixes.size() && 0 != m_namespaces.size())
{
- for( NamespaceVectorType::iterator it = m_namespaces.begin();
- it != m_namespaces.end(); )
+ const NamespaceVectorType::iterator theEnd =
+ m_namespaces.end();
+
+ for(NamespaceVectorType::iterator it = m_namespaces.begin();
+ it != theEnd; )
{
- NameSpace ns = *it;
- DOMString p = ns.getPrefix();
- String2StringMapType::const_iterator it2 =
excludeResultPrefixes.find(p);
+ const NameSpace& ns = *it;
+
+ const XalanDOMString& prefix = ns.getPrefix();
+
+ const String2StringMapType::const_iterator it2 =
+ excludeResultPrefixes.find(prefix);
+
if(it2 != excludeResultPrefixes.end())
{
- m_excludedNamespaces.insert(make_pair(p,
ns.getURI()));
+
m_excludedNamespaces.insert(String2StringMapType::value_type(prefix,
ns.getURI()));
+
it = m_namespaces.erase(it);
}
- else
- it++;
+ else
+ {
+ ++it;
+ }
}
}
}
-
-bool ElemTemplateElement::shouldExcludeResultNamespaceNode(
- const DOMString& prefix, const DOMString& uri)
+
+
+
+bool
+ElemTemplateElement::shouldExcludeResultNamespaceNode(
+ const XalanDOMString& prefix,
+ const XalanDOMString& uri)
{
/*
@@ JMD: Need to implement this ---
@@ -1218,6 +1232,7 @@
}
+
XalanNodeList*
ElemTemplateElement::getElementsByTagName(const XalanDOMString&
/* name */) const
{
@@ -1328,6 +1343,16 @@
XalanDOMString
ElemTemplateElement::getNamespaceForPrefix(const XalanDOMString& prefix)
const
{
+ return getNamespaceForPrefixInternal(prefix, true);
+}
+
+
+
+XalanDOMString
+ElemTemplateElement::getNamespaceForPrefixInternal(
+ const XalanDOMString& prefix,
+ bool fReportError)
const
+{
XalanDOMString nameSpace;
if(m_finishedConstruction == true)
@@ -1358,7 +1383,7 @@
nameSpace =
getStylesheet().getNamespaceForPrefixFromStack(prefix);
}
- if(isEmpty(nameSpace))
+ if(fReportError == true && isEmpty(nameSpace) == true)
{
error("Can not resolve namespace prefix: " + prefix);
}
1.10 +29 -13 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ElemTemplateElement.hpp 2000/04/12 19:40:59 1.9
+++ ElemTemplateElement.hpp 2000/05/24 19:38:48 1.10
@@ -131,7 +131,7 @@
* @param which index into the attribute list (not used at this time)
* @return true if this is a namespace name
*/
- bool
+ virtual bool
isAttrOK(
int tok,
const XalanDOMChar* attrName,
@@ -147,7 +147,7 @@
* @param which index into the attribute list (not used at this time)
* @return true if this is a namespace name
*/
- bool
+ virtual bool
isAttrOK(
const XalanDOMChar*
attrName,
const AttributeList& atts,
@@ -305,6 +305,12 @@
return m_columnNumber;
}
+ const XalanDOMString
+ getElementName() const
+ {
+ return m_elemName;
+ }
+
#if defined(XALAN_NO_NAMESPACES)
typedef vector<NameSpace> NamespaceVectorType;
typedef map<XalanDOMString, XalanDOMString> String2StringMapType;
@@ -626,14 +632,24 @@
virtual XalanDOMString
getNamespaceForPrefix(const XalanDOMString& prefix) const;
-
virtual XalanDOMString
getURI() const;
-
protected:
- /**
+ /**
+ * Get the namespace for a given prefix.
+ *
+ * @param prefix The prefix to search for
+ * @param fReportError If true, and exception will be thrown to report
the error.
+ * @return The namespace string.
+ */
+ XalanDOMString
+ getNamespaceForPrefixInternal(
+ const XalanDOMString& prefix,
+ bool fReportError)
const;
+
+ /**
* Perform a query if needed, and call transformChild for each child.
*
* @param stylesheetTree The owning stylesheet tree.
@@ -678,14 +694,6 @@
bool shouldExcludeResultNamespaceNode(
const XalanDOMString& prefix, const XalanDOMString& uri);
- /**
- * The table of namespaces that are excluded from being
- * used in the result tree but which need to be used
- * in to resolve prefixes.
- * @serial
- */
- String2StringMapType m_excludedNamespaces;
-
/**
* Given an element and mode, find the corresponding
* template and process the contents.
@@ -737,6 +745,14 @@
const int m_columnNumber;
NamespaceVectorType m_namespaces;
+
+ /**
+ * The table of namespaces that are excluded from being
+ * used in the result tree but which need to be used
+ * in to resolve prefixes.
+ * @serial
+ */
+ String2StringMapType m_excludedNamespaces;
bool m_defaultSpace;
bool m_finishedConstruction;
1.6 +12 -13 xml-xalan/c/src/XSLT/ElemTextLiteral.hpp
Index: ElemTextLiteral.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTextLiteral.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ElemTextLiteral.hpp 2000/04/11 15:09:26 1.5
+++ ElemTextLiteral.hpp 2000/05/24 19:38:48 1.6
@@ -57,13 +57,6 @@
#if !defined(XALAN_ELEMTEXTLITERAL_HEADER_GUARD)
#define XALAN_ELEMTEXTLITERAL_HEADER_GUARD
-/**
- * $Id: ElemTextLiteral.hpp,v 1.5 2000/04/11 15:09:26 dbertoni Exp $
- *
- * $State: Exp $
- *
- * @author Myriam Midy (Myriam_Midy @lotus.com
- */
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
@@ -123,6 +116,18 @@
return m_preserveSpace;
}
+#if defined(XALAN_NO_NAMESPACES)
+ typedef vector<XalanDOMChar> XMLChVectorType;
+#else
+ typedef std::vector<XalanDOMChar> XMLChVectorType;
+#endif
+
+ const XMLChVectorType&
+ getText() const
+ {
+ return m_ch;
+ }
+
// These methods are inherited from ElemTemplateElement ...
virtual void
@@ -143,12 +148,6 @@
const bool m_isCData;
const bool m_preserveSpace;
const bool m_disableOutputEscaping;
-
-#if defined(XALAN_NO_NAMESPACES)
- typedef vector<XalanDOMChar> XMLChVectorType;
-#else
- typedef std::vector<XalanDOMChar> XMLChVectorType;
-#endif
const XMLChVectorType m_ch;
};
1.7 +4 -4 xml-xalan/c/src/XSLT/ElemValueOf.cpp
Index: ElemValueOf.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemValueOf.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ElemValueOf.cpp 2000/05/15 15:56:38 1.6
+++ ElemValueOf.cpp 2000/05/24 19:38:48 1.7
@@ -179,9 +179,9 @@
theValue = executionContext.getNodeData(*sourceNode);
}
- if(0 != getStylesheet().getStylesheetRoot().getTraceListeners())
+ if(0 != executionContext.getTraceListeners())
{
- getStylesheet().getStylesheetRoot().fireSelectedEvent(
+ executionContext.fireSelectEvent(
SelectionEvent(executionContext,
sourceNode,
*this,
@@ -197,9 +197,9 @@
*this,
executionContext);
- if(0 != getStylesheet().getStylesheetRoot().getTraceListeners())
+ if(0 != executionContext.getTraceListeners())
{
- getStylesheet().getStylesheetRoot().fireSelectedEvent(
+ executionContext.fireSelectEvent(
SelectionEvent(executionContext,
sourceNode,
*this,
1.6 +2 -2 xml-xalan/c/src/XSLT/ElemVariable.cpp
Index: ElemVariable.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemVariable.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ElemVariable.cpp 2000/04/20 16:47:35 1.5
+++ ElemVariable.cpp 2000/05/24 19:38:49 1.6
@@ -176,9 +176,9 @@
{
var = m_selectPattern->execute(sourceNode, *this,
executionContext);
- if(0 != getStylesheet().getStylesheetRoot().getTraceListeners())
+ if(0 != executionContext.getTraceListeners())
{
- getStylesheet().getStylesheetRoot().fireSelectedEvent(
+ executionContext.fireSelectEvent(
SelectionEvent(executionContext, sourceNode,
*this,
XalanDOMString(XALAN_STATIC_UCODE_STRING("select")), *m_selectPattern, var));
}
1.5 +24 -24 xml-xalan/c/src/XSLT/SelectionEvent.hpp
Index: SelectionEvent.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/SelectionEvent.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SelectionEvent.hpp 2000/04/11 15:09:28 1.4
+++ SelectionEvent.hpp 2000/05/24 19:38:49 1.5
@@ -101,41 +101,41 @@
virtual
~SelectionEvent();
-private:
-
- // Unimplemented...
- SelectionEvent&
- operator=(const SelectionEvent& other);
-
- /**
- * The executionContext instance.
- */
+ /**
+ * The executionContext instance.
+ */
const StylesheetExecutionContext& m_executionContext;
- /**
- * The current context node.
- */
+ /**
+ * The current context node.
+ */
const XalanNode* m_sourceNode;
- /**
- * The node in the style tree where the event occurs.
- */
+ /**
+ * The node in the style tree where the event occurs.
+ */
const ElemTemplateElement& m_styleNode;
- /**
- * The attribute name from which the selection is made.
- */
+ /**
+ * The attribute name from which the selection is made.
+ */
const XalanDOMString m_attributeName;
- /**
- * The XPath that executed the selection.
- */
+ /**
+ * The XPath that executed the selection.
+ */
const XPath& m_xpath;
- /**
- * The result of the selection.
- */
+ /**
+ * The result of the selection.
+ */
const XObject* const m_selection;
+
+private:
+
+ // Unimplemented...
+ SelectionEvent&
+ operator=(const SelectionEvent& other);
};
1.15 +66 -23 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.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- StylesheetExecutionContext.hpp 2000/05/18 18:38:38 1.14
+++ StylesheetExecutionContext.hpp 2000/05/24 19:38:49 1.15
@@ -100,13 +100,16 @@
class FormatterToHTML;
class FormatterToText;
class FormatterToXML;
+class GenerateEvent;
class PrefixResolver;
class NodeRefListBase;
class PrintWriter;
class QName;
+class SelectionEvent;
class Stylesheet;
class StylesheetRoot;
class TextOutputStream;
+class TracerEvent;
class Writer;
class XalanDocument;
class XalanDocumentFragment;
@@ -187,7 +190,7 @@
* @param theStylesheet root stylesheet
*/
virtual void
- setStylesheetRoot(StylesheetRoot* theStylesheet) = 0;
+ setStylesheetRoot(const StylesheetRoot* theStylesheet) = 0;
/**
* Reset the state of execution to node 'xmlNode' in source tree
'sourceTree.'
@@ -878,25 +881,6 @@
getXalanXSLNameSpaceURL() const = 0;
/**
- * If this is set to true, simple traces of template calls are made.
- *
- * @return true if traces made
- */
- virtual bool
- isTraceSelect() const = 0;
-
- /**
- * Compose a diagnostic trace of the current selection
- *
- * @param theTemplate current context node
- * @param nl list of selected nodes
- */
- virtual void
- traceSelect(
- const XalanElement& theTemplate,
- const NodeRefListBase& nl) const = 0;
-
- /**
* Determine if an element is on the recursion stack.
*
* @return true if element on stack
@@ -985,6 +969,11 @@
bool xmlDecl = true,
const XalanDOMString& standalone = XalanDOMString())
= 0;
+ enum eDummy
+ {
+ eDefaultHTMLIndentAmount = 4
+ };
+
/**
* Create a new FormatterToHTML instance. The execution context
* owns the instance and will delete it when reset.
@@ -1069,6 +1058,60 @@
createXalanNumberFormat() = 0;
+ // Trace interface...
+
+ /**
+ * Determine the number of trace listeners.
+ *
+ * @return number of listeners
+ */
+ virtual unsigned long
+ getTraceListeners() const = 0;
+
+ /**
+ * Fire a generate event.
+ *
+ * @param ge generate event to fire
+ */
+ virtual void
+ fireGenerateEvent(const GenerateEvent& ge) = 0;
+
+ /**
+ * Fire a trace event.
+ *
+ * @param te trace event to fire
+ */
+ virtual void
+ fireTraceEvent(const TracerEvent& te) = 0;
+
+ /**
+ * Fire a selection event.
+ *
+ * @param se selection event to fire
+ */
+ virtual void
+ fireSelectEvent(const SelectionEvent& se) = 0;
+
+ /**
+ * If this is set to true, simple traces of template calls are made.
+ *
+ * @return true if traces made
+ */
+ virtual bool
+ getTraceSelects() const = 0;
+
+ /**
+ * Compose a diagnostic trace of the current selection
+ *
+ * @param theTemplate current context node
+ * @param nl list of selected nodes
+ */
+ virtual void
+ traceSelect(
+ const XalanElement& theTemplate,
+ const NodeRefListBase& nl) const = 0;
+
+
// These interfaces are inherited from XPathExecutionContext...
virtual XalanNode*
@@ -1117,17 +1160,17 @@
virtual bool
elementAvailable(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName) const = 0;
+ const XalanDOMString& elementName) const = 0;
virtual bool
functionAvailable(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName) const = 0;
+ const XalanDOMString& functionName) const = 0;
virtual XObject*
extFunction(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName,
+ const XalanDOMString& functionName,
XalanNode*
context,
const XObjectArgVectorType& argVec) = 0;
1.12 +42 -9
xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp
Index: StylesheetExecutionContextDefault.cpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- StylesheetExecutionContextDefault.cpp 2000/05/18 18:38:40 1.11
+++ StylesheetExecutionContextDefault.cpp 2000/05/24 19:38:49 1.12
@@ -209,7 +209,7 @@
void
-StylesheetExecutionContextDefault::setStylesheetRoot(StylesheetRoot*
theStylesheet)
+StylesheetExecutionContextDefault::setStylesheetRoot(const StylesheetRoot*
theStylesheet)
{
assert(theStylesheet->isRoot() == true);
@@ -688,12 +688,13 @@
bool
-StylesheetExecutionContextDefault::isTraceSelect() const
+StylesheetExecutionContextDefault::getTraceSelects() const
{
- return m_xsltProcessor.isTraceSelect();
+ return m_xsltProcessor.getTraceSelects();
}
+
void
StylesheetExecutionContextDefault::traceSelect(
const XalanElement& theTemplate,
@@ -1021,9 +1022,9 @@
bool
StylesheetExecutionContextDefault::elementAvailable(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName) const
+ const XalanDOMString& elementName) const
{
- return m_xpathExecutionContextDefault.elementAvailable(theNamespace,
extensionName);
+ return m_xpathExecutionContextDefault.elementAvailable(theNamespace,
elementName);
}
@@ -1031,9 +1032,9 @@
bool
StylesheetExecutionContextDefault::functionAvailable(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName) const
+ const XalanDOMString& functionName) const
{
- return m_xpathExecutionContextDefault.functionAvailable(theNamespace,
extensionName);
+ return m_xpathExecutionContextDefault.functionAvailable(theNamespace,
functionName);
}
@@ -1041,11 +1042,11 @@
XObject*
StylesheetExecutionContextDefault::extFunction(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName,
+ const XalanDOMString& functionName,
XalanNode*
context,
const XObjectArgVectorType& argVec)
{
- return m_xpathExecutionContextDefault.extFunction(theNamespace,
extensionName, context, argVec);
+ return m_xpathExecutionContextDefault.extFunction(theNamespace,
functionName, context, argVec);
}
@@ -1301,6 +1302,38 @@
m_textOutputStreams.insert(theTextOutputStream);
return createPrintWriter(theTextOutputStream);
+}
+
+
+
+unsigned long
+StylesheetExecutionContextDefault::getTraceListeners() const
+{
+ return m_xsltProcessor.getTraceListeners();
+}
+
+
+
+void
+StylesheetExecutionContextDefault::fireGenerateEvent(const GenerateEvent&
ge)
+{
+ m_xsltProcessor.fireGenerateEvent(ge);
+}
+
+
+
+void
+StylesheetExecutionContextDefault::fireTraceEvent(const TracerEvent& te)
+{
+ m_xsltProcessor.fireTraceEvent(te);
+}
+
+
+
+void
+StylesheetExecutionContextDefault::fireSelectEvent(const SelectionEvent&
se)
+{
+ m_xsltProcessor.fireSelectEvent(se);
}
1.13 +27 -13
xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp
Index: StylesheetExecutionContextDefault.hpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- StylesheetExecutionContextDefault.hpp 2000/05/18 18:38:40 1.12
+++ StylesheetExecutionContextDefault.hpp 2000/05/24 19:38:49 1.13
@@ -124,7 +124,7 @@
createDocument() const;
virtual void
- setStylesheetRoot(StylesheetRoot* theStylesheet);
+ setStylesheetRoot(const StylesheetRoot* theStylesheet);
virtual void
resetCurrentState(
@@ -316,14 +316,6 @@
getXalanXSLNameSpaceURL() const;
virtual bool
- isTraceSelect() const;
-
- virtual void
- traceSelect(
- const XalanElement& theTemplate,
- const NodeRefListBase& nl) const;
-
- virtual bool
findOnElementRecursionStack(const ElemTemplateElement* theElement)
const;
virtual void
@@ -408,6 +400,28 @@
static XalanNumberFormatFactory*
installXalanNumberFormatFactory(XalanNumberFormatFactory*
theFactory);
+ // Trace interface...
+ virtual unsigned long
+ getTraceListeners() const;
+
+ virtual void
+ fireGenerateEvent(const GenerateEvent& ge);
+
+ virtual void
+ fireTraceEvent(const TracerEvent& te);
+
+ virtual void
+ fireSelectEvent(const SelectionEvent& se);
+
+ virtual bool
+ getTraceSelects() const;
+
+ virtual void
+ traceSelect(
+ const XalanElement& theTemplate,
+ const NodeRefListBase& nl) const;
+
+
// These interfaces are inherited from XPathExecutionContext...
virtual XalanNode*
@@ -456,17 +470,17 @@
virtual bool
elementAvailable(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName) const;
+ const XalanDOMString& elementName) const;
virtual bool
functionAvailable(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName) const;
+ const XalanDOMString& functionName) const;
virtual XObject*
extFunction(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName,
+ const XalanDOMString& functionName,
XalanNode*
context,
const XObjectArgVectorType& argVec);
@@ -614,7 +628,7 @@
const PrefixResolver* m_prefixResolver;
- StylesheetRoot*
m_stylesheetRoot;
+ const StylesheetRoot* m_stylesheetRoot;
FormatterListenerSetType m_formatterListeners;
1.27 +4 -5 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.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- StylesheetHandler.cpp 2000/05/18 18:38:40 1.26
+++ StylesheetHandler.cpp 2000/05/24 19:38:49 1.27
@@ -538,22 +538,20 @@
}
else if(equals(aname,
Constants::ATTRNAME_EXTENSIONELEMENTPREFIXES))
{
- // BEGIN SANJIVA CODE
StringTokenizer
tokenizer(atts.getValue(i),
XALAN_STATIC_UCODE_STRING(" \t\n\r"),
false);
-
while(tokenizer.hasMoreTokens ())
+
while(tokenizer.hasMoreTokens() == true)
{
const
XalanDOMString prefix = tokenizer.nextToken();
// SANJIVA: ask
Scott: is the line below correct?
const
XalanDOMString extns = m_stylesheet.getNamespaceForPrefixFromStack(prefix);
-
ExtensionNSHandler* const nsh = new ExtensionNSHandler (m_processor,
extns);
+
ExtensionNSHandler* const nsh = new ExtensionNSHandler(m_processor,
extns);
m_stylesheet.addExtensionNamespace(extns, nsh);
}
- // END SANJIVA CODE
}
else if(equals(aname,
XALAN_STATIC_UCODE_STRING("id")))
{
@@ -1056,7 +1054,7 @@
m_foundStylesheet = true;
m_stylesheet.setWrapperless(true);
- if(equals(name, XALAN_STATIC_UCODE_STRING("HTML")))
+ if(equalsIgnoreCase(name, Constants::ELEMNAME_HTML_STRING) == true)
{
m_stylesheet.getStylesheetRoot().setIndentResult(true);
m_stylesheet.getStylesheetRoot().setOutputMethod(OUTPUT_METHOD_HTML);
@@ -1064,6 +1062,7 @@
return pElem;
}
+
static bool
1.16 +3 -74 xml-xalan/c/src/XSLT/StylesheetRoot.cpp
Index: StylesheetRoot.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetRoot.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- StylesheetRoot.cpp 2000/05/18 18:38:41 1.15
+++ StylesheetRoot.cpp 2000/05/24 19:38:49 1.16
@@ -190,7 +190,7 @@
StylesheetRoot::process(
XalanNode*
sourceTree,
XSLTResultTarget&
outputTarget,
- StylesheetExecutionContext&
executionContext)
+ StylesheetExecutionContext&
executionContext) const
{
// Find the root pattern in the XSL.
ElemTemplate* rootRule =
@@ -283,7 +283,7 @@
{
if (doIndent == true && indentAmount <
0)
{
- indentAmount = 4;
+ indentAmount =
FormatterToHTML::eDefaultIndentAmount;
}
flistener =
executionContext.createFormatterToHTML(
@@ -304,7 +304,7 @@
// indenting
if (doIndent == true && indentAmount <
0)
{
- indentAmount = 0;
+ indentAmount =
FormatterToXML::eDefaultIndentAmount;
}
flistener =
executionContext.createFormatterToXML(
@@ -672,75 +672,4 @@
assert(m_defaultRule != 0);
assert(m_defaultTextRule != 0);
assert(m_defaultRootRule != 0);
-}
-
-
-
-int
-StylesheetRoot::getTraceListeners() const
-{
- return m_traceListeners.size();
-}
-
-
-
-void
-StylesheetRoot::addTraceListener(TraceListener* tl)
-{
- m_traceListeners.push_back(tl);
-}
-
-
-
-void
-StylesheetRoot::removeTraceListener(TraceListener* theListener)
-{
-#if !defined(XALAN_NO_NAMESPACES)
- using std::find;
-#endif
-
- const ListenersVectorType::iterator it =
- find(m_traceListeners.begin(),
- m_traceListeners.end(),
- theListener);
-
- if (it != m_traceListeners.end())
- {
- m_traceListeners.erase(it);
- }
-}
-
-
-
-
-/**
- * Fire a trace event.
- */
-void
-StylesheetRoot::fireTraceEvent(const TracerEvent& te) const
-{
- const ListenersVectorType::size_type nListeners =
- m_traceListeners.size();
-
- for(ListenersVectorType::size_type i = 0; i < nListeners; i++)
- {
- m_traceListeners[i]->trace(te);
- }
-}
-
-
-
-/**
- * Fire a selection event.
- */
-void
-StylesheetRoot::fireSelectedEvent(const SelectionEvent& se) const
-{
- const ListenersVectorType::size_type nListeners =
- m_traceListeners.size();
-
- for(ListenersVectorType::size_type i = 0; i < nListeners; i++)
- {
- m_traceListeners[i]->selected(se);
- }
}
1.10 +12 -81 xml-xalan/c/src/XSLT/StylesheetRoot.hpp
Index: StylesheetRoot.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetRoot.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- StylesheetRoot.hpp 2000/05/18 18:38:41 1.9
+++ StylesheetRoot.hpp 2000/05/24 19:38:49 1.10
@@ -76,10 +76,7 @@
-class SelectionEvent;
class StylesheetConstructionContext;
-class TraceListener;
-class TracerEvent;
class XMLURL;
class XSLTResultTarget;
@@ -94,12 +91,6 @@
{
public:
-#if defined(XALAN_NO_NAMESPACES)
- typedef vector<TraceListener*> ListenersVectorType;
-#else
- typedef std::vector<TraceListener*> ListenersVectorType;
-#endif
-
/**
* Construct a Stylesheet from a Document.
*
@@ -124,7 +115,7 @@
process(
XalanNode*
sourceTree,
XSLTResultTarget&
outputTarget,
- StylesheetExecutionContext&
executionContext);
+ StylesheetExecutionContext&
executionContext) const;
/**
* Return the output method that was specified in the stylesheet.
@@ -238,7 +229,6 @@
return m_defaultTextRule;
}
-
/**
* Get the template representing the default rule.
*
@@ -286,32 +276,32 @@
* The version tells the version of XML to be used for outputting the
result tree,
* as specified in xsl:output.
*/
- XalanDOMString m_version; // = null;
+ XalanDOMString m_version;
/**
* indent-result is by default no, which means an XSL processor must not
* change the whitespace on output.
*/
- bool m_indentResult; // = false;
+ bool m_indentResult;
/**
* The encoding attribute specifies the preferred encoding to use
* for outputting the result tree.
*/
- XalanDOMString m_encoding; // = null;
+ XalanDOMString m_encoding;
/**
* The media-type attribute is applicable for the xml output method.
* The default value for the media-type attribute is text/xml.
*/
- XalanDOMString m_mediatype; // = null;
+ XalanDOMString m_mediatype;
/**
* If the doctype-system-id attribute is specified, the xml output
method should
* output a document type declaration immediately before the first
element.
* The name following <!DOCTYPE should be the name of the first
element.
*/
- XalanDOMString m_doctypeSystem; // = null;
+ XalanDOMString m_doctypeSystem;
/**
* If doctype-public-id attribute is also specified, then the xml
output
@@ -321,17 +311,17 @@
* doctype-public-id attribute should be ignored unless the
doctype-system-id
* attribute is specified.
*/
- XalanDOMString m_doctypePublic; // = null;
+ XalanDOMString m_doctypePublic;
/**
* Tells whether or not to output an XML declaration.
*/
- bool m_omitxmlDecl; // = false;
+ bool m_omitxmlDecl;
/**
* Tells what the xmldecl should specify for the standalone value.
*/
- XalanDOMString m_standalone; // = null;
+ XalanDOMString m_standalone;
/**
* Retrieve the stack of imported stylesheets.
@@ -355,7 +345,6 @@
return m_importStack;
}
-
/**
* Change the value of the flag for indenting results.
*
@@ -380,62 +369,16 @@
}
/**
- * Determine the number of trace listeners.
- *
- * @return number of listeners
- */
- int
- getTraceListeners() const;
-
- /**
- * Add a trace listener for the purposes of debugging and diagnosis.
- *
- * @param tl pointer to listener to add
- */
- void
- addTraceListener(TraceListener *tl);
-
- /**
- * Remove a trace listener.
- *
- * @param tl pointer to listener to remove
- */
- void
- removeTraceListener(TraceListener* tl);
-
- /**
- * Fire a trace event.
- *
- * @param te trace event to fire
- */
- void
- fireTraceEvent(const TracerEvent& te) const;
-
- /**
- * Fire a selection event.
- *
- * @param se selection event to fire
- */
- void
- fireSelectedEvent(const SelectionEvent& se) const;
-
- /**
* Retrieve list of CDATA section elements.
*
* @return vector of elements
*/
const QNameVectorType&
- getCdataSectionElems()
+ getCDATASectionElems() const
{
return m_cdataSectionElems;
}
- // Read the stylesheet root from a serialization stream.
- // @@ Not implemented yet
- // void readObject(ObjectInputStream stream);
-
- // These methods are inherited from Stylesheet ...
-
private:
/**
@@ -443,18 +386,7 @@
* @serial
*/
XalanDOMString m_resultNameSpaceURL;
-
- /**
- * List of listeners who are interested in tracing what's going on.
- */
- //transient
- ListenersVectorType m_traceListeners;
-
- /**
- * String buffer for use by AVTs and the like.
- */
- //java: transient DOMStringBuffer m_stringbuf = new StringBuffer();
-
+
/**
* The output method as specified in xsl:output.
*/
@@ -473,10 +405,9 @@
* particular URI is imported in multiple places is not treated
* specially."
*/
- //transient
URLStackType m_importStack;
+
-
/**
* The default template to use for text nodes if we don't find
* anything else. This is initialized in initDefaultRule().
1.3 +80 -22 xml-xalan/c/src/XSLT/TraceListener.hpp
Index: TraceListener.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/TraceListener.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TraceListener.hpp 2000/02/29 20:54:24 1.2
+++ TraceListener.hpp 2000/05/24 19:38:49 1.3
@@ -64,32 +64,90 @@
class SelectionEvent;
class GenerateEvent;
-class TraceListener
+class XALAN_XSLT_EXPORT TraceListener
{
public:
- /**
- * Method that is called when a trace event occurs. The method is
blocking.
- * It must return before processing continues.
- *
- * @param ev trace event
- */
- virtual void trace(const TracerEvent& ev) = 0;
-
- /**
- * Method that is called just after the formatter listener is called.
- *
- * @param ev generate event
- */
- virtual void selected(const SelectionEvent& ev) = 0;
-
- /**
- * Method that is called just after the formatter listener is called.
- *
- * @param ev generate event
- */
- virtual void generated(const GenerateEvent& ev) = 0;
+ TraceListener();
+ virtual
+ ~TraceListener();
+
+ /**
+ * Method that is called when a trace event occurs. The method is
blocking.
+ * It must return before processing continues.
+ *
+ * @param ev trace event
+ */
+ virtual void
+ trace(const TracerEvent& ev) = 0;
+
+ /**
+ * Method that is called just after the formatter listener is called.
+ *
+ * @param ev generate event
+ */
+ virtual void
+ selected(const SelectionEvent& ev) = 0;
+
+ /**
+ * Method that is called just after the formatter listener is called.
+ *
+ * @param ev generate event
+ */
+ virtual void
+ generated(const GenerateEvent& ev) = 0;
+
+ struct TraceListenerTraceFunctor
+ {
+ TraceListenerTraceFunctor(const TracerEvent& theEvent) :
+ m_event(theEvent)
+ {
+ }
+
+ void
+ operator()(TraceListener* theListener) const
+ {
+ theListener->trace(m_event);
+ }
+
+ const TracerEvent& m_event;
+ };
+
+ struct TraceListenerSelectFunctor
+ {
+ TraceListenerSelectFunctor(const SelectionEvent&
theEvent) :
+ m_event(theEvent)
+ {
+ }
+
+ void
+ operator()(TraceListener* theListener) const
+ {
+ theListener->selected(m_event);
+ }
+
+ const SelectionEvent& m_event;
+ };
+
+ struct TraceListenerGenerateFunctor
+ {
+ TraceListenerGenerateFunctor(const GenerateEvent&
theEvent) :
+ m_event(theEvent)
+ {
+ }
+
+ void
+ operator()(TraceListener* theListener) const
+ {
+ theListener->generated(m_event);
+ }
+
+ const GenerateEvent& m_event;
+ };
+
};
+
+
#endif //XALAN_TraceListener_HEADER_GUARD
1.39 +327 -346 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.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- XSLTEngineImpl.cpp 2000/05/18 18:38:41 1.38
+++ XSLTEngineImpl.cpp 2000/05/24 19:38:49 1.39
@@ -200,6 +200,7 @@
m_currentNode(),
m_pendingElementName(),
m_pendingAttributes(),
+ m_hasPendingStartDocument(false),
m_resultNameSpaces(),
m_emptyNamespace(),
m_xpathFactory(xpathFactory),
@@ -211,10 +212,8 @@
m_problemListener(new ProblemListenerDefault()),
m_stylesheetRoot(0),
m_XSLDirectiveLookup(),
- m_quietConflictWarnings(false),
- m_traceTemplateChildren(false),
- m_traceTemplates(false),
m_traceSelects(false),
+ m_quietConflictWarnings(false),
m_diagnosticsPrintWriter(0),
m_durationsTable(),
m_traceListeners(),
@@ -270,6 +269,7 @@
m_currentNode = 0;
m_needToCheckForInfiniteLoops = false;
m_variableStacks.reset();
+ m_hasPendingStartDocument = false;
m_stackGuard.clear();
m_xpathSupport.reset();
@@ -346,29 +346,38 @@
void
XSLTEngineImpl::process(
XSLTInputSource&
inputSource,
- XSLTInputSource*
stylesheetSource,
+ XSLTInputSource&
stylesheetSource,
XSLTResultTarget& outputTarget,
StylesheetConstructionContext& constructionContext,
StylesheetExecutionContext&
executionContext)
{
try
{
- XalanDOMString xslIdentifier(((0 == stylesheetSource) ||
-
(0 == stylesheetSource->getSystemId()))
-
? XalanDOMString(XALAN_STATIC_UCODE_STRING("Input XSL")) :
stylesheetSource->getSystemId());
+ XalanDOMString xslIdentifier(0 ==
stylesheetSource.getSystemId()
+
? XalanDOMString(XALAN_STATIC_UCODE_STRING("Input XSL")) :
stylesheetSource.getSystemId());
bool totalTimeID = true;
pushTime(&totalTimeID);
-
- XalanNode* sourceTree = 0;
- sourceTree = getSourceTreeFromInput(inputSource);
+ XalanNode* sourceTree =
getSourceTreeFromInput(inputSource);
- if(0 != stylesheetSource)
+ try
{
- m_stylesheetRoot = processStylesheet(*stylesheetSource,
constructionContext);
+ m_stylesheetRoot = processStylesheet(stylesheetSource,
constructionContext);
}
- else if(0 != sourceTree)
+ catch(const XSLException&)
{
+ }
+ catch(const SAXException&)
+ {
+ }
+ catch(const XMLException&)
+ {
+ }
+
+ if(0 != sourceTree && m_stylesheetRoot == 0)
+ {
+ // Didn't get a stylesheet from the input source, so
look for a
+ // stylesheet processing instruction...
XalanDOMString stylesheetURI = 0;
XalanNode* child =
sourceTree->getFirstChild();
@@ -419,16 +428,18 @@
if(isOK)
{
StringTokenizer
tokenizer(child->getNodeValue(), XALAN_STATIC_UCODE_STRING(" \t="), true);
+
while(tokenizer.hasMoreTokens())
{
-
if(equals(tokenizer.nextToken(), XALAN_STATIC_UCODE_STRING("href")))
+ const
XalanDOMString theCurrentToken = tokenizer.nextToken();
+
+
if(equals(theCurrentToken, XALAN_STATIC_UCODE_STRING("href")))
{
stylesheetURI = tokenizer.nextToken();
-
stylesheetURI = substring(stylesheetURI, 1, stylesheetURI.length()-1);
+
stylesheetURI = substring(stylesheetURI, 1, length(stylesheetURI) - 1);
hrefs.push_back(stylesheetURI);
}
}
- // break;
}
}
}
@@ -457,17 +468,12 @@
hrefs.pop_back();
}
}
- else
- {
- error("Stylesheet input was not specified!");
- }
if(0 == m_stylesheetRoot)
{
error("Failed to process stylesheet!");
}
-
- if(0 != sourceTree)
+ else if(0 != sourceTree)
{
executionContext.setStylesheetRoot(m_stylesheetRoot);
@@ -479,23 +485,6 @@
}
}
}
-/*
- catch(MalformedURLException mue)
- {
- error(mue.getMessage(), mue);
- // throw se;
- }
- catch(FileNotFoundException fnfe)
- {
- error(fnfe.getMessage(), fnfe);
- // throw se;
- }
- catch(IOException ioe)
- {
- error(ioe.getMessage(), ioe);
- // throw se;
- }
- */
catch(SAXException& se)
{
message("SAX Exception");
@@ -512,6 +501,39 @@
+void
+XSLTEngineImpl::process(
+ XSLTInputSource&
inputSource,
+ XSLTResultTarget& outputTarget,
+ StylesheetExecutionContext&
executionContext)
+{
+ bool totalTimeID = true;
+
+ if(0 != m_diagnosticsPrintWriter)
+ {
+ pushTime(&totalTimeID);
+ }
+
+ XalanNode* const sourceTree =
getSourceTreeFromInput(inputSource);
+
+ if(0 != sourceTree)
+ {
+ if (m_stylesheetRoot == 0)
+ {
+ error("No stylesheet is available to process!");
+ }
+
+ m_stylesheetRoot->process(sourceTree, outputTarget,
executionContext);
+ }
+
+ if(0 != m_diagnosticsPrintWriter)
+ {
+ displayDuration(XALAN_STATIC_UCODE_STRING("Total time"),
&totalTimeID);
+ }
+}
+
+
+
StylesheetRoot*
XSLTEngineImpl::processStylesheet(
const XalanDOMString&
xsldocURLString,
@@ -529,6 +551,7 @@
throw se;
}
+
return 0;
}
@@ -543,15 +566,15 @@
const XalanDOMString xslIdentifier(0 ==
stylesheetSource.getSystemId() ?
ds :
stylesheetSource.getSystemId());
+ StylesheetRoot* theStylesheet = 0;
+
// In case we have a fragment identifier, go ahead and
// try to parse the XML here.
try
{
- m_stylesheetRoot = constructionContext.create(stylesheetSource);
-
- addTraceListenersToStylesheet();
+ theStylesheet = constructionContext.create(stylesheetSource);
- StylesheetHandler stylesheetProcessor(*this,
*m_stylesheetRoot, constructionContext);
+ StylesheetHandler stylesheetProcessor(*this,
*theStylesheet, constructionContext);
if(0 != stylesheetSource.getNode())
{
@@ -575,15 +598,12 @@
throw;
}
-
catch(const SAXException&)
{
message("Error parsing " + xslIdentifier);
throw;
}
-
-
catch(const XMLException&)
{
message("Error parsing " + xslIdentifier);
@@ -591,7 +611,9 @@
throw;
}
- return m_stylesheetRoot;
+ m_stylesheetRoot = theStylesheet;
+
+ return theStylesheet;
}
@@ -822,16 +844,18 @@
if(isRoot)
{
- m_stylesheetRoot =
constructionContext.create(stringHolder);
- stylesheet = m_stylesheetRoot;
+ StylesheetRoot* const theLocalRoot =
+
constructionContext.create(stringHolder);
+
+ stylesheet = theLocalRoot;
+
+ m_stylesheetRoot = theLocalRoot;
}
else
{
- stylesheet = new Stylesheet(*m_stylesheetRoot,
stringHolder, constructionContext);
+ stylesheet = new
Stylesheet(*const_cast<StylesheetRoot*>(m_stylesheetRoot), stringHolder,
constructionContext);
}
- addTraceListenersToStylesheet();
-
StylesheetHandler stylesheetProcessor(*this,
*stylesheet, constructionContext);
FormatterTreeWalker tw(stylesheetProcessor);
@@ -859,16 +883,18 @@
if(isRoot)
{
- m_stylesheetRoot =
constructionContext.create(localXSLURLString);
- stylesheet = m_stylesheetRoot;
+ StylesheetRoot* const theLocalRoot =
+
constructionContext.create(localXSLURLString);
+
+ stylesheet = theLocalRoot;
+
+ m_stylesheetRoot = theLocalRoot;
}
else
{
- stylesheet = new Stylesheet(*m_stylesheetRoot,
localXSLURLString, constructionContext);
+ stylesheet = new
Stylesheet(*const_cast<StylesheetRoot*>(m_stylesheetRoot), localXSLURLString,
constructionContext);
}
- addTraceListenersToStylesheet();
-
StylesheetHandler stylesheetProcessor(*this, *stylesheet,
constructionContext);
typedef StylesheetConstructionContext::URLAutoPtrType
URLAutoPtrType;
@@ -891,7 +917,8 @@
//==========================================================
-double XSLTEngineImpl::getXSLTVerSupported()
+double
+XSLTEngineImpl::getXSLTVerSupported()
{
return s_XSLTVerSupported;
}
@@ -909,6 +936,7 @@
int tok = -2;
if(XalanNode::ELEMENT_NODE != node.getNodeType()) return tok;
+
const XalanDOMString ns =
m_xpathSupport.getNamespaceOfNode(node);
@@ -919,27 +947,26 @@
const ElementKeysMapType::const_iterator j =
s_elementKeys.find(localName);
+
if(j != s_elementKeys.end())
{
tok = (*j).second;
}
- else
- tok = -2;
}
else if(equals(ns, s_XSLT4JNameSpaceURL))
{
- const XalanDOMString localName =
m_xpathSupport.getLocalNameOfNode(node);
+ const XalanDOMString localName =
+ m_xpathSupport.getLocalNameOfNode(node);
+
const ElementKeysMapType::const_iterator j =
s_XSLT4JElementKeys.find(localName);
+
if(j != s_XSLT4JElementKeys.end())
{
tok = (*j).second;
}
- else
- tok = -2;
}
- else
- tok = -2;
+
return tok;
}
@@ -1037,135 +1064,132 @@
-bool
-XSLTEngineImpl::functionAvailable(
- XalanDOMString& theNamespace,
- XalanDOMString& extensionName) const
+const StylesheetRoot*
+XSLTEngineImpl::getStylesheetRoot() const
{
- return m_xpathEnvSupport.functionAvailable(theNamespace, extensionName);
+ return m_stylesheetRoot;
}
-/**
- * Handle an extension function.
- */
-XObject*
-XSLTEngineImpl::extFunction(
- XPathExecutionContext&
executionContext,
- const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName,
- XalanNode*
context,
- const XObjectArgVectorType& argVec) const
+void
+XSLTEngineImpl::setStylesheetRoot(const StylesheetRoot*
theStylesheet)
{
- return m_xpathEnvSupport.extFunction(
- executionContext,
- theNamespace,
- extensionName,
- context,
- argVec);
+ m_stylesheetRoot = theStylesheet;
}
void
-XSLTEngineImpl::handleFunctionsInstruction(XalanElement& /*
extensionElem */)
+XSLTEngineImpl::setExecutionContext(StylesheetExecutionContext*
theExecutionContext)
{
- error("Calling external functions is not supported in the C++ version
of Xalan!!!");
+ m_executionContext = theExecutionContext;
}
-StylesheetRoot*
-XSLTEngineImpl::getStylesheetRoot() const
+//==========================================================
+// SECTION: Diagnostic functions
+//==========================================================
+
+unsigned long
+XSLTEngineImpl::getTraceListeners() const
{
- return m_stylesheetRoot;
+ return m_traceListeners.size();
}
void
-XSLTEngineImpl::setStylesheetRoot(StylesheetRoot* theStylesheet)
+XSLTEngineImpl::addTraceListener(TraceListener* tl)
{
- m_stylesheetRoot = theStylesheet;
+ if (tl != 0)
+ {
+ m_traceListeners.push_back(tl);
+ }
}
void
-XSLTEngineImpl::setExecutionContext(StylesheetExecutionContext*
theExecutionContext)
+XSLTEngineImpl::removeTraceListener(TraceListener* tl)
{
- m_executionContext = theExecutionContext;
-}
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::remove;
+#endif
+ const TraceListenerVectorType::iterator i =
+ remove(
+ m_traceListeners.begin(),
+ m_traceListeners.end(),
+ tl);
+ m_traceListeners.erase(i);
+}
-//==========================================================
-// SECTION: Diagnostic functions
-//==========================================================
-/**
- * Add a trace listener for the purposes of debugging and diagnosis.
- * @param tl Trace listener to be added.
- */
-void XSLTEngineImpl::addTraceListener(TraceListener* tl)
- // throws TooManyListenersException
+
+void
+XSLTEngineImpl::fireGenerateEvent(const GenerateEvent& ge)
{
- m_traceListeners.push_back(tl);
- if(0 != m_stylesheetRoot)
- m_stylesheetRoot->addTraceListener(tl);
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::for_each;
+#endif
+
+ for_each(
+ m_traceListeners.begin(),
+ m_traceListeners.end(),
+ TraceListener::TraceListenerGenerateFunctor(ge));
}
-/**
- * Add a trace listener for the purposes of debugging and diagnosis.
- * @param tl Trace listener to be added.
- */
-void XSLTEngineImpl::addTraceListenersToStylesheet()
+
+
+void
+XSLTEngineImpl::fireSelectEvent(const SelectionEvent& se)
{
- if(0 == m_stylesheetRoot) return;
- try
- {
- int nListeners = m_traceListeners.size();
- for(int i = 0; i < nListeners; i++)
- {
- TraceListener* tl = m_traceListeners[i];
- m_stylesheetRoot->addTraceListener(tl);
- }
- }
- catch(...)
- // catch(TooManyListenersException tmle)
- {
- throw SAXException("addTraceListenersToStylesheet -
TooManyListenersException");
- }
-}
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::for_each;
+#endif
+
+ for_each(
+ m_traceListeners.begin(),
+ m_traceListeners.end(),
+ TraceListener::TraceListenerSelectFunctor(se));
+}
+
-void XSLTEngineImpl::removeTraceListener(TraceListener* tl)
+void
+XSLTEngineImpl::fireTraceEvent(const TracerEvent& te)
{
- int nListeners = m_traceListeners.size();
- for(int i = 0; i < nListeners; i++)
- {
- TraceListener* tli = m_traceListeners[i];
- if (tli == tl)
m_traceListeners.erase(m_traceListeners.begin()+i);
- }
- if(0 != m_stylesheetRoot)
- m_stylesheetRoot->removeTraceListener(tl);
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::for_each;
+#endif
+
+ for_each(
+ m_traceListeners.begin(),
+ m_traceListeners.end(),
+ TraceListener::TraceListenerTraceFunctor(te));
}
+
-void XSLTEngineImpl::fireGenerateEvent(const GenerateEvent& te)
+bool
+XSLTEngineImpl::getTraceSelects() const
{
- const int nListeners = m_traceListeners.size();
+ return m_traceSelects;
+}
- for(int i = 0; i < nListeners; i++)
- {
- TraceListener* const tl = m_traceListeners[i];
- tl->generated(te);
- }
+
+void
+XSLTEngineImpl::setTraceSelects(bool b)
+{
+ m_traceSelects = b;
}
+
void
XSLTEngineImpl::message(
const XalanDOMString& msg,
@@ -1270,22 +1294,25 @@
m_durationsTable.erase(i);
}
}
+
return clockTicksDuration;
}
void
-XSLTEngineImpl::displayDuration(const XalanDOMString& info,
- const void*
key) const
+XSLTEngineImpl::displayDuration(
+ const XalanDOMString& info,
+ const void* key) const
{
if(0 != key)
{
const clock_t theDuration = popDuration(key);
- double millis = 1000.0*theDuration/CLOCKS_PER_SEC;
if(0 != m_diagnosticsPrintWriter)
{
+ const double millis = (1000.0 * theDuration) /
CLOCKS_PER_SEC;
+
XalanDOMString msg(info);
msg += XALAN_STATIC_UCODE_STRING(" took ");
@@ -1298,13 +1325,17 @@
}
+
void
XSLTEngineImpl::setDiagnosticsOutput(PrintWriter* pw)
{
m_diagnosticsPrintWriter = pw;
+
m_problemListener->setPrintWriter(pw);
}
+
+
void
XSLTEngineImpl::diag(const XalanDOMString& s) const
{
@@ -1314,44 +1345,20 @@
}
}
-/**
- * If this is set to true, simple traces of
- * template calls are made.
- */
-void
-XSLTEngineImpl::setTraceTemplates(bool b)
-{
- m_traceTemplates = b;
-}
-
void
-XSLTEngineImpl::setTraceSelect(bool b)
-{
- m_traceSelects = b;
-}
-
-
-
-bool XSLTEngineImpl::isTraceSelect() const
+XSLTEngineImpl::setQuietConflictWarnings(bool b)
{
- return m_traceSelects;
+ m_quietConflictWarnings = b;
}
-void
-XSLTEngineImpl::setTraceTemplateChildren(bool b)
-{
- m_traceTemplateChildren = b;
-}
-
-
void
-XSLTEngineImpl::setQuietConflictWarnings(bool b)
+XSLTEngineImpl::setDocumentLocator(const Locator* const /*
locator */)
{
- m_quietConflictWarnings = b;
+ // Do nothing for now
}
@@ -1361,130 +1368,61 @@
const XalanElement& theTemplate,
const NodeRefListBase& nl) const
{
- XalanDOMString msg = theTemplate.getNodeName() +
XalanDOMString(XALAN_STATIC_UCODE_STRING(": "));
-
- XalanAttr* attr =
theTemplate.getAttributeNode(Constants::ATTRNAME_SELECT);
-
- if(0 != attr)
- {
- msg += attr->getValue();
- msg += XALAN_STATIC_UCODE_STRING(", ");
- msg += LongToDOMString(nl.getLength());
- msg += XALAN_STATIC_UCODE_STRING(" selected");
- }
- else
- {
- msg += XALAN_STATIC_UCODE_STRING("*|text(), (default select),
");
- msg += LongToDOMString(nl.getLength());
- msg += XALAN_STATIC_UCODE_STRING(" selected");
- }
-
- attr = theTemplate.getAttributeNode(Constants::ATTRNAME_MODE);
-
- if(0 != attr)
+ if (0 != m_diagnosticsPrintWriter)
{
- msg += XalanDOMString(XALAN_STATIC_UCODE_STRING(", mode = ")) +
attr->getValue();
- }
+ XalanDOMString msg = theTemplate.getNodeName() +
XalanDOMString(XALAN_STATIC_UCODE_STRING(": "));
- // $$$ ToDo: We do all of this work, and don't output the message.
- //System.out.println(msg);
-}
-
+ XalanAttr* attr =
theTemplate.getAttributeNode(Constants::ATTRNAME_SELECT);
-
-void
-XSLTEngineImpl::traceTemplate(const XalanElement& theTemplate) const
-{
- XalanDOMString msg;
-
- XalanAttr* attr =
theTemplate.getAttributeNode(Constants::ATTRNAME_MATCH);
-
- if(0 != attr)
- {
- msg = XalanDOMString(XALAN_STATIC_UCODE_STRING("Calling
template for: ")) + attr->getValue();
- }
- else
- {
- attr = theTemplate.getAttributeNode(Constants::ATTRNAME_NAME);
-
- if(0 != attr)
+ if(0 != attr)
{
- msg = XalanDOMString(XALAN_STATIC_UCODE_STRING("Calling
named template, name = ")) + attr->getValue();
+ msg += attr->getValue();
+ msg += XALAN_STATIC_UCODE_STRING(", ");
+ msg += LongToDOMString(nl.getLength());
+ msg += XALAN_STATIC_UCODE_STRING(" selected");
}
else
{
- const int xslToken = getXSLToken(theTemplate);
-
- if(Constants::ELEMNAME_FOREACH == xslToken)
- {
- attr =
theTemplate.getAttributeNode(Constants::ATTRNAME_SELECT);
-
- if(0 != attr)
- {
- msg =
XalanDOMString(XALAN_STATIC_UCODE_STRING("Processing for-each, select = ")) +
attr->getValue();
- }
- else
- {
- error("for-each must have either a
match or name attribute");
- clear(msg);
- }
- }
- else
- {
- error("templates must have either a match or
name attribute");
-
- clear(msg);
- }
+ msg += XALAN_STATIC_UCODE_STRING("*|text(), (default
select), ");
+ msg += LongToDOMString(nl.getLength());
+ msg += XALAN_STATIC_UCODE_STRING(" selected");
}
- }
- attr = theTemplate.getAttributeNode(Constants::ATTRNAME_MODE);
+ attr = theTemplate.getAttributeNode(Constants::ATTRNAME_MODE);
- if(0 != attr)
- {
- msg += XalanDOMString(XALAN_STATIC_UCODE_STRING(", mode = ")) +
attr->getValue();
- }
-
- // $$$ ToDo: We do all of this work, and don't output the message.
- //System.out.println(msg);
-}
-
+ if(0 != attr)
+ {
+ msg += XalanDOMString(XALAN_STATIC_UCODE_STRING(", mode
= ")) + attr->getValue();
+ }
-void
-XSLTEngineImpl::diagnoseTemplateChildren(
- const XalanNode& templateChild,
- const XalanNode& sourceNode) const
-{
- if(m_traceTemplateChildren)
- {
- const XalanDOMString templateChildTagName =
templateChild.getNodeName();
- const XalanDOMString xmlElemName = sourceNode.getNodeName();
- diag(XalanDOMString(XALAN_STATIC_UCODE_STRING("source node: "))
- + xmlElemName
- + XalanDOMString(XALAN_STATIC_UCODE_STRING(",
template-node: "))
- + templateChildTagName);
+ m_diagnosticsPrintWriter->println(msg);
}
}
-
-
-void
-XSLTEngineImpl::setDocumentLocator(const Locator* const /*
locator */)
-{
- // Do nothing for now
-}
-
void
XSLTEngineImpl::startDocument()
{
assert(m_flistener != 0);
- m_flistener->startDocument();
- if(m_traceListeners.size() > 0)
+ assert(m_executionContext != 0);
+
+// if (m_hasPendingStartDocument == false)
+// {
+// m_hasPendingStartDocument = true;
+// }
+// else
{
- GenerateEvent ge(this, GenerateEvent::EVENTTYPE_STARTDOCUMENT);
- fireGenerateEvent(ge);
+ m_flistener->startDocument();
+
+ if(getTraceListeners() > 0)
+ {
+ GenerateEvent ge(this,
GenerateEvent::EVENTTYPE_STARTDOCUMENT);
+
+ fireGenerateEvent(ge);
+ }
+
+ m_hasPendingStartDocument = false;
}
}
@@ -1497,34 +1435,54 @@
assert(m_executionContext != 0);
flushPending();
+
m_flistener->endDocument();
- if(m_traceListeners.size() > 0)
+
+ if(getTraceListeners() > 0)
{
GenerateEvent ge(this, GenerateEvent::EVENTTYPE_ENDDOCUMENT);
+
fireGenerateEvent(ge);
}
+
m_variableStacks.popCurrentContext();
}
+
-void XSLTEngineImpl::addResultNamespaceDecl(const XalanDOMString& prefix,
- const XalanDOMString& namespaceVal)
+
+void
+XSLTEngineImpl::addResultNamespaceDecl(
+ const XalanDOMString& prefix,
+ const XalanDOMString& namespaceVal)
{
- NamespaceVectorType nsVector;
- NameSpace ns(prefix, namespaceVal);
- assert(m_resultNameSpaces.size() > 0);
- NamespaceVectorType nsOnStack = m_resultNameSpaces.back();
- // If the last vector contains only an empty namespace, replace it with
a
- // new vector containing only this namespace
- if(isEmpty(nsOnStack.front().getURI()))
+
+ const NameSpace ns(prefix, namespaceVal);
+
+ if (m_resultNameSpaces.size() == 0)
{
+ NamespaceVectorType nsVector;
nsVector.push_back(ns);
- m_resultNameSpaces.pop_back();
+
m_resultNameSpaces.push_back(nsVector);
}
- // Otherwise, add the namespace at the end of the last vector
else
{
- nsOnStack.push_back(ns);
+ NamespaceVectorType& nsOnStack = m_resultNameSpaces.back();
+
+ // If the last vector contains only an empty namespace, replace
it with a
+ // new vector containing only this namespace
+ if(isEmpty(nsOnStack.front().getURI()))
+ {
+ NamespaceVectorType nsVector;
+ nsVector.push_back(ns);
+
+ nsOnStack = nsVector;
+ }
+ // Otherwise, add the namespace at the end of the last vector
+ else
+ {
+ nsOnStack.push_back(ns);
+ }
}
}
@@ -1589,6 +1547,11 @@
void
XSLTEngineImpl::flushPending()
{
+ if (m_hasPendingStartDocument == true)
+ {
+ startDocument();
+ }
+
if(0 != length(m_pendingElementName))
{
assert(m_flistener != 0);
@@ -1597,13 +1560,14 @@
if (m_stylesheetRoot->isOutputMethodSet() == false)
{
if (equalsIgnoreCase(m_pendingElementName,
-
XALAN_STATIC_UCODE_STRING("html")) == true &&
+
Constants::ELEMNAME_HTML_STRING) == true &&
+// m_hasPendingStartDocument == true &&
pendingAttributesHasDefaultNS() == false)
{
if (m_flistener->getOutputFormat() ==
FormatterListener::OUTPUT_METHOD_XML)
{
// Yuck!!! Ugly hack to switch to HTML
on-the-fly. You can
- // blame this ridiculous crap on James
Clark ([EMAIL PROTECTED])
+ // blame this ridiculous crap on the
XSLT Working Group...
FormatterToXML* const theFormatter =
static_cast<FormatterToXML*>(m_flistener);
@@ -1615,20 +1579,25 @@
theFormatter->getDoctypeSystem(),
theFormatter->getDoctypePublic(),
true, // indent
-
theFormatter->getIndent() > 0 ? theFormatter->getIndent() : 4);
+
theFormatter->getIndent() > 0 ? theFormatter->getIndent() :
+
StylesheetExecutionContext::eDefaultHTMLIndentAmount);
}
}
}
m_cdataStack.push_back(isCDataResultElem(m_pendingElementName)?
true : false);
m_flistener->startElement(c_wstr(m_pendingElementName),
m_pendingAttributes);
- if(m_traceListeners.size() > 0)
+
+ if(getTraceListeners() > 0)
{
- GenerateEvent ge(this,
GenerateEvent::EVENTTYPE_STARTELEMENT,
+ const GenerateEvent ge(this,
GenerateEvent::EVENTTYPE_STARTELEMENT,
m_pendingElementName,
&m_pendingAttributes);
+
fireGenerateEvent(ge);
}
+
m_pendingAttributes.clear();
+
clear(m_pendingElementName);
}
}
@@ -1660,10 +1629,10 @@
assert(m_flistener != 0);
assert(name != 0);
flushPending();
- const int nAtts = atts.getLength();
+ const unsigned int nAtts = atts.getLength();
m_pendingAttributes.clear();
- for(int i = 0; i < nAtts; i++)
+ for(unsigned int i = 0; i < nAtts; i++)
{
m_pendingAttributes.addAttribute(atts.getName(i),
atts.getType(i),
@@ -1672,9 +1641,11 @@
// Push a new container on the stack, then push an empty
// result namespace on to that container.
- NamespaceVectorType nsVector;
+ NamespaceVectorType nsVector;
nsVector.push_back(m_emptyNamespace);
+
m_resultNameSpaces.push_back(nsVector);
+
m_pendingElementName = name;
}
@@ -1690,7 +1661,7 @@
m_flistener->endElement(name);
- if(m_traceListeners.size() > 0)
+ if(getTraceListeners() > 0)
{
GenerateEvent ge(this, GenerateEvent::EVENTTYPE_ENDELEMENT,
name, 0);
fireGenerateEvent(ge);
@@ -1699,7 +1670,7 @@
m_resultNameSpaces.pop_back();
const Stylesheet::QNameVectorType& cdataElems =
- m_stylesheetRoot->getCdataSectionElems();
+ m_stylesheetRoot->getCDATASectionElems();
if(0 != cdataElems.size())
{
@@ -1732,13 +1703,13 @@
flushPending();
const Stylesheet::QNameVectorType& cdataElems =
- m_stylesheetRoot->getCdataSectionElems();
+ m_stylesheetRoot->getCDATASectionElems();
if(0 != cdataElems.size() && 0 != m_cdataStack.size())
{
m_flistener->cdata(ch + start, length);
- if(m_traceListeners.size() > 0)
+ if(getTraceListeners() > 0)
{
GenerateEvent ge(this, GenerateEvent::EVENTTYPE_CDATA,
ch, start, length);
fireGenerateEvent(ge);
@@ -1748,7 +1719,7 @@
{
m_flistener->characters(ch + start, length);
- if(m_traceListeners.size() > 0)
+ if(getTraceListeners() > 0)
{
GenerateEvent ge(this,
GenerateEvent::EVENTTYPE_CHARACTERS, ch,
start, length);
@@ -1766,20 +1737,10 @@
const unsigned int length)
{
flushPending();
-
- FormatterListener* const pFL =
- dynamic_cast<FormatterListener*>(m_flistener);
- if(0 != pFL)
- {
- pFL->charactersRaw(ch, length);
- }
- else
- {
- m_flistener->characters(ch, length);
- }
+ m_flistener->charactersRaw(ch, length);
- if(m_traceListeners.size() > 0)
+ if(getTraceListeners() > 0)
{
GenerateEvent ge(this, GenerateEvent::EVENTTYPE_CHARACTERS,
ch, 0, length);
@@ -1809,12 +1770,16 @@
{
assert(m_flistener != 0);
assert(ch != 0);
+
flushPending();
+
m_flistener->ignorableWhitespace(ch, length);
- if(m_traceListeners.size() > 0)
+
+ if(getTraceListeners() > 0)
{
GenerateEvent ge(this,
GenerateEvent::EVENTTYPE_IGNORABLEWHITESPACE,
ch, 0, length);
+
fireGenerateEvent(ge);
}
}
@@ -1829,12 +1794,16 @@
assert(m_flistener != 0);
assert(target != 0);
assert(data != 0);
+
flushPending();
+
m_flistener->processingInstruction(target, data);
- if(m_traceListeners.size() > 0)
+
+ if(getTraceListeners() > 0)
{
GenerateEvent ge(this, GenerateEvent::EVENTTYPE_PI,
target, data);
+
fireGenerateEvent(ge);
}
}
@@ -1846,12 +1815,12 @@
{
assert(m_flistener != 0);
assert(data != 0);
+
flushPending();
- // future: assert (m_flistener.getType == eFormatterListener)
- FormatterListener* pfl =
- static_cast<FormatterListener*>(m_flistener);
- pfl->comment(data);
- if(m_traceListeners.size() > 0)
+
+ m_flistener->comment(data);
+
+ if(getTraceListeners() > 0)
{
GenerateEvent ge(this, GenerateEvent::EVENTTYPE_COMMENT,
data);
@@ -1865,49 +1834,57 @@
{
assert(m_flistener != 0);
assert(name != 0);
+
flushPending();
- // future: assert (m_flistener.getType == eFormatterListener)
- FormatterListener* pfl =
- static_cast<FormatterListener*>(m_flistener);
- pfl->entityReference(name);
- if(m_traceListeners.size() > 0)
+
+ m_flistener->entityReference(name);
+
+ if(getTraceListeners() > 0)
{
GenerateEvent ge(this, GenerateEvent::EVENTTYPE_ENTITYREF,
name);
+
fireGenerateEvent(ge);
}
}
-void XSLTEngineImpl::cdata(
+
+void
+XSLTEngineImpl::cdata(
const XMLCh* const ch,
const unsigned int start,
const unsigned int length)
{
assert(m_flistener != 0);
assert(ch != 0);
+
flushPending();
- Stylesheet::QNameVectorType cdataElems =
m_stylesheetRoot->getCdataSectionElems();
+
+ const Stylesheet::QNameVectorType& cdataElems =
+ m_stylesheetRoot->getCDATASectionElems();
+
if(0 != cdataElems.size() && 0 != m_cdataStack.size())
{
- // future: assert (m_flistener.getType == eFormatterListener)
- FormatterListener* pfl =
- static_cast<FormatterListener*>(m_flistener);
- pfl->cdata(ch, length);
- if(m_traceListeners.size() > 0)
+ m_flistener->cdata(ch, length);
+
+ if(getTraceListeners() > 0)
{
GenerateEvent ge(this, GenerateEvent::EVENTTYPE_CDATA,
ch, start,
length);
+
fireGenerateEvent(ge);
}
}
else
{
m_flistener->characters(ch, length);
- if(m_traceListeners.size() > 0)
+
+ if(getTraceListeners() > 0)
{
GenerateEvent ge(this,
GenerateEvent::EVENTTYPE_CHARACTERS, ch,
start, length);
+
fireGenerateEvent(ge);
}
}
@@ -2244,12 +2221,12 @@
bool
-XSLTEngineImpl::isCDataResultElem(const XalanDOMString&
elementName)
+XSLTEngineImpl::isCDataResultElem(const XalanDOMString&
elementName) const
{
typedef Stylesheet::QNameVectorType QNameVectorType;
bool is = false;
- const QNameVectorType& cdataElems =
m_stylesheetRoot->getCdataSectionElems();
+ const QNameVectorType& cdataElems =
m_stylesheetRoot->getCDATASectionElems();
const QNameVectorType::size_type theSize = cdataElems.size();
if(0 != theSize)
@@ -2298,10 +2275,11 @@
+// $$$ ToDo: This should not be here!!!!
bool
XSLTEngineImpl::qnameEqualsResultElemName(
const QName& qname,
- const XalanDOMString& elementName)
+ const XalanDOMString& elementName) const
{
XalanDOMString elemNS;
XalanDOMString elemLocalName;
@@ -3075,22 +3053,25 @@
XMLChVectorType buf(theStringData,
theStringData +
length(string));
- const int len = buf.size();
+ const unsigned int len = buf.size();
bool edit = false;
- int s;
- for(s = 0; s < len; s++)
+ unsigned int s;
+
+ for(s = 0; s < len; ++s)
{
if(isSpace(buf[s]) == true)
{
break;
}
}
+
/* replace S to ' '. and ' '+ -> single ' '. */
- int d = s;
+ unsigned int d = s;
bool pres = false;
- for ( ; s < len; s ++)
+ for ( ; s < len; ++s)
{
const XMLCh c = buf[s];
+
if (isSpace(c) == true)
{
if (!pres)
@@ -3150,7 +3131,7 @@
// OK, we have to calculate the length of the string,
// taking into account that we may have moved up the
// start because we're trimming the from of the string.
- const int theLength = d - (start - buf.begin());
+ const unsigned int theLength = d - (start - buf.begin());
return XalanDOMString(start, theLength);
}
}
1.32 +56 -147 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.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- XSLTEngineImpl.hpp 2000/05/18 18:38:41 1.31
+++ XSLTEngineImpl.hpp 2000/05/24 19:38:49 1.32
@@ -257,11 +257,17 @@
virtual void
process(
XSLTInputSource&
inputSource,
- XSLTInputSource*
stylesheetSource,
+ XSLTInputSource&
stylesheetSource,
XSLTResultTarget&
outputTarget,
StylesheetConstructionContext& constructionContext,
StylesheetExecutionContext& executionContext);
-
+
+ virtual void
+ process(
+ XSLTInputSource&
inputSource,
+ XSLTResultTarget&
outputTarget,
+ StylesheetExecutionContext& executionContext);
+
virtual StylesheetRoot*
processStylesheet(
XSLTInputSource&
stylesheetSource,
@@ -354,26 +360,41 @@
virtual void
setFormatterListener(FormatterListener* flistener);
- virtual void addTraceListener(TraceListener* tl);
-
+ // Trace-related functions...
+
+ virtual unsigned long
+ getTraceListeners() const;
+
virtual void
- setTraceTemplates(bool b);
+ addTraceListener(TraceListener* tl);
- bool isTraceSelect() const;
+ virtual void
+ removeTraceListener(TraceListener* tl);
virtual void
- setTraceSelect(bool b);
-
+ fireGenerateEvent(const GenerateEvent& ge);
+
virtual void
- setTraceTemplateChildren(bool b);
+ fireTraceEvent(const TracerEvent& te);
virtual void
- setQuietConflictWarnings(bool b);
+ fireSelectEvent(const SelectionEvent& se);
+
+ virtual bool
+ getTraceSelects() const;
virtual void
- removeTraceListener(TraceListener* tl);
-
+ setTraceSelects(bool b);
+
virtual void
+ traceSelect(
+ const XalanElement& theTemplate,
+ const NodeRefListBase& nl) const;
+
+ virtual void
+ setQuietConflictWarnings(bool b);
+
+ virtual void
setDiagnosticsOutput(PrintWriter* pw);
@@ -592,52 +613,11 @@
outputResultTreeFragment(const XObject& theTree);
/**
- * Determine if an external function is available.
- *
- * @param theNamespace namespace for function
- * @param extensionName name of extension function
- * @return whether the given function is available or not
- */
- bool
- functionAvailable(
- XalanDOMString& theNamespace,
- XalanDOMString& extensionName) const;
-
- /**
- * Handle an extension function.
- *
- * @param executionContext current execution context
- * @param theNamespace namespace of function
- * @param extensionName extension function name
- * @param argVec vector of arguments to function
- * @return pointer to XObject result
- */
- virtual XObject*
- extFunction(
- XPathExecutionContext&
executionContext,
- const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName,
- XalanNode*
context,
- const XObjectArgVectorType& argVec) const;
-
- // This is public for class Stylesheet...
- /**
- * In response to xsl:function, set up a function that can be called
from
- * the expression language.
- *
- * NOTE: this method is not yet supported
- *
- * @param extensionElem extension element
- */
- void
- handleFunctionsInstruction(XalanElement& extensionElem);
-
- /**
* Retrieve the root stylesheet.
*
* @return pointer to root stylesheet
*/
- virtual StylesheetRoot*
+ virtual const StylesheetRoot*
getStylesheetRoot() const;
/**
@@ -646,7 +626,7 @@
* @param theStylesheet pointer to new root stylesheet
*/
virtual void
- setStylesheetRoot(StylesheetRoot* theStylesheet);
+ setStylesheetRoot(const StylesheetRoot* theStylesheet);
/**
* Set the execution context.
@@ -766,19 +746,6 @@
const XalanNode& node,
int tagType) const;
- /**
- * Add list of trace listeners to the root sylesheet for the purposes of
- * debugging and diagnosis.
- */
- void addTraceListenersToStylesheet();
-
- /**
- * Fire a generate event.
- *
- * @param te generate event to fire
- */
- void fireGenerateEvent(const GenerateEvent& te);
-
/**
* Whether to warn about pattern match conflicts.
*
@@ -876,23 +843,14 @@
const XalanDOMString& s) const;
/**
- * Compose a diagnostic trace of the current selection
- *
- * @param theTemplate current context node
- * @param nl list of selected nodes
- */
- void traceSelect(
- const XalanElement& theTemplate,
- const NodeRefListBase& nl) const;
-
- /**
* Tell if a given element name should output it's text
* as cdata.
*
* @param elementName name of element
* @return true if it should output as cdata
*/
- bool isCDataResultElem(const XalanDOMString& elementName);
+ bool
+ isCDataResultElem(const XalanDOMString& elementName) const;
/**
* Tell if a qualified name equals the current result tree name.
@@ -901,7 +859,10 @@
* @param elementName current result tree element
* @return true if names are the same
*/
- bool qnameEqualsResultElemName(const QName& qname, const
XalanDOMString& elementName);
+ bool
+ qnameEqualsResultElemName(
+ const QName& qname,
+ const XalanDOMString& elementName) const;
/**
* Retrieve the result namespace corresponding to a prefix.
@@ -910,8 +871,7 @@
* @return string for namespace URI
*/
XalanDOMString
- getResultNamespaceForPrefix(
- const XalanDOMString& prefix) const;
+ getResultNamespaceForPrefix(const XalanDOMString& prefix) const;
/**
* Retrieve the result prefix corresponding to a namespace.
@@ -920,8 +880,7 @@
* @return string for namespace prefix
*/
XalanDOMString
- getResultPrefixForNamespace(
- const XalanDOMString& theNamespace) const;
+ getResultPrefixForNamespace(const XalanDOMString& theNamespace)
const;
/**
* Evaluate an xpath string and return the result as a numberic score.
@@ -969,7 +928,7 @@
*/
XObject*
evalXPathStr(
- const XalanDOMString& str,
+ const XalanDOMString& str,
XPathExecutionContext& executionContext);
/**
@@ -1226,32 +1185,6 @@
getNormalizedText(const XalanText& tx) const;
/**
- * Set the stylesheet root. If this is set, then the process calls that
- * take only the input .xml will use this instead of looking for a
- * stylesheet PI.
- *
- * @param theStylesheet pointer to root stylesheet
- */
- void
- setStylesheet(StylesheetRoot *stylesheetRoot)
- {
- m_stylesheetRoot = stylesheetRoot;
- }
-
- /**
- * Get the stylesheet root. If this is set, then the process calls that
- * take only the input .xml will use this instead of looking for a
- * stylesheet PI.
- *
- * @return pointer to root stylesheet
- */
- StylesheetRoot*
- getStylesheet() const
- {
- return m_stylesheetRoot;
- }
-
- /**
* Get the filename of the output document, if it was set. This is for
use
* by multiple output documents, to determine the base directory for the
* output document. It needs to be set by the caller.
@@ -1915,6 +1848,12 @@
*/
AttributeListImpl m_pendingAttributes;
+ /*
+ * true if a startDocument() event has been fired, but we
+ * haven't yet calld startDocument() on our formatter.
+ */
+ bool m_hasPendingStartDocument;
+
/**
* NOTE: This replaces the ResultNameSpace class in java, since it is
the
* same as the NameSpace class
@@ -1978,27 +1917,10 @@
*/
ProblemListener* m_problemListener;
- /**
- * Print a trace of a template that is being called, either by
- * a match, name, or as part of for-each.
- */
- void
- traceTemplate(
- const XalanElement& theTemplate) const;
-
- /**
- * Print some diagnostics about the current
- * template child.
- */
- void
- diagnoseTemplateChildren(
- const XalanNode& templateChild,
- const XalanNode& sourceNode) const;
-
/**
* The root of a linked set of stylesheets.
*/
- StylesheetRoot* m_stylesheetRoot;
+ const StylesheetRoot* m_stylesheetRoot;
/**
* The namespace that we must match as a minimum for XSLT.
@@ -2049,28 +1971,15 @@
*/
/**
+ * If this is set to true, selects will be traced
+ */
+ bool m_traceSelects;
+
+ /**
* If this is set to true, do not warn about pattern
* match conflicts.
*/
bool m_quietConflictWarnings;
-
- /*
- * If this is true, then the diag function will
- * be called.
- */
- bool m_traceTemplateChildren;
-
- /*
- * If this is true, then the simple tracing of templates
- * will be performed.
- */
- bool m_traceTemplates;
-
- /*
- * If this is true, then diagnostics of each select
- * will be performed.
- */
- bool m_traceSelects;
/*
* A stream to print diagnostics to.
1.10 +77 -42 xml-xalan/c/src/XSLT/XSLTProcessor.hpp
Index: XSLTProcessor.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTProcessor.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XSLTProcessor.hpp 2000/05/18 18:38:42 1.9
+++ XSLTProcessor.hpp 2000/05/24 19:38:50 1.10
@@ -77,6 +77,7 @@
class ElemTemplateElement;
class Formatter;
class FormatterListener;
+class GenerateEvent;
class InputSource;
class Locator;
class NodeRefListBase;
@@ -86,12 +87,14 @@
class QName;
class ResultTreeFrag;
class ResultTreeFragBase;
+class SelectionEvent;
class StackEntry;
class Stylesheet;
class StylesheetConstructionContext;
class StylesheetExecutionContext;
class StylesheetRoot;
class TraceListener;
+class TracerEvent;
class XalanDocument;
class XalanElement;
class XalanNode;
@@ -127,10 +130,11 @@
/**
* Transform the source tree to the output in the given result tree
target.
+ * The processor will process the input source, the stylesheet source,
+ * and transform to the output target.
*
- * @param inputSource input source, may be null
- * @param stylesheetSource stylesheet source, may be null if
source
- * has a
xml-stylesheet PI
+ * @param inputSource input source
+ * @param stylesheetSource stylesheet source
* @param outputTarget output source tree
* @param constructionContext context for construction of objects
* @param executionContext current execution context
@@ -139,14 +143,31 @@
virtual void
process(
XSLTInputSource& inputSource,
- XSLTInputSource*
stylesheetSource,
+ XSLTInputSource&
stylesheetSource,
XSLTResultTarget& outputTarget,
StylesheetConstructionContext& constructionContext,
StylesheetExecutionContext& executionContext) = 0;
/**
+ * Transform the source tree to the output in the given result tree
target.
+ * This function does not create a stylesheet tree, it assumes the
+ * provided StylesheetExecutionContext has the stylesheet tree to use.
This
+ * is set by calling StylesheetExecutionContext::setStylesheetRoot().
+ *
+ * @param inputSource input source
+ * @param outputTarget output source tree
+ * @param executionContext current execution context
+ * @exception XSLProcessorException
+ */
+ virtual void
+ process(
+ XSLTInputSource&
inputSource,
+ XSLTResultTarget&
outputTarget,
+ StylesheetExecutionContext& executionContext) = 0;
+
+ /**
* Given a stylesheet input source, compile the stylesheet into an
internal
- * representation. This will delete any existing stylesheet root.
+ * representation.
*
* @param stylesheetSource input source for the stylesheet
* @param constructionContext context for construction of objects
@@ -160,7 +181,7 @@
/**
* Given a URI to an XSL stylesheet, compile the stylesheet into an
internal
- * representation. This will delete any existing stylesheet root.
+ * representation.
*
* @param xmldocURLString URI to the input XML document
* @param constructionContext context for construction of objects
@@ -247,7 +268,7 @@
*
* @return pointer to root stylesheet
*/
- virtual StylesheetRoot*
+ virtual const StylesheetRoot*
getStylesheetRoot() const = 0;
/**
@@ -256,7 +277,7 @@
* @param theStylesheet pointer to new root stylesheet
*/
virtual void
- setStylesheetRoot(StylesheetRoot* theStylesheet) = 0;
+ setStylesheetRoot(const StylesheetRoot* theStylesheet) = 0;
/**
* Set the execution context. Must be set if after calling
@@ -436,42 +457,73 @@
*/
virtual void
setFormatterListener(FormatterListener* flistener) = 0;
-
+
/**
+ * Determine the number of trace listeners.
+ *
+ * @return number of listeners
+ */
+ virtual unsigned long
+ getTraceListeners() const = 0;
+
+ /**
* Add a trace listener for the purposes of debugging and diagnosis.
*
* @param tl pointer to listener to add
*/
virtual void
addTraceListener(TraceListener* tl) = 0;
-
+
/**
- * If this is set to true, simple traces of template calls are made.
+ * Remove a trace listener.
*
- * @param b true to make traces of template calls
+ * @param tl Trace listener to be removed.
*/
virtual void
- setTraceTemplates(bool b) = 0;
+ removeTraceListener(TraceListener* tl) = 0;
/**
- * If this is set to true, simple traces of select calls are made.
- *
- * @param b true to make traces of select calls
+ * Fire a generate event.
+ *
+ * @param ge generate event to fire
*/
virtual void
- setTraceSelect(bool b) = 0;
-
+ fireGenerateEvent(const GenerateEvent& ge) = 0;
+
/**
- * If this is set to true, debug diagnostics about
- * template children as they are being constructed
- * will be written to the m_diagnosticsPrintWriter
- * stream. diagnoseTemplateChildren is false by
- * default.
+ * Fire a trace event.
+ *
+ * @param te trace event to fire
+ */
+ virtual void
+ fireTraceEvent(const TracerEvent& te) = 0;
+
+ /**
+ * Fire a selection event.
+ *
+ * @param se selection event to fire
+ */
+ virtual void
+ fireSelectEvent(const SelectionEvent& se) = 0;
+
+ /**
+ * If this is set to true, simple traces of template calls are made.
+ *
+ * @return true if traces made
+ */
+ virtual bool
+ getTraceSelects() const = 0;
+
+ /**
+ * Compose a diagnostic trace of the current selection
*
- * @param b true to make traces of template children construction
+ * @param theTemplate current context node
+ * @param nl list of selected nodes
*/
virtual void
- setTraceTemplateChildren(bool b) = 0;
+ traceSelect(
+ const XalanElement& theTemplate,
+ const NodeRefListBase& nl) const = 0;
/**
* If the quietConflictWarnings property is set to
@@ -484,23 +536,6 @@
virtual void
setQuietConflictWarnings(bool b) = 0;
- /**
- * Remove a trace listener.
- *
- * @param tl Trace listener to be removed.
- */
- virtual void
- removeTraceListener(TraceListener* tl) = 0;
-
-// @@TODO: what to do about output stream ??
- /*
- * If this is set, diagnostics will be
- * written to the m_diagnosticsPrintWriter stream. If
- * the value is null, then diagnostics will be turned
- * off.
- */
-// virtual void setDiagnosticsOutput(java.io.OutputStream out) = 0;
-
/**
* If this is set, diagnostics will be
* written to the m_diagnosticsPrintWriter stream. If
1.5 +3 -3 xml-xalan/c/src/XSLT/XSLTProcessorEnvSupport.hpp
Index: XSLTProcessorEnvSupport.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTProcessorEnvSupport.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XSLTProcessorEnvSupport.hpp 2000/05/15 15:56:00 1.4
+++ XSLTProcessorEnvSupport.hpp 2000/05/24 19:38:50 1.5
@@ -133,18 +133,18 @@
virtual bool
elementAvailable(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName) const = 0;
+ const XalanDOMString& elementName) const = 0;
virtual bool
functionAvailable(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName) const = 0;
+ const XalanDOMString& functionName) const = 0;
virtual XObject*
extFunction(
XPathExecutionContext&
executionContext,
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName,
+ const XalanDOMString& functionName,
XalanNode*
context,
const XObjectArgVectorType& argVec) const =
0;
1.12 +14 -14 xml-xalan/c/src/XSLT/XSLTProcessorEnvSupportDefault.cpp
Index: XSLTProcessorEnvSupportDefault.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTProcessorEnvSupportDefault.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- XSLTProcessorEnvSupportDefault.cpp 2000/05/15 15:56:00 1.11
+++ XSLTProcessorEnvSupportDefault.cpp 2000/05/24 19:38:50 1.12
@@ -111,10 +111,10 @@
void
XSLTProcessorEnvSupportDefault::installExternalFunctionGlobal(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName,
+ const XalanDOMString& functionName,
const Function& function)
{
- XPathEnvSupportDefault::installExternalFunctionGlobal(theNamespace,
extensionName, function);
+ XPathEnvSupportDefault::installExternalFunctionGlobal(theNamespace,
functionName, function);
}
@@ -122,9 +122,9 @@
void
XSLTProcessorEnvSupportDefault::uninstallExternalFunctionGlobal(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName)
+ const XalanDOMString& functionName)
{
- XPathEnvSupportDefault::uninstallExternalFunctionGlobal(theNamespace,
extensionName);
+ XPathEnvSupportDefault::uninstallExternalFunctionGlobal(theNamespace,
functionName);
}
@@ -132,10 +132,10 @@
void
XSLTProcessorEnvSupportDefault::installExternalFunctionLocal(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName,
+ const XalanDOMString& functionName,
const Function& function)
{
- m_defaultSupport.installExternalFunctionLocal(theNamespace,
extensionName, function);
+ m_defaultSupport.installExternalFunctionLocal(theNamespace,
functionName, function);
}
@@ -143,9 +143,9 @@
void
XSLTProcessorEnvSupportDefault::uninstallExternalFunctionLocal(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName)
+ const XalanDOMString& functionName)
{
- m_defaultSupport.uninstallExternalFunctionLocal(theNamespace,
extensionName);
+ m_defaultSupport.uninstallExternalFunctionLocal(theNamespace,
functionName);
}
@@ -347,10 +347,10 @@
bool
XSLTProcessorEnvSupportDefault::elementAvailable(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName) const
+ const XalanDOMString& functionName) const
{
return m_defaultSupport.elementAvailable(theNamespace,
-
extensionName);
+
functionName);
}
@@ -358,10 +358,10 @@
bool
XSLTProcessorEnvSupportDefault::functionAvailable(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName) const
+ const XalanDOMString& functionName) const
{
return m_defaultSupport.functionAvailable(theNamespace,
-
extensionName);
+
functionName);
}
@@ -370,13 +370,13 @@
XSLTProcessorEnvSupportDefault::extFunction(
XPathExecutionContext&
executionContext,
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName,
+ const XalanDOMString& functionName,
XalanNode*
context,
const XObjectArgVectorType& argVec) const
{
return m_defaultSupport.extFunction(executionContext,
theNamespace,
-
extensionName,
+
functionName,
context,
argVec);
}
1.10 +11 -11 xml-xalan/c/src/XSLT/XSLTProcessorEnvSupportDefault.hpp
Index: XSLTProcessorEnvSupportDefault.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTProcessorEnvSupportDefault.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XSLTProcessorEnvSupportDefault.hpp 2000/05/15 15:56:00 1.9
+++ XSLTProcessorEnvSupportDefault.hpp 2000/05/24 19:38:50 1.10
@@ -110,25 +110,25 @@
* Install an external function in the global space.
*
* @param theNamespace The namespace for the functionl
- * @param extensionName The name of the function.
+ * @param functionName The name of the function.
* @param function The function to install.
*/
static void
installExternalFunctionGlobal(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName,
+ const XalanDOMString& functionName,
const Function& function);
/**
* Uninstall an external function from the global space.
*
* @param theNamespace The namespace for the functionl
- * @param extensionName The name of the function.
+ * @param functionName The name of the function.
*/
static void
uninstallExternalFunctionGlobal(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName);
+ const XalanDOMString& functionName);
// Interfaces to install and uninstall external functions in this
instance.
@@ -136,25 +136,25 @@
* Install an external function in the local space.
*
* @param theNamespace The namespace for the functionl
- * @param extensionName The name of the function.
+ * @param functionName The name of the function.
* @param function The function to install.
*/
virtual void
installExternalFunctionLocal(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName,
+ const XalanDOMString& functionName,
const Function& function);
/**
* Uninstall an external function from the local space.
*
* @param theNamespace The namespace for the functionl
- * @param extensionName The name of the function.
+ * @param functionName The name of the function.
*/
virtual void
uninstallExternalFunctionLocal(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName);
+ const XalanDOMString& functionName);
// These interfaces are inherited from XSLTProcessorEnvSupport...
@@ -204,18 +204,18 @@
virtual bool
elementAvailable(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName) const;
+ const XalanDOMString& elementName) const;
virtual bool
functionAvailable(
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName) const;
+ const XalanDOMString& functionName) const;
virtual XObject*
extFunction(
XPathExecutionContext&
executionContext,
const XalanDOMString& theNamespace,
- const XalanDOMString& extensionName,
+ const XalanDOMString& functionName,
XalanNode*
context,
const XObjectArgVectorType& argVec) const;
1.2 +0 -3 xml-xalan/c/src/XSLT/XSLTProcessorException.cpp
Index: XSLTProcessorException.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTProcessorException.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSLTProcessorException.cpp 1999/12/18 19:48:05 1.1
+++ XSLTProcessorException.cpp 2000/05/24 19:38:50 1.2
@@ -75,6 +75,3 @@
XSLTProcessorException::~XSLTProcessorException()
{
}
-
-
-