You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@locus.apache.org on 2000/05/30 00:47:56 UTC
cvs commit: xml-xalan/c/src/XSLT StylesheetConstructionContext.hpp StylesheetConstructionContextDefault.cpp StylesheetConstructionContextDefault.hpp StylesheetHandler.cpp StylesheetHandler.hpp
dbertoni 00/05/29 15:47:56
Modified: c/src/XSLT StylesheetConstructionContext.hpp
StylesheetConstructionContextDefault.cpp
StylesheetConstructionContextDefault.hpp
StylesheetHandler.cpp StylesheetHandler.hpp
Log:
Removed dependency on XSLTEngineImpl.
Revision Changes Path
1.7 +71 -0 xml-xalan/c/src/XSLT/StylesheetConstructionContext.hpp
Index: StylesheetConstructionContext.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetConstructionContext.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- StylesheetConstructionContext.hpp 2000/05/12 18:21:32 1.6
+++ StylesheetConstructionContext.hpp 2000/05/29 22:47:55 1.7
@@ -79,9 +79,13 @@
+class DocumentHandler;
+class Locator;
class PrefixResolver;
class StylesheetRoot;
+class XalanDocument;
class XPath;
+class XMLURL;
class XSLTInputSource;
@@ -210,6 +214,73 @@
createXPath(
const XalanDOMString& str,
const PrefixResolver& resolver) = 0;
+
+ /**
+ * Get the locator from the top of the locator stack.
+ *
+ * @return A pointer to the Locator, or 0 if there is nothing on the stack.
+ */
+ virtual const Locator*
+ getLocatorFromStack() const = 0;
+
+ /**
+ * Push a locator on to the locator stack.
+ *
+ * @param A pointer to the Locator to push.
+ */
+ virtual void
+ pushLocatorOnStack(const Locator* locator) = 0;
+
+ /**
+ * Pop the locator from the top of the locator stack.
+ */
+ virtual void
+ popLocatorStack() = 0;
+
+ /**
+ * Get the Xalan namespace for built-in extensions.
+ *
+ * @return Xalan namespace for extensions
+ */
+ virtual const XalanDOMString&
+ getXalanXSLNameSpaceURL() const = 0;
+
+ /**
+ * Read in the XML file, either producing a Document or calling SAX events,
+ * and register the document in a table. If the document has already been
+ * read in, it will not be reparsed.
+ *
+ * @param url location of the XML
+ * @param docHandler pointer to SAX event handler
+ * @param docToRegister if using a SAX event handler, the object to register in the source docs table.
+ * @return document object, which represents the parsed XML
+ * @exception SAXException
+ */
+ virtual XalanDocument*
+ parseXML(
+ const XMLURL& url,
+ DocumentHandler* docHandler,
+ XalanDocument* docToRegister) = 0;
+
+ /**
+ * Given an XSL tag name, return an integer token that corresponds to
+ * ELEMNAME_XXX constants defined in Constants.hpp
+ *
+ * @param name a probable xsl:xxx element
+ * @return Constants.ELEMNAME_XXX token, -1 if in XSL or Xalan namespace,
+ * or -2 if not in known namespace
+ */
+ virtual int
+ getElementToken(const XalanDOMString& name) const = 0;
+
+ /**
+ * Get the latest XSLT version currently supported.
+ *
+ * @return XSLT version number
+ */
+ virtual double
+ getXSLTVersionSupported() const = 0;
+
// These interfaces are inherited from ExecutionContext...
1.6 +61 -0 xml-xalan/c/src/XSLT/StylesheetConstructionContextDefault.cpp
Index: StylesheetConstructionContextDefault.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetConstructionContextDefault.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StylesheetConstructionContextDefault.cpp 2000/05/12 18:21:32 1.5
+++ StylesheetConstructionContextDefault.cpp 2000/05/29 22:47:55 1.6
@@ -150,6 +150,8 @@
for_each(m_stylesheets.begin(),
m_stylesheets.end(),
DeleteFunctor<StylesheetRoot>());
+
+ m_stylesheets.clear();
}
@@ -265,3 +267,62 @@
return xpath;
}
+
+
+
+const Locator*
+StylesheetConstructionContextDefault::getLocatorFromStack() const
+{
+ return m_processor.getLocatorFromStack();
+}
+
+
+
+void
+StylesheetConstructionContextDefault::pushLocatorOnStack(const Locator* locator)
+{
+ m_processor.pushLocatorOnStack(locator);
+}
+
+
+
+void
+StylesheetConstructionContextDefault::popLocatorStack()
+{
+ m_processor.popLocatorStack();
+}
+
+
+
+const XalanDOMString&
+StylesheetConstructionContextDefault::getXalanXSLNameSpaceURL() const
+{
+ return XSLTEngineImpl::getXalanXSLNameSpaceURL();
+}
+
+
+
+XalanDocument*
+StylesheetConstructionContextDefault::parseXML(
+ const XMLURL& url,
+ DocumentHandler* docHandler,
+ XalanDocument* docToRegister)
+{
+ return m_processor.parseXML(url, docHandler, docToRegister);
+}
+
+
+
+int
+StylesheetConstructionContextDefault::getElementToken(const XalanDOMString& name) const
+{
+ return m_processor.getElementToken(name);
+}
+
+
+
+double
+StylesheetConstructionContextDefault::getXSLTVersionSupported() const
+{
+ return XSLTEngineImpl::getXSLTVerSupported();
+}
\ No newline at end of file
1.7 +25 -0 xml-xalan/c/src/XSLT/StylesheetConstructionContextDefault.hpp
Index: StylesheetConstructionContextDefault.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetConstructionContextDefault.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- StylesheetConstructionContextDefault.hpp 2000/05/12 18:21:33 1.6
+++ StylesheetConstructionContextDefault.hpp 2000/05/29 22:47:55 1.7
@@ -73,6 +73,7 @@
#include <memory>
#include <set>
+#include <vector>
@@ -160,6 +161,30 @@
createXPath(
const XalanDOMString& str,
const PrefixResolver& resolver);
+
+ virtual const Locator*
+ getLocatorFromStack() const;
+
+ virtual void
+ pushLocatorOnStack(const Locator* locator);
+
+ virtual void
+ popLocatorStack();
+
+ virtual const XalanDOMString&
+ getXalanXSLNameSpaceURL() const;
+
+ virtual XalanDocument*
+ parseXML(
+ const XMLURL& url,
+ DocumentHandler* docHandler,
+ XalanDocument* docToRegister);
+
+ virtual int
+ getElementToken(const XalanDOMString& name) const;
+
+ virtual double
+ getXSLTVersionSupported() const;
private:
1.29 +24 -27 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.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- StylesheetHandler.cpp 2000/05/26 19:23:02 1.28
+++ StylesheetHandler.cpp 2000/05/29 22:47:55 1.29
@@ -70,6 +70,7 @@
+#include <PlatformSupport/AttributeListImpl.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/StringTokenizer.hpp>
@@ -110,19 +111,16 @@
#include "Stylesheet.hpp"
#include "StylesheetConstructionContext.hpp"
#include "StylesheetRoot.hpp"
-#include "XSLTEngineImpl.hpp"
StylesheetHandler::StylesheetHandler(
- XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
StylesheetConstructionContext& constructionContext) :
FormatterListener(OUTPUT_METHOD_OTHER),
m_includeBase(stylesheetTree.getBaseIdentifier()),
m_pendingException(),
m_exceptionPending(false),
- m_processor(processor),
m_stylesheet(stylesheetTree),
m_constructionContext(constructionContext),
m_elemStack(),
@@ -169,7 +167,7 @@
void StylesheetHandler::setDocumentLocator(const Locator* const locator)
{
- m_processor.pushLocatorOnStack(locator);
+ m_constructionContext.pushLocatorOnStack(locator);
}
@@ -183,7 +181,7 @@
void StylesheetHandler::endDocument()
{
- m_processor.popLocatorStack();
+ m_constructionContext.popLocatorStack();
if (m_exceptionPending == true)
{
@@ -254,7 +252,7 @@
m_whiteSpaceElems.clear();
- const Locator* const locator = m_processor.getLocatorFromStack();
+ const Locator* const locator = m_constructionContext.getLocatorFromStack();
const int lineNumber = 0 != locator ? locator->getLineNumber() : 0;
const int columnNumber = 0 != locator ? locator->getColumnNumber() : 0;
@@ -290,11 +288,8 @@
m_stylesheet.setWrapperless(false);
}
- XSLTEngineImpl::AttributeKeysMapType::const_iterator iter=
- XSLTEngineImpl::getElementKeys().find(localName);
+ const int xslToken = m_constructionContext.getElementToken(localName);
- int xslToken = iter!= XSLTEngineImpl::getElementKeys().end() ? (*iter).second : -2;
-
if(!m_inTemplate)
{
if(m_foundStylesheet && Constants::ELEMNAME_IMPORT != xslToken)
@@ -314,9 +309,9 @@
break;
case Constants::ELEMNAME_EXTENSION:
- if(!equalsIgnoreCase(ns, m_processor.getXalanXSLNameSpaceURL()))
+ if(!equalsIgnoreCase(ns, m_constructionContext.getXalanXSLNameSpaceURL()))
{
- m_constructionContext.warn("Old syntax: the functions instruction should use a url of " + m_processor.getXalanXSLNameSpaceURL());
+ m_constructionContext.warn("Old syntax: the functions instruction should use a url of " + m_constructionContext.getXalanXSLNameSpaceURL());
}
// m_constructionContext.handleFunctionsInstruction((Element)child);
break;
@@ -342,7 +337,7 @@
break;
case Constants::ELEMNAME_LOCALE:
- m_processor.warn(XALAN_STATIC_UCODE_STRING("xsl:locale not yet supported!"));
+ m_constructionContext.warn(XALAN_STATIC_UCODE_STRING("xsl:locale not yet supported!"));
break;
case Constants::ELEMNAME_PRESERVESPACE:
@@ -550,7 +545,7 @@
const XalanDOMString extns = m_stylesheet.getNamespaceForPrefixFromStack(prefix);
- ExtensionNSHandler* const nsh = new ExtensionNSHandler(m_processor, extns);
+ ExtensionNSHandler* const nsh = new ExtensionNSHandler(extns);
m_stylesheet.addExtensionNamespace(extns, nsh);
}
}
@@ -835,7 +830,7 @@
// If this stylesheet is declared to be of a higher version than the one
// supported, don't flag an error.
- if(XSLTEngineImpl::getXSLTVerSupported() < m_stylesheet.getXSLTVerDeclared())
+ if(m_constructionContext.getXSLTVersionSupported() < m_stylesheet.getXSLTVerDeclared())
{
m_constructionContext.warn(msg);
}
@@ -848,7 +843,7 @@
}
}
// BEGIN SANJIVA CODE
- else if (!m_inTemplate && startsWith(ns,m_processor.getXalanXSLNameSpaceURL()))
+ else if (!m_inTemplate && startsWith(ns, m_constructionContext.getXalanXSLNameSpaceURL()))
{
if (equals(localName, XALAN_STATIC_UCODE_STRING("component")))
{
@@ -894,7 +889,7 @@
if (nsh == 0)
{
// The extension namespace might not yet be known...
- nsh = new ExtensionNSHandler(m_processor, extns);
+ nsh = new ExtensionNSHandler(extns);
m_stylesheet.addExtensionNamespace(extns, nsh);
}
@@ -1004,8 +999,12 @@
m_elemStack.push_back(new ElemEmpty(m_constructionContext,
m_stylesheet,
name, lineNumber, columnNumber));
- }
+ if (elem != 0)
+ {
+ delete elem;
+ }
+ }
} // end try
// Here's the story. startElement throws exceptions for certain malformed constructs. These
@@ -1151,12 +1150,10 @@
theImportURI,
m_constructionContext);
- StylesheetHandler tp(m_processor, *pImportedStylesheet, m_constructionContext);
+ StylesheetHandler tp(*pImportedStylesheet, m_constructionContext);
-// pImportedStylesheet->setBaseIdentifier();
+ m_constructionContext.parseXML(*hrefUrl, &tp, pImportedStylesheet);
- m_processor.parseXML(*hrefUrl, &tp, pImportedStylesheet);
-
// I'm going to insert the elements in backwards order,
// so I can walk them 0 to n.
m_stylesheet.getImports().insert(m_stylesheet.getImports().begin(),
@@ -1196,7 +1193,7 @@
if(equals(aname, Constants::ATTRNAME_HREF))
{
foundIt = true;
-
+
PushPopIncludeState theStateHandler(*this);
const XalanDOMString href = atts.getValue(i);
@@ -1216,7 +1213,7 @@
m_stylesheet.getIncludeStack().push_back(hrefUrl.get());
hrefUrl.release();
- m_processor.parseXML(*hrefUrl, this, &m_stylesheet);
+ m_constructionContext.parseXML(*hrefUrl, this, &m_stylesheet);
m_stylesheet.getIncludeStack().pop_back();
}
@@ -1326,7 +1323,7 @@
preserveSpace = true;
}
- const Locator* const locator = m_processor.getLocatorFromStack();
+ const Locator* const locator = m_constructionContext.getLocatorFromStack();
const int lineNumber = (0 != locator) ? locator->getLineNumber() : 0;
const int columnNumber = (0 != locator) ? locator->getColumnNumber() : 0;
@@ -1413,7 +1410,7 @@
preserveSpace = true;
}
- const Locator* const locator = m_processor.getLocatorFromStack();
+ const Locator* const locator = m_constructionContext.getLocatorFromStack();
const int lineNumber = (0 != locator) ? locator->getLineNumber() : 0;
const int columnNumber = (0 != locator) ? locator->getColumnNumber() : 0;
@@ -1531,7 +1528,7 @@
void
StylesheetHandler::charactersRaw(const XMLCh* const /* chars */, const unsigned int /* length */)
{
- // if we have apending exception, we don't want to even try to process this
+ // if we have a pending exception, we don't want to even try to process this
if (m_exceptionPending == true)
return;
1.13 +0 -7 xml-xalan/c/src/XSLT/StylesheetHandler.hpp
Index: StylesheetHandler.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetHandler.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- StylesheetHandler.hpp 2000/04/20 16:47:35 1.12
+++ StylesheetHandler.hpp 2000/05/29 22:47:56 1.13
@@ -84,7 +84,6 @@
class ExtensionNSHandler;
class Stylesheet;
class StylesheetConstructionContext;
-class XSLTEngineImpl;
@@ -109,7 +108,6 @@
* to the document fragment.
*/
StylesheetHandler(
- XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
StylesheetConstructionContext& constructionContext);
@@ -402,11 +400,6 @@
typedef std::vector<ElemTextLiteral*> ElemTextLiteralStackType;
#endif
- /**
- * The XSLT Processor for needed services.
- */
- XSLTEngineImpl& m_processor;
-
/**
* The owning stylesheet.
*/