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...@apache.org on 2001/04/27 22:56:52 UTC
cvs commit: xml-xalan/c/src/XalanTransformer XalanDefaultDocumentBuilder.cpp XalanDefaultDocumentBuilder.hpp XalanDefaultParsedSource.cpp XalanDefaultParsedSource.hpp XalanDocumentBuilder.hpp XalanParsedSource.hpp XalanTransformer.cpp XalanTransformer.hpp XercesDOMParsedSource.cpp XercesDOMParsedSource.hpp
dbertoni 01/04/27 13:56:52
Modified: c/src/XalanTransformer XalanDefaultDocumentBuilder.cpp
XalanDefaultDocumentBuilder.hpp
XalanDefaultParsedSource.cpp
XalanDefaultParsedSource.hpp
XalanDocumentBuilder.hpp XalanParsedSource.hpp
XalanTransformer.cpp XalanTransformer.hpp
XercesDOMParsedSource.cpp XercesDOMParsedSource.hpp
Log:
Changes for new document builder.
Revision Changes Path
1.2 +1 -17 xml-xalan/c/src/XalanTransformer/XalanDefaultDocumentBuilder.cpp
Index: XalanDefaultDocumentBuilder.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanDefaultDocumentBuilder.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XalanDefaultDocumentBuilder.cpp 2001/04/18 20:02:53 1.1
+++ XalanDefaultDocumentBuilder.cpp 2001/04/27 20:56:51 1.2
@@ -80,21 +80,13 @@
XalanDocument*
-XalanDefaultDocumentBuilder::getDocument() const
+XalanDefaultDocumentBuilder::getDocument()
{
return m_contentHandler.getDocument();
}
-const XMLParserLiaison*
-XalanDefaultDocumentBuilder::getParserLiaison() const
-{
- return &m_parserLiaison;
-}
-
-
-
XMLParserLiaison*
XalanDefaultDocumentBuilder::getParserLiaison()
{
@@ -105,14 +97,6 @@
DOMSupport*
XalanDefaultDocumentBuilder::getDOMSupport()
-{
- return &m_domSupport;
-}
-
-
-
-const DOMSupport*
-XalanDefaultDocumentBuilder::getDOMSupport() const
{
return &m_domSupport;
}
1.2 +4 -10 xml-xalan/c/src/XalanTransformer/XalanDefaultDocumentBuilder.hpp
Index: XalanDefaultDocumentBuilder.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanDefaultDocumentBuilder.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XalanDefaultDocumentBuilder.hpp 2001/04/18 20:02:53 1.1
+++ XalanDefaultDocumentBuilder.hpp 2001/04/27 20:56:51 1.2
@@ -75,10 +75,10 @@
/**
- * This is abstract base class designed to allow a XalanTranfomer
- * object to use a document that is build dynamically by a user.
+ * This is class is designed to allow a XalanTranfomer object
+ * to use a document that is build dynamically by a user.
*/
-class XALAN_TRANSFORMER_EXPORT XalanDefaultDocumentBuilder
+class XALAN_TRANSFORMER_EXPORT XalanDefaultDocumentBuilder : public XalanDocumentBuilder
{
public:
@@ -88,19 +88,13 @@
~XalanDefaultDocumentBuilder();
virtual XalanDocument*
- getDocument() const;
+ getDocument();
- virtual const XMLParserLiaison*
- getParserLiaison() const;
-
virtual XMLParserLiaison*
getParserLiaison();
virtual DOMSupport*
getDOMSupport();
-
- virtual const DOMSupport*
- getDOMSupport() const;
virtual ContentHandler*
getContentHandler();
1.2 +2 -2 xml-xalan/c/src/XalanTransformer/XalanDefaultParsedSource.cpp
Index: XalanDefaultParsedSource.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanDefaultParsedSource.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XalanDefaultParsedSource.cpp 2001/03/30 21:35:44 1.1
+++ XalanDefaultParsedSource.cpp 2001/04/27 20:56:51 1.2
@@ -79,8 +79,8 @@
-XalanNode*
-XalanDefaultParsedSource::getParsedSource()
+XalanDocument*
+XalanDefaultParsedSource::getDocument()
{
return m_parsedSource;
}
1.2 +4 -4 xml-xalan/c/src/XalanTransformer/XalanDefaultParsedSource.hpp
Index: XalanDefaultParsedSource.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanDefaultParsedSource.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XalanDefaultParsedSource.hpp 2001/03/30 21:35:44 1.1
+++ XalanDefaultParsedSource.hpp 2001/04/27 20:56:51 1.2
@@ -84,14 +84,14 @@
class XALAN_TRANSFORMER_EXPORT XalanDefaultParsedSource : public XalanParsedSource
{
public:
-
+
XalanDefaultParsedSource(const XSLTInputSource& theInputSource);
virtual
~XalanDefaultParsedSource();
- virtual XalanNode*
- getParsedSource();
+ virtual XalanDocument*
+ getDocument();
virtual XMLParserLiaison*
getParserLiaison();
@@ -105,7 +105,7 @@
XalanSourceTreeParserLiaison m_parserLiaison;
- XalanNode* const m_parsedSource;
+ XalanDocument* const m_parsedSource;
};
1.3 +9 -8 xml-xalan/c/src/XalanTransformer/XalanDocumentBuilder.hpp
Index: XalanDocumentBuilder.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanDocumentBuilder.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XalanDocumentBuilder.hpp 2001/04/18 21:31:51 1.2
+++ XalanDocumentBuilder.hpp 2001/04/27 20:56:51 1.3
@@ -64,6 +64,11 @@
+// Base class include file.
+#include <XalanTransformer/XalanParsedSource.hpp>
+
+
+
class ContentHandler;
class DOMSupport;
class DTDHandler;
@@ -77,7 +82,7 @@
* This is abstract base class designed to allow a XalanTranfomer
* object to use a document that is build dynamically by a user.
*/
-class XALAN_TRANSFORMER_EXPORT XalanDocumentBuilder
+class XALAN_TRANSFORMER_EXPORT XalanDocumentBuilder : public XalanParsedSource
{
public:
@@ -86,21 +91,17 @@
{
}
+ // These are inherited from XalanParsedSource...
virtual XalanDocument*
- getDocument() const = 0;
+ getDocument() = 0;
- virtual const XMLParserLiaison*
- getParserLiaison() const = 0;
-
virtual XMLParserLiaison*
getParserLiaison() = 0;
virtual DOMSupport*
getDOMSupport() = 0;
-
- virtual const DOMSupport*
- getDOMSupport() const = 0;
+ // These are new to XalanDocumentBuilder...
virtual ContentHandler*
getContentHandler() = 0;
1.2 +9 -4 xml-xalan/c/src/XalanTransformer/XalanParsedSource.hpp
Index: XalanParsedSource.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanParsedSource.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XalanParsedSource.hpp 2001/03/30 21:35:44 1.1
+++ XalanParsedSource.hpp 2001/04/27 20:56:51 1.2
@@ -64,8 +64,13 @@
+// We're bringing in XalanDocument so that its derivation from XalanNode
+// is known...
+#include <XalanDOM/XalanDocument.hpp>
+
+
+
class DOMSupport;
-class XalanNode;
class XMLParserLiaison;
@@ -77,14 +82,14 @@
class XALAN_TRANSFORMER_EXPORT XalanParsedSource
{
public:
-
+
XalanParsedSource();
virtual
~XalanParsedSource();
- virtual XalanNode*
- getParsedSource() = 0;
+ virtual XalanDocument*
+ getDocument() = 0;
virtual XMLParserLiaison*
getParserLiaison() = 0;
1.16 +98 -3 xml-xalan/c/src/XalanTransformer/XalanTransformer.cpp
Index: XalanTransformer.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanTransformer.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- XalanTransformer.cpp 2001/04/20 13:48:09 1.15
+++ XalanTransformer.cpp 2001/04/27 20:56:51 1.16
@@ -75,6 +75,34 @@
+#include <PlatformSupport/DOMStringHelper.hpp>
+
+
+
+#include <XPath/XObjectFactoryDefault.hpp>
+#include <XPath/XPathFactoryBlock.hpp>
+#include <XPath/XPathFactoryDefault.hpp>
+
+
+
+#include <XSLT/StylesheetRoot.hpp>
+#include <XSLT/XSLTEngineImpl.hpp>
+#include <XSLT/XSLTInit.hpp>
+#include <XSLT/XSLTProcessorEnvSupportDefault.hpp>
+
+
+
+#include <XalanSourceTree/XalanSourceTreeDOMSupport.hpp>
+#include <XalanSourceTree/XalanSourceTreeParserLiaison.hpp>
+
+
+
+#include "XalanDefaultDocumentBuilder.hpp"
+#include "XalanDefaultParsedSource.hpp"
+#include "XercesDOMParsedSource.hpp"
+
+
+
XSLTInit* XalanTransformer::m_xsltInit = 0;
@@ -225,7 +253,7 @@
// Do the transformation...
theProcessor.process(
- theParsedXML.getParsedSource(),
+ theParsedXML.getDocument(),
theStylesheetSource,
tempResultTarget,
theStylesheetConstructionContext,
@@ -387,7 +415,7 @@
// Do the transformation...
theProcessor.process(
- theParsedXML.getParsedSource(),
+ theParsedXML.getDocument(),
tempResultTarget,
m_stylesheetExecutionContext);
}
@@ -692,6 +720,29 @@
+void
+XalanTransformer::destroyStylesheet(XalanCompiledStylesheet* theStylesheet)
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::find;
+#endif
+
+ const CompiledStylesheetPtrVectorType::iterator i =
+ find(
+ m_compiledStylesheets.begin(),
+ m_compiledStylesheets.end(),
+ theStylesheet);
+
+ if (i != m_compiledStylesheets.end())
+ {
+ m_compiledStylesheets.erase(i);
+
+ delete theStylesheet;
+ }
+}
+
+
+
XalanParsedSource*
XalanTransformer::parseSource(
const XSLTInputSource& theInputSource,
@@ -781,6 +832,29 @@
void
+XalanTransformer::destroyParsedSource(XalanParsedSource* theParsedSource)
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::find;
+#endif
+
+ const ParsedSourcePtrVectorType::iterator i =
+ find(
+ m_parsedSources.begin(),
+ m_parsedSources.end(),
+ theParsedSource);
+
+ if (i != m_parsedSources.end())
+ {
+ m_parsedSources.erase(i);
+
+ delete theParsedSource;
+ }
+}
+
+
+
+void
XalanTransformer::setStylesheetParam(
const XalanDOMString& key,
const XalanDOMString& expression)
@@ -804,7 +878,29 @@
+XalanDocumentBuilder*
+XalanTransformer::createDocumentBuilder()
+{
+ m_parsedSources.reserve(m_parsedSources.size() + 1);
+
+ XalanDocumentBuilder* const theNewBuilder = new XalanDefaultDocumentBuilder;
+
+ m_parsedSources.push_back(theNewBuilder);
+
+ return theNewBuilder;
+}
+
+
+
void
+XalanTransformer::destroyDocumentBuilder(XalanDocumentBuilder* theDocumentBuilder)
+{
+ destroyParsedSource(theDocumentBuilder);
+}
+
+
+
+void
XalanTransformer::installExternalFunction(
const XalanDOMString& theNamespace,
const XalanDOMString& functionName,
@@ -884,4 +980,3 @@
{
}
}
-
1.19 +87 -34 xml-xalan/c/src/XalanTransformer/XalanTransformer.hpp
Index: XalanTransformer.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanTransformer.hpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- XalanTransformer.hpp 2001/04/20 13:48:09 1.18
+++ XalanTransformer.hpp 2001/04/27 20:56:51 1.19
@@ -68,37 +68,15 @@
-#include <PlatformSupport/DOMStringHelper.hpp>
-
-
-
-#include <XPath/QNameByValue.hpp>
-#include <XPath/XObjectFactoryDefault.hpp>
-#include <XPath/XPathFactoryBlock.hpp>
-#include <XPath/XPathFactoryDefault.hpp>
-
-
-
#include <XSLT/StylesheetConstructionContextDefault.hpp>
-#include <XSLT/StylesheetExecutionContextDefault.hpp>
-#include <XSLT/StylesheetRoot.hpp>
-#include <XSLT/XSLTEngineImpl.hpp>
-#include <XSLT/XSLTInit.hpp>
#include <XSLT/XSLTInputSource.hpp>
-#include <XSLT/XSLTProcessorEnvSupportDefault.hpp>
#include <XSLT/XSLTResultTarget.hpp>
-
-#include <XalanSourceTree/XalanSourceTreeDOMSupport.hpp>
-#include <XalanSourceTree/XalanSourceTreeParserLiaison.hpp>
-
-
+#include <XalanTransformer/XalanDocumentBuilder.hpp>
#include <XalanTransformer/XalanCompiledStylesheet.hpp>
-#include <XalanTransformer/XalanDefaultParsedSource.hpp>
#include <XalanTransformer/XalanParsedSource.hpp>
-#include <XalanTransformer/XercesDOMParsedSource.hpp>
#include <XalanTransformer/XalanTransformerOutputStream.hpp>
@@ -117,7 +95,10 @@
#endif
+class XSLTInit;
+
+
/**
* This is a simple C++ interface for some common usage patterns. It's
* the user's responsibility to call initialize and terminate for Xerces
@@ -306,18 +287,36 @@
/**
* Creates a complied stylesheet. The input source can be
- * a file name, a stream or a root node.
+ * a file name, a stream or a root node. The XalanTransformer
+ * instance owns the XalanCompiledStylesheet instance and will
+ * delete it when the XalanTransformer instance goes out of scope,
+ * or you explicitly call destroyStylesheet(). You must not delete
+ * the instance yourself.
*
- * @param theStylesheetSource input source
- * @return a pointer to a XalanCompiledStylesheet or 0 for failure.
+ * @param theStylesheetSource input source
+ * @return a pointer to a XalanCompiledStylesheet or 0 for failure.
*/
XalanCompiledStylesheet*
- compileStylesheet(const XSLTInputSource& theStylesheetSource);
+ compileStylesheet(const XSLTInputSource& theStylesheetSource);
/**
- * Parse source document. The input source can be
- * a file name, a stream or a root node.
+ * Destroy a XalanCompiledStylesheet instance created by a previous
+ * call to compileStylesheet(). Passing a pointer that is not created
+ * by a call to createDocumentBuilder() can result in undefined behavior.
*
+ * @param theStylesheet The instance to destroy.
+ */
+ void
+ destroyStylesheet(XalanCompiledStylesheet* theStylesheet);
+
+ /**
+ * Parse a source XML document. The input source can be
+ * a file name, a stream or a root node. The XalanTransformer
+ * instance owns the XalanParsedSource instance and will
+ * delete it when the XalanTransformer instance goes out of scope,
+ * or you explicitly call destroyParsedSource(). You must not
+ * delete the instance yourself.
+ *
* @param theInputSource input source
* @param useXercesDOM input use default or xerces dom source tree
* @return a pointer to a XalanParsedSource or 0 for failure.
@@ -325,9 +324,41 @@
XalanParsedSource*
parseSource(
const XSLTInputSource& theInputSource,
- bool useXercesDOM = 0);
+ bool useXercesDOM = false);
+
+ /**
+ * Destroy a parsed source created by a previous call to parseSource().
+ * Passing a pointer that was not created by a call to parseSource() can
+ * result in undefined behavior.
+ *
+ * @param theParsedSource The XalanParsedSource instance to destroy.
+ */
+ void
+ destroyParsedSource(XalanParsedSource* theParsedSource);
+
+ /**
+ * Create a document builder. Using the document builder, you
+ * can construct a document using SAX2 interfaces. The XalanTransformer
+ * instance owns the document builder and will delete it when the
+ * XalanTransformer instance goes out of scope, or you explicitly call
+ * deleteDocumentBuilder(). You must not delete the instance yourself.
+ *
+ * @return a pointer to a XalanDocumentBuilder instance or 0 for failure.
+ */
+ XalanDocumentBuilder*
+ createDocumentBuilder();
/**
+ * Destroy a document builder created by a previous call to createDocumentBuilder().
+ * Passing a pointer that is not created by a call to createDocumentBuilder() can
+ * result in undefined behavior.
+ *
+ * @param theDocumentBuilder The document builder to destroy.
+ */
+ void
+ destroyDocumentBuilder(XalanDocumentBuilder* theDocumentBuilder);
+
+ /**
* Install an external function in the local space.
*
* @param theNamespace The namespace for the functionl
@@ -340,6 +371,14 @@
const XalanDOMString& functionName,
const Function& function);
+ /**
+ * Install an external function. The function is only
+ * available in this instance.
+ *
+ * @param theNamespace The namespace for the functionl
+ * @param functionName The name of the function.
+ * @param function The function to install.
+ */
void
installExternalFunction(
const char* theNamespace,
@@ -347,7 +386,7 @@
const Function& function);
/**
- * Uninstall an external function from the local space.
+ * Uninstall an external function.
*
* @param theNamespace The namespace for the function
* @param functionName The name of the function.
@@ -357,6 +396,12 @@
const XalanDOMString& theNamespace,
const XalanDOMString& functionName);
+ /**
+ * Uninstall an external function.
+ *
+ * @param theNamespace The namespace for the function
+ * @param functionName The name of the function.
+ */
void
uninstallExternalFunction(
const char* theNamespace,
@@ -373,10 +418,18 @@
setStylesheetParam(
const XalanDOMString& key,
const XalanDOMString& expression);
+
+ /**
+ * Set a top-level stylesheet parameter. This value can be evaluated via
+ * xsl:param-variable.
+ *
+ * @param key name of the param
+ * @param expression expression that will be evaluated
+ */
void
setStylesheetParam(
- const char* key,
- const char* expression);
+ const char* key,
+ const char* expression);
/**
* Returns the last error that occurred as a
@@ -408,7 +461,7 @@
private:
- void
+ void
reset();
StylesheetExecutionContextDefault m_stylesheetExecutionContext;
1.2 +3 -3 xml-xalan/c/src/XalanTransformer/XercesDOMParsedSource.cpp
Index: XercesDOMParsedSource.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XercesDOMParsedSource.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XercesDOMParsedSource.cpp 2001/03/30 21:35:44 1.1
+++ XercesDOMParsedSource.cpp 2001/04/27 20:56:51 1.2
@@ -62,7 +62,7 @@
-XercesDOMParsedSource::XercesDOMParsedSource(const XSLTInputSource& theInputSource):
+XercesDOMParsedSource::XercesDOMParsedSource(const XSLTInputSource& theInputSource):
XalanParsedSource(),
m_domSupport(),
m_parserLiaison(m_domSupport),
@@ -78,8 +78,8 @@
-XalanNode*
-XercesDOMParsedSource::getParsedSource()
+XalanDocument*
+XercesDOMParsedSource::getDocument()
{
return m_parsedSource;
}
1.2 +5 -7 xml-xalan/c/src/XalanTransformer/XercesDOMParsedSource.hpp
Index: XercesDOMParsedSource.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XercesDOMParsedSource.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XercesDOMParsedSource.hpp 2001/03/30 21:35:44 1.1
+++ XercesDOMParsedSource.hpp 2001/04/27 20:56:51 1.2
@@ -90,8 +90,8 @@
virtual
~XercesDOMParsedSource();
- virtual XalanNode*
- getParsedSource();
+ virtual XalanDocument*
+ getDocument();
virtual XMLParserLiaison*
getParserLiaison();
@@ -99,15 +99,13 @@
virtual DOMSupport*
getDOMSupport();
-protected:
-
private:
- XercesDOMSupport m_domSupport;
+ XercesDOMSupport m_domSupport;
- XercesParserLiaison m_parserLiaison;
+ XercesParserLiaison m_parserLiaison;
- XalanNode* const m_parsedSource;
+ XalanDocument* const m_parsedSource;
};
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org