auriemma 01/03/20 13:50:12
Modified: c/src/XalanTransformer XalanCAPI.cpp XalanCAPI.h
XalanTransformer.hpp
Log:
Added (c) support for compiled stylesheets and stylesheet parameters.
Revision Changes Path
1.10 +120 -2 xml-xalan/c/src/XalanTransformer/XalanCAPI.cpp
Index: XalanCAPI.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanCAPI.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XalanCAPI.cpp 2001/02/14 18:51:24 1.9
+++ XalanCAPI.cpp 2001/03/20 21:50:07 1.10
@@ -124,11 +124,40 @@
const char* theOutFileName,
XalanHandle theXalanHandle)
{
+ if(0 == theXSLFileName)
+ {
// Do the transformation...
#if defined(XALAN_OLD_STYLE_CASTS)
+ return ((XalanTransformer*)theXalanHandle)->transform(theXMLFileName,
theOutFileName);
+#else
+ return
static_cast<XalanTransformer*>(theXalanHandle)->transform(theXMLFileName,
theOutFileName);
+#endif
+ }
+ else
+ {
+ // Do the transformation...
+#if defined(XALAN_OLD_STYLE_CASTS)
return ((XalanTransformer*)theXalanHandle)->transform(theXMLFileName,
theXSLFileName, theOutFileName);
#else
return
static_cast<XalanTransformer*>(theXalanHandle)->transform(theXMLFileName,
theXSLFileName, theOutFileName);
+#endif
+ }
+}
+
+
+
+XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
+XalanTransformToFileCSS(
+ const char* theXMLFileName,
+ XalanCSSHandle theCSSHandle,
+ const char* theOutFileName,
+ XalanHandle theXalanHandle)
+{
+ // Do the transformation...
+#if defined(XALAN_OLD_STYLE_CASTS)
+ return ((XalanTransformer*)theXalanHandle)->transform(theXMLFileName,
(XalanCompiledStylesheet*)theCSSHandle, theOutFileName);
+#else
+ return
static_cast<XalanTransformer*>(theXalanHandle)->transform(theXMLFileName,
static_cast<XalanCompiledStylesheet*>(theCSSHandle), theOutFileName);
#endif
}
@@ -148,12 +177,53 @@
int status = true;
ostrstream theOutputStream;
+ if(0 == theXSLFileName)
+ {
+ // Do the transformation...
+#if defined(XALAN_OLD_STYLE_CASTS)
+ status =
((XalanTransformer*)theXalanHandle)->transform(theXMLFileName, theOutputStream);
+#else
+ status =
static_cast<XalanTransformer*>(theXalanHandle)->transform(theXMLFileName,
theOutputStream);
+#endif
+ }
+ else
+ {
+#if defined(XALAN_OLD_STYLE_CASTS)
+ status =
((XalanTransformer*)theXalanHandle)->transform(theXMLFileName, theXSLFileName,
theOutputStream);
+#else
+ status =
static_cast<XalanTransformer*>(theXalanHandle)->transform(theXMLFileName,
theXSLFileName, theOutputStream);
+#endif
+ }
+ // Null-terminate the data.
+ theOutputStream << '\0';
+
+ *theOutput = theOutputStream.str();
+
+ return status;
+}
+
+
+
+XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
+XalanTransformToDataCSS(
+ const char* theXMLFileName,
+ XalanCSSHandle theCSSHandle,
+ char** theOutput,
+ XalanHandle theXalanHandle)
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::ostrstream;
+#endif
+
+ int status = true;
+
+ ostrstream theOutputStream;
// Do the transformation...
#if defined(XALAN_OLD_STYLE_CASTS)
- status = ((XalanTransformer*)theXalanHandle)->transform(theXMLFileName,
theXSLFileName, theOutputStream);
+ status = ((XalanTransformer*)theXalanHandle)->transform(theXMLFileName,
(XalanCompiledStylesheet*)theCSSHandle, theOutputStream);
#else
- status =
static_cast<XalanTransformer*>(theXalanHandle)->transform(theXMLFileName,
theXSLFileName, theOutputStream);
+ status =
static_cast<XalanTransformer*>(theXalanHandle)->transform(theXMLFileName,
static_cast<XalanCompiledStylesheet*>(theCSSHandle), theOutputStream);
#endif
// Null-terminate the data.
theOutputStream << '\0';
@@ -188,6 +258,54 @@
return ((XalanTransformer*)theXalanHandle)->transform(theXMLFileName,
theXSLFileName, theOutputHandle, theOutputHandler, theFlushHandler);
#else
return
static_cast<XalanTransformer*>(theXalanHandle)->transform(theXMLFileName,
theXSLFileName, theOutputHandle, theOutputHandler, theFlushHandler);
+#endif
+}
+
+
+
+XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
+XalanTransformToHandlerCSS(
+ const char* theXMLFileName,
+ XalanCSSHandle theCSSHandle,
+ XalanHandle theXalanHandle,
+ const void*
theOutputHandle,
+ XalanOutputHandlerType theOutputHandler,
+ XalanFlushHandlerType theFlushHandler)
+{
+ // Do the transformation...
+#if defined(XALAN_OLD_STYLE_CASTS)
+ return ((XalanTransformer*)theXalanHandle)->transform(theXMLFileName,
(XalanCompiledStylesheet*)theCSSHandletheCSSHandle, theOutputHandle,
theOutputHandler, theFlushHandler);
+#else
+ return
static_cast<XalanTransformer*>(theXalanHandle)->transform(theXMLFileName,
static_cast<XalanCompiledStylesheet*>(theCSSHandle), theOutputHandle,
theOutputHandler, theFlushHandler);
+#endif
+}
+
+
+
+XALAN_TRANSFORMER_EXPORT_FUNCTION(XalanCSSHandle)
+XalanCompileStylesheet(
+ const char* theXSLFileName,
+ XalanHandle theXalanHandle)
+{
+#if defined(XALAN_OLD_STYLE_CASTS)
+ return
((XalanTransformer*)theXalanHandle)->compileStylesheet(theXSLFileName);
+#else
+ return
static_cast<XalanTransformer*>(theXalanHandle)->compileStylesheet(theXSLFileName);
+#endif
+}
+
+
+
+XALAN_TRANSFORMER_EXPORT_FUNCTION(void)
+XalanSetStylesheetParam(
+ const char* key,
+ const char* expression,
+ XalanHandle theXalanHandle)
+{
+#if defined(XALAN_OLD_STYLE_CASTS)
+ ((XalanTransformer*)theXalanHandle)->setStylesheetParam(key,
expression);
+#else
+ static_cast<XalanTransformer*>(theXalanHandle)->setStylesheetParam(key,
expression);
#endif
}
1.9 +105 -6 xml-xalan/c/src/XalanTransformer/XalanCAPI.h
Index: XalanCAPI.h
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanCAPI.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XalanCAPI.h 2001/02/08 21:18:09 1.8
+++ XalanCAPI.h 2001/03/20 21:50:08 1.9
@@ -65,10 +65,11 @@
/**
* This is a simple C interface for the class XalanTransformer. It's
- * the user's responsibility to call initialize and terminate
- * before creating and after deleting any XalanTransformer instances
- * respectively. After calling XalanTransformToData, the user should
- * call XalanFreeData to release the memory allocated by that operation.
+ * the user's responsibility to call initialize and terminate before
+ * creating and after deleting any XalanTransformer instances respectively.
+ * After calling XalanTransformToData or XalanTransformToDataCSS, the user
+ * should call XalanFreeData to release the memory allocated by that
+ * operation.
*/
#if defined(__cplusplus)
extern "C"
@@ -76,11 +77,16 @@
#endif
/**
- * Handle use to store the address of XalanTransformer instance.
+ * Handle used to store the address of XalanTransformer instance.
*/
typedef void* XalanHandle;
/**
+ * Handle used to store the address of Compiled Stylesheet instance.
+ */
+ typedef void* XalanCSSHandle;
+
+ /**
* Callback function passed to XalanTransformToHandler.
* Used to process transformation output in blocks of data.
* Caller is responsible for streaming or copying data to a user
@@ -136,7 +142,7 @@
/**
* Create a XalanTransformer instance.
*
- * @return pointer to current handler
+ * @return the XalanTransformer handle
*/
XALAN_TRANSFORMER_EXPORT_FUNCTION(XalanHandle)
CreateXalanTransformer();
@@ -168,6 +174,24 @@
XalanHandle
theXalanHandle);
/**
+ * Transform the XML source tree to the given result file.
+ * The processor will apply the compiled stylesheet to the input
+ * file and write the transformation result to a new output file.
+ *
+ * @param theXMLFileName filename of XML input source
+ * @param theCSSHandle handle of compiled stylesheet
+ * @param theOutFileName filename of output source
+ * @param theXalanHandle handle of XalanTransformer instance.
+ * @return 0 for success
+ */
+ XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
+ XalanTransformToFileCSS(
+ const char*
theXMLFileName,
+ XalanCSSHandle theCSSHandle,
+ const char*
theOutFileName,
+ XalanHandle
theXalanHandle);
+
+ /**
* Transform the XML source tree to a dynamically allocated buffer.
* The processor will apply the stylesheet file to the input file
* and assign the address of the dynamically allocated result to a
@@ -188,6 +212,26 @@
XalanHandle
theXalanHandle);
/**
+ * Transform the XML source tree to a dynamically allocated buffer.
+ * The processor will apply the compiled stylesheet to the input file
+ * and assign the address of the dynamically allocated result to a
+ * user defined pointer. The user must call XalanFreeData with the
+ * address of this pointer.
+ *
+ * @param theXMLFileName filename of XML input source
+ * @param theCSSHandle handle of compiled stylesheet
+ * @param theOutFileName filename of output source
+ * @param theXalanHandle handle of XalanTransformer instance.
+ * @return 0 for success
+ */
+ XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
+ XalanTransformToDataCSS(
+ const char*
theXMLFileName,
+ XalanCSSHandle theCSSHandle,
+ char**
theOutput,
+ XalanHandle
theXalanHandle);
+
+ /**
* Free memory allocated as a result of calling
* XalanTransformToData.
*
@@ -225,6 +269,61 @@
const void*
theOutputHandle,
XalanOutputHandlerType theOutputHandler,
XalanFlushHandlerType theFlushHandler);
+
+ /**
+ * Transform the XML source tree to a callback function.
+ * The processor will apply the compiled stylesheet to the input file
+ * and allocate the transformation result to a callback function
+ * in pre-allocated blocks. Once the transformation is complete,
+ * a second callback, to flush the buffer, is called. You can pass
+ * in NULL if you do not wish to implement a flush callback. Xalan
+ * will release any memory allocated upon termination, and data passed
+ * to the callback is not guaranteed to be null terminated.
+ *
+ * - See XalanOutputHandlerType and XalanFlushHandlerType for more
+ * details.
+ *
+ * @param theXMLFileName filename of XML input source
+ * @param theCSSHandle handle of compiled stylesheet
+ * @param theXalanHandle handle of XalanTransformer instance.
+ * @param theOutputHandle void pointer passed through to callback.
+ * @param theOutputHandler a user defined (callback) function.
+ * @param theFlushHandler (can be NULL) a user defined (callback)
function.
+ * @return 0 for success
+ */
+ XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
+ XalanTransformToHandlerCSS(
+ const char*
theXMLFileName,
+ XalanCSSHandle theCSSHandle,
+ XalanHandle
theXalanHandle,
+ const void*
theOutputHandle,
+ XalanOutputHandlerType theOutputHandler,
+ XalanFlushHandlerType theFlushHandler);
+
+ /**
+ * Creates a complied stylesheet. The input source can be
+ * a file name, a stream or a root node.
+ *
+ * @param theXSLFileName filename of stylesheet source
+ * @return a CSSHandle or 0 for failure.
+ */
+ XALAN_TRANSFORMER_EXPORT_FUNCTION(XalanCSSHandle)
+ XalanCompileStylesheet(
+ const char*
theXSLFileName,
+ XalanHandle
theXalanHandle);
+
+ /**
+ * 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
+ */
+ XALAN_TRANSFORMER_EXPORT_FUNCTION(void)
+ XalanSetStylesheetParam(
+ const char* key,
+ const char*
expression,
+ XalanHandle
theXalanHandle);
/**
* Returns the last error that occurred as a
1.13 +10 -9 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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XalanTransformer.hpp 2001/03/16 20:12:40 1.12
+++ XalanTransformer.hpp 2001/03/20 21:50:09 1.13
@@ -145,15 +145,6 @@
terminate();
/**
- * Returns the last error that occurred as a
- * result of calling transform.
- *
- * @return error message const character pointer.
- */
- const char*
- getLastError() const;
-
- /**
* Transform will apply the stylesheet source to the input source
* and write the transformation output to the target. The input
* source and result target can be a file name, a stream or a root
@@ -303,6 +294,16 @@
setStylesheetParam(
const char* key,
const char* expression);
+
+ /**
+ * Returns the last error that occurred as a
+ * result of calling transform.
+ *
+ * @return error message const character pointer.
+ */
+ const char*
+ getLastError() const;
+
#if defined(XALAN_NO_NAMESPACES)
typedef vector<const XalanCompiledStylesheet*>
CompiledStylesheetPtrVectorType;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]