FDO API Reference Feature Data Objects

TransformerXalan.h

Go to the documentation of this file.
00001 #ifndef FDO_XSL_TRANSFORMERXALAN_H
00002 #define FDO_XSL_TRANSFORMERXALAN_H
00003 // 
00004 
00005 //
00006 // Copyright (C) 2004-2006  Autodesk, Inc.
00007 // 
00008 // This library is free software; you can redistribute it and/or
00009 // modify it under the terms of version 2.1 of the GNU Lesser
00010 // General Public License as published by the Free Software Foundation.
00011 // 
00012 // This library is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 // Lesser General Public License for more details.
00016 // 
00017 // You should have received a copy of the GNU Lesser General Public
00018 // License along with this library; if not, write to the Free Software
00019 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 //
00021 
00022 
00023 #include <FdoCommon.h>
00024 #include <xercesc/util/BinInputStream.hpp>
00025 #define XALAN_USE_NATIVE_WCHAR_T 1
00026 #include <xalanc/XalanTransformer/XalanTransformer.hpp>
00027 #include <xalanc/XSLT/ProblemListener.hpp>
00028 
00029 
00030 /// \cond DOXYGEN-IGNORE
00031 // Subclass of FdoXslTransformer that uses Xalan to perform the transformation.
00032 // This class is not directly exposed to the API, only through the 
00033 // FdoXslTransformer interface.
00034 class FdoXslTransformerXalan : public FdoXslTransformer, public XALAN_CPP_NAMESPACE::ProblemListener
00035 {
00036 public:
00037 
00038     static FdoXslTransformerXalan* Create( 
00039         FdoXmlReader* inDoc = NULL, 
00040         FdoXmlReader* stylesheet = NULL, 
00041         FdoXmlWriter* outDoc = NULL,
00042         FdoIoTextWriter* log = NULL
00043     );
00044 
00045     virtual void Transform();
00046 
00047     static void Initialize();
00048 
00049     /// Implementation of XALAN_CPP_NAMESPACE::ProblemListener interface:
00050     virtual void setPrintWriter(XALAN_CPP_NAMESPACE::PrintWriter*       pw);
00051     /**
00052      * Function that is called when a problem event occurs.
00053      * 
00054      * @param   where          either in XMLPARSER, XSLPROCESSOR, or QUERYENGINE
00055      * @param   classification either MESSAGE, ERROR or WARNING
00056      * @param   sourceNode     source tree node where the problem occurred
00057      *                         (may be 0)
00058      * @param   styleNode      style tree node where the problem occurred
00059      *                         (may be 0)
00060      * @param   msg            string message explaining the problem.
00061      * @param   uri            the URI of the document where the problem occurred.  May be 0.
00062      * @param   lineNo         line number where the problem occurred.
00063      * @param   charOffset     character offset where the problem.
00064      */
00065     virtual void
00066     problem(
00067             eProblemSource              where,
00068             eClassification             classification,
00069             const XALAN_CPP_NAMESPACE::XalanNode*           sourceNode,
00070             const XALAN_CPP_NAMESPACE::ElemTemplateElement* styleNode,
00071             const XALAN_CPP_NAMESPACE::XalanDOMString&      msg,
00072             const XALAN_CPP_NAMESPACE::XalanDOMChar*            uri,
00073             int                         lineNo,
00074             int                         charOffset);
00075 
00076 protected:
00077     /// Reader adapter. Allows Xalan to read from a FdoXmlReader.
00078     class InputSource : public XALAN_CPP_NAMESPACE::XSLTInputSource
00079     {
00080     public:
00081 
00082         InputSource( FdoXmlReader* reader );
00083 
00084         ~InputSource() {}
00085 
00086         virtual XALAN_CPP_NAMESPACE::BinInputStreamType* makeStream () const;
00087 
00088     private:
00089         class InputStream : public XALAN_CPP_NAMESPACE::BinInputStreamType
00090         {
00091         public:
00092             InputStream( FdoXmlReader* reader ); 
00093 
00094             ~InputStream() {}
00095 
00096     /// Tells Xalan the current position of the reader
00097             virtual unsigned int curPos()  const;
00098 
00099     /// Gets data from the reader to Xalan.
00100             virtual unsigned int readBytes( 
00101                 XMLByte *const  toFill,  
00102                 const unsigned int  maxToRead 
00103             );
00104 
00105         private:
00106             FdoXmlReaderP mReader;
00107         };
00108 
00109         FdoXmlReaderP mReader;
00110     };
00111 
00112     FdoXslTransformerXalan( 
00113         FdoXmlReader* inDoc = NULL, 
00114         FdoXmlReader* stylesheet = NULL, 
00115         FdoXmlWriter* outDoc = NULL,
00116         FdoIoTextWriter* log = NULL
00117     );
00118 
00119     virtual ~FdoXslTransformerXalan(void) {}
00120 
00121     /// Output handler callback implementation. Writes the data to the 
00122     /// out document
00123     unsigned long HandleOutput(const void* data, unsigned long length );
00124 
00125     /// Output handler callback implementation. Forwards the data to this 
00126     /// transformer, which is passed in through the handle parameter.
00127     static CallbackSizeType outputHandler(const void* data, CallbackSizeType length, const void *handle);
00128 
00129     /// Handles output flush requests from Xalan.
00130     static void flushHandler(const void *handle);
00131 
00132     /// Convert a XalanDOMString to a FdoStringP string:
00133     FdoStringP XalanDomStringToUnicode(const XALAN_CPP_NAMESPACE::XalanDOMString &xalanDomString);
00134 
00135     /// Convert a XalanNode to a FdoStringP string:
00136     FdoStringP XalanNodeToUnicode(const XALAN_CPP_NAMESPACE::XalanNode* inNode);
00137 
00138 private:
00139     FdoInt32            mPrologueState;
00140 };
00141 /// \endcond
00142 
00143 #endif
00144 
00145 

Comments or suggestions? Send us feedback.