dbertoni    00/05/18 11:38:46

  Modified:    c/src/XSLT ElemNumber.cpp StylesheetExecutionContext.hpp
                        StylesheetExecutionContextDefault.cpp
                        StylesheetExecutionContextDefault.hpp
                        StylesheetHandler.cpp StylesheetRoot.cpp
                        StylesheetRoot.hpp XSLTEngineImpl.cpp
                        XSLTEngineImpl.hpp XSLTProcessor.hpp
  Log:
  Made some changes to support switching formatters "on-the-fly", and for 
re-worked FormatterListeners.
  
  Revision  Changes    Path
  1.17      +11 -9     xml-xalan/c/src/XSLT/ElemNumber.cpp
  
  Index: ElemNumber.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemNumber.cpp,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ElemNumber.cpp    2000/05/08 17:29:34     1.16
  +++ ElemNumber.cpp    2000/05/18 18:38:38     1.17
  @@ -88,7 +88,15 @@
   
   const XalanDOMString 
ElemNumber::s_alphaCountTable(XALAN_STATIC_UCODE_STRING("ZABCDEFGHIJKLMNOPQRSTUVWXY"));
   
  -XalanDOMString       s_elalphaCountTable;
  +const XalanDOMChar   elalphaCountTable[] =
  +{
  +     0x03c9, 
0x03b1,0x03b2,0x03b3,0x03b4,0x03b5,0x03b6,0x03b7,0x03b8,0x03b9,0x03ba,
  +     0x03bb,0x03bc,0x03bd,0x03be,0x03bf,0x03c0,0x03c1,0x03c2,0x03c3,0x03c4,
  +     0x03c5,0x03c6,0x03c7,0x03c8,0
  +};
  +
  +
  +const XalanDOMString s_elalphaCountTable = elalphaCountTable;
   
   
   
  @@ -750,18 +758,12 @@
                case 0x0430:
                        executionContext.error(LongToDOMString(numberType) + " 
format not supported yet!");
                        break;
  +
                // Handle the special case of Greek letters for now
                case 0x03B1:
  -                     if (isEmpty(s_elalphaCountTable))
  -                     {
  -                             // Start at lower case Greek letters in entity 
reference table in
  -                             // FormatterToHTML
  -                             s_elalphaCountTable += 962;
  -                             for (unsigned short i = 1, j=938; i < 25; i++, 
j++)
  -                                     s_elalphaCountTable += j;
  -                     }
                        formattedNumber += int2alphaCount(listElement, 
s_elalphaCountTable);
                        break;
  +
                default: // "1"
                        {
                                const XalanDOMString            numString =
  
  
  
  1.14      +108 -0    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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- StylesheetExecutionContext.hpp    2000/05/15 15:57:45     1.13
  +++ StylesheetExecutionContext.hpp    2000/05/18 18:38:38     1.14
  @@ -96,6 +96,10 @@
   
   class ElemTemplateElement;
   class FormatterListener;
  +class FormatterToDOM;
  +class FormatterToHTML;
  +class FormatterToText;
  +class FormatterToXML;
   class PrefixResolver;
   class NodeRefListBase;
   class PrintWriter;
  @@ -103,7 +107,9 @@
   class Stylesheet;
   class StylesheetRoot;
   class TextOutputStream;
  +class Writer;
   class XalanDocument;
  +class XalanDocumentFragment;
   class XalanElement;
   class XalanNode;
   class XalanNumberFormat;
  @@ -944,6 +950,108 @@
   
                StylesheetExecutionContext&                     
m_executionContext;
        };
  +
  +
  +     /**
  +      * Create a new FormatterToXML instance.  The execution context
  +      * owns the instance and will delete it when reset.
  +      *
  +      * @param writer            character output stream to use
  +      * @param version           version of the output method
  +      * @param doIndent          true if output is to be indented
  +      * @param indent            number of spaces to indent at each nesting 
level
  +      * @param encoding          character encoding in use by 
<VAR>writer</VAR>
  +      * @param mediaType         media type (MIME content type) of the data
  +      * @param doctypeSystem     system identifier to be used in the document
  +      *                          type declaration
  +      * @param doctypePublic     public identifier to be used in the document
  +      *                          type declaration
  +      * @param xmlDecl           true if the XSLT processor should output an 
XML
  +      *                          declaration
  +      * @param standalone        true if the XSLT processor should output a
  +      *                          standalone document declaration
  +      * @return a pointer to the new instance.
  +      */
  +     virtual FormatterToXML*
  +     createFormatterToXML(
  +                     Writer&                                 writer,
  +                     const XalanDOMString&   version = XalanDOMString(),
  +                     bool                                    doIndent = 
false,
  +                     int                                             indent 
= 0,
  +                     const XalanDOMString&   encoding = XalanDOMString(),
  +                     const XalanDOMString&   mediaType = XalanDOMString(),
  +                     const XalanDOMString&   doctypeSystem = 
XalanDOMString(),
  +                     const XalanDOMString&   doctypePublic = 
XalanDOMString(),
  +                     bool                                    xmlDecl = true,
  +                     const XalanDOMString&   standalone = XalanDOMString()) 
= 0;
  +
  +     /**
  +      * Create a new FormatterToHTML instance.  The execution context
  +      * owns the instance and will delete it when reset.
  +      *
  +      * @param writer            character output stream to use
  +      * @param encoding          character encoding in use by 
<VAR>writer</VAR>
  +      * @param mediaType         media type (MIME content type) of the data
  +      * @param doctypeSystem     system identifier to be used in the document
  +      *                          type declaration
  +      * @param doctypePublic     public identifier to be used in the document
  +      *                          type declaration
  +      * @param doIndent          true if output is to be indented
  +      * @param indent            number of spaces to indent at each nesting 
level
  +      * @param version           version of the output method
  +      * @param standalone        true if the XSLT processor should output a
  +      *                          standalone document declaration
  +      * @param xmlDecl           true if the XSLT processor should output an 
XML
  +      *                          declaration
  +      * @return a pointer to the new instance.
  +      */
  +     virtual FormatterToHTML*
  +     createFormatterToHTML(
  +                     Writer&                                 writer,
  +                     const XalanDOMString&   encoding = XalanDOMString(),
  +                     const XalanDOMString&   mediaType = XalanDOMString(),
  +                     const XalanDOMString&   doctypeSystem = 
XalanDOMString(),
  +                     const XalanDOMString&   doctypePublic = 
XalanDOMString(),
  +                     bool                                    doIndent = true,
  +                     int                                             indent 
= 4,
  +                     const XalanDOMString&   version = XalanDOMString(),
  +                     const XalanDOMString&   standalone = XalanDOMString(),
  +                     bool                                    xmlDecl = 
false) = 0;
  +
  +     /**
  +      * Construct a FormatterToDOM instance.  it will add the DOM nodes 
  +      * to the document fragment.
  +      *
  +      * @param doc            document for nodes
  +      * @param docFrag        document fragment for nodes, default none
  +      * @param currentElement current element for nodes, default none
  +      */
  +     virtual FormatterToDOM*
  +     createFormatterToDOM(
  +                     XalanDocument*                  doc,
  +                     XalanDocumentFragment*  docFrag = 0,
  +                     XalanElement*                   currentElement = 0) = 0;
  +
  +     /**
  +      * Construct a FormatterToDOM instance.  it will add the DOM nodes 
  +      * to the document fragment.
  +      *
  +      * @param doc            document for nodes
  +      * @param docFrag        document fragment for nodes, default none
  +      * @param currentElement current element for nodes, default none
  +      */
  +     virtual FormatterToDOM*
  +     createFormatterToDOM(
  +                     XalanDocument*  doc,
  +                     XalanElement*   elem) = 0;
  +
  +     /**
  +      * FormatterToText instance constructor.
  +      *
  +      * @param pw print writer for output
  +      */
  +     virtual FormatterToText*
  +     createFormatterToText(Writer&   writer) = 0;
   
   
   #if defined(XALAN_NO_NAMESPACES)
  
  
  
  1.11      +138 -1    
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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- StylesheetExecutionContextDefault.cpp     2000/05/15 15:56:00     1.10
  +++ StylesheetExecutionContextDefault.cpp     2000/05/18 18:38:40     1.11
  @@ -79,6 +79,10 @@
   
   
   
  +#include <XMLSupport/FormatterToDOM.hpp>
  +#include <XMLSupport/FormatterToXML.hpp>
  +#include <XMLSupport/FormatterToHTML.hpp>
  +#include <XMLSupport/FormatterToText.hpp>
   #include <XMLSupport/XMLParserLiaison.hpp>
   
   
  @@ -121,6 +125,7 @@
        m_elementRecursionStack(),
        m_prefixResolver(0),
        m_stylesheetRoot(0),
  +     m_formatterListeners(),
        m_printWriters(),
        m_textOutputStreams()
   {
  @@ -142,6 +147,12 @@
        using std::for_each;
   #endif
   
  +     for_each(m_formatterListeners.begin(),
  +                      m_formatterListeners.end(),
  +                      DeleteFunctor<FormatterListener>());
  +
  +     m_formatterListeners.clear();
  +
        for_each(m_printWriters.begin(),
                         m_printWriters.end(),
                         DeleteFunctor<PrintWriter>());
  @@ -203,6 +214,17 @@
        assert(theStylesheet->isRoot() == true);
   
        m_stylesheetRoot = theStylesheet;
  +
  +     m_xsltProcessor.setStylesheetRoot(theStylesheet);
  +
  +     if (theStylesheet == 0)
  +     {
  +             m_xsltProcessor.setExecutionContext(0);
  +     }
  +     else
  +     {
  +             m_xsltProcessor.setExecutionContext(this);
  +     }
   }
   
   
  @@ -365,7 +387,7 @@
   int
   StylesheetExecutionContextDefault::getIndent() const
   {
  -             return m_xsltProcessor.getXMLParserLiaison().getIndent();
  +     return m_xsltProcessor.getXMLParserLiaison().getIndent();
   }
   
   
  @@ -720,6 +742,121 @@
        m_elementRecursionStack.pop_back();
   
        return theTemp;
  +}
  +
  +
  +
  +FormatterToXML*
  +StylesheetExecutionContextDefault::createFormatterToXML(
  +                     Writer&                                 writer,
  +                     const XalanDOMString&   version,
  +                     bool                                    doIndent,
  +                     int                                             indent,
  +                     const XalanDOMString&   encoding,
  +                     const XalanDOMString&   mediaType,
  +                     const XalanDOMString&   doctypeSystem,
  +                     const XalanDOMString&   doctypePublic,
  +                     bool                                    xmlDecl,
  +                     const XalanDOMString&   standalone)
  +{
  +     FormatterToXML* const   theFormatter =
  +             new FormatterToXML(
  +                     writer,
  +                     version,
  +                     doIndent,
  +                     indent,
  +                     encoding,
  +                     mediaType,
  +                     doctypeSystem,
  +                     doctypePublic,
  +                     xmlDecl,
  +                     standalone);
  +
  +     m_formatterListeners.insert(theFormatter);
  +
  +     return theFormatter;
  +}
  +
  +
  +
  +FormatterToHTML*
  +StylesheetExecutionContextDefault::createFormatterToHTML(
  +                     Writer&                                 writer,
  +                     const XalanDOMString&   encoding,
  +                     const XalanDOMString&   mediaType,
  +                     const XalanDOMString&   doctypeSystem,
  +                     const XalanDOMString&   doctypePublic,
  +                     bool                                    doIndent,
  +                     int                                             indent,
  +                     const XalanDOMString&   version,
  +                     const XalanDOMString&   standalone,
  +                     bool                                    xmlDecl)
  +{
  +     FormatterToHTML* const  theFormatter =
  +             new FormatterToHTML(
  +                     writer,
  +                     encoding,
  +                     mediaType,
  +                     doctypeSystem,
  +                     doctypePublic,
  +                     doIndent,
  +                     indent,
  +                     version,
  +                     standalone,
  +                     xmlDecl);
  +
  +     m_formatterListeners.insert(theFormatter);
  +
  +     return theFormatter;
  +}
  +
  +
  +
  +FormatterToDOM*
  +StylesheetExecutionContextDefault::createFormatterToDOM(
  +                     XalanDocument*                  doc,
  +                     XalanDocumentFragment*  docFrag,
  +                     XalanElement*                   currentElement)
  +{
  +     FormatterToDOM* const   theFormatter =
  +             new FormatterToDOM(
  +                     doc,
  +                     docFrag,
  +                     currentElement);
  +
  +     m_formatterListeners.insert(theFormatter);
  +
  +     return theFormatter;
  +}
  +
  +
  +
  +FormatterToDOM*
  +StylesheetExecutionContextDefault::createFormatterToDOM(
  +                     XalanDocument*  doc,
  +                     XalanElement*   elem)
  +{
  +     FormatterToDOM* const   theFormatter =
  +             new FormatterToDOM(
  +                     doc,
  +                     elem);
  +
  +     m_formatterListeners.insert(theFormatter);
  +
  +     return theFormatter;
  +}
  +
  +
  +
  +FormatterToText*
  +StylesheetExecutionContextDefault::createFormatterToText(Writer&     writer)
  +{
  +     FormatterToText* const  theFormatter =
  +             new FormatterToText(writer);
  +
  +     m_formatterListeners.insert(theFormatter);
  +
  +     return theFormatter;
   }
   
   
  
  
  
  1.12      +45 -1     
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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StylesheetExecutionContextDefault.hpp     2000/05/15 15:56:00     1.11
  +++ StylesheetExecutionContextDefault.hpp     2000/05/18 18:38:40     1.12
  @@ -332,10 +332,50 @@
        virtual const ElemTemplateElement*
        popElementRecursionStack();
   
  +     virtual FormatterToXML*
  +     createFormatterToXML(
  +                     Writer&                                 writer,
  +                     const XalanDOMString&   version = XalanDOMString(),
  +                     bool                                    doIndent = 
false,
  +                     int                                             indent 
= 0,
  +                     const XalanDOMString&   encoding = XalanDOMString(),
  +                     const XalanDOMString&   mediaType = XalanDOMString(),
  +                     const XalanDOMString&   doctypeSystem = 
XalanDOMString(),
  +                     const XalanDOMString&   doctypePublic = 
XalanDOMString(),
  +                     bool                                    xmlDecl = true,
  +                     const XalanDOMString&   standalone = XalanDOMString());
  +
  +     virtual FormatterToHTML*
  +     createFormatterToHTML(
  +                     Writer&                                 writer,
  +                     const XalanDOMString&   encoding = XalanDOMString(),
  +                     const XalanDOMString&   mediaType = XalanDOMString(),
  +                     const XalanDOMString&   doctypeSystem = 
XalanDOMString(),
  +                     const XalanDOMString&   doctypePublic = 
XalanDOMString(),
  +                     bool                                    doIndent = true,
  +                     int                                             indent 
= 4,
  +                     const XalanDOMString&   version = XalanDOMString(),
  +                     const XalanDOMString&   standalone = XalanDOMString(),
  +                     bool                                    xmlDecl = 
false);
  +
  +     virtual FormatterToDOM*
  +     createFormatterToDOM(
  +                     XalanDocument*                  doc,
  +                     XalanDocumentFragment*  docFrag = 0,
  +                     XalanElement*                   currentElement = 0);
  +
  +     virtual FormatterToDOM*
  +     createFormatterToDOM(
  +                     XalanDocument*  doc,
  +                     XalanElement*   elem);
  +
  +     virtual FormatterToText*
  +     createFormatterToText(Writer&   writer);
  +
  +
        virtual XalanNumberFormatAutoPtr
        createXalanNumberFormat();
   
  -
        // A basic class to create XalanNumberFormat instances...
        class XALAN_XSLT_EXPORT XalanNumberFormatFactory
        {
  @@ -560,10 +600,12 @@
   
   #if defined(XALAN_NO_NAMESPACES)
        typedef vector<const ElemTemplateElement*>                      
ElementRecursionStackType;
  +     typedef set<FormatterListener*>                                         
FormatterListenerSetType;
        typedef set<PrintWriter*>                                               
        PrintWriterSetType;
        typedef set<TextOutputStream*>                                          
TextOutputStreamSetType;
   #else
        typedef std::vector<const ElemTemplateElement*>         
ElementRecursionStackType;
  +     typedef std::set<FormatterListener*>                            
FormatterListenerSetType;
        typedef std::set<PrintWriter*>                                          
PrintWriterSetType;
        typedef std::set<TextOutputStream*>                                     
TextOutputStreamSetType;
   #endif
  @@ -573,6 +615,8 @@
        const PrefixResolver*                           m_prefixResolver;
   
        StylesheetRoot*                                         
m_stylesheetRoot;
  +
  +     FormatterListenerSetType                        m_formatterListeners;
   
        PrintWriterSetType                                      m_printWriters;
   
  
  
  
  1.26      +2 -2      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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- StylesheetHandler.cpp     2000/05/12 18:21:33     1.25
  +++ StylesheetHandler.cpp     2000/05/18 18:38:40     1.26
  @@ -117,7 +117,7 @@
                        XSLTEngineImpl&                                 
processor,
                        Stylesheet&                                             
stylesheetTree,
                        StylesheetConstructionContext&  constructionContext) :
  -     FormatterListener(),
  +     FormatterListener(OUTPUT_METHOD_OTHER),
        m_includeBase(stylesheetTree.getBaseIdentifier()),
        m_pendingException(),
        m_exceptionPending(false),
  @@ -1059,7 +1059,7 @@
        if(equals(name, XALAN_STATIC_UCODE_STRING("HTML")))
        {
                m_stylesheet.getStylesheetRoot().setIndentResult(true);
  -             
m_stylesheet.getStylesheetRoot().setOutputMethod(Formatter::OUTPUT_METH_HTML);
  +             
m_stylesheet.getStylesheetRoot().setOutputMethod(OUTPUT_METHOD_HTML);
        }
   
        return pElem;
  
  
  
  1.15      +44 -39    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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- StylesheetRoot.cpp        2000/05/12 18:21:33     1.14
  +++ StylesheetRoot.cpp        2000/05/18 18:38:41     1.15
  @@ -118,14 +118,14 @@
    *            halt processing.
    */
   StylesheetRoot::StylesheetRoot(
  -        const XalanDOMString&                                baseIdentifier,
  +        const XalanDOMString&                        baseIdentifier,
                StylesheetConstructionContext&  constructionContext) :
        Stylesheet(*this,
                           baseIdentifier,
                           constructionContext),
        m_importStack(),
        m_resultNameSpaceURL(),
  -     m_outputmethod(Formatter::OUTPUT_METH_XML),
  +     m_outputMethod(FormatterListener::OUTPUT_METHOD_NONE),
        m_version(),
        m_indentResult(false),
        m_encoding(),
  @@ -210,8 +210,6 @@
                using std::auto_ptr;
   #endif
   
  -             auto_ptr<FormatterListener>             theListenerGuard;
  -
                Writer* pw = 0;
   
                flistener = outputTarget.getFormatterListener();
  @@ -278,33 +276,44 @@
   
                        int                     indentAmount = 
executionContext.getIndent();
                        const bool      doIndent = (indentAmount > -1) ? true : 
m_indentResult;
  -                     // Make sure we don't have a negative indent amount if 
we're
  -                     // indenting
  -                     if (m_indentResult && indentAmount < 0)
  -                             indentAmount = 0;
                        
  -                     switch(m_outputmethod)
  +                     switch(m_outputMethod)
                        {
  -                     case Formatter::OUTPUT_METH_HTML:
  -                             flistener = new FormatterToHTML(
  -                                     *pw, m_version, doIndent, indentAmount, 
m_encoding, m_mediatype,
  -                                     m_doctypeSystem, m_doctypePublic, 
!m_omitxmlDecl, m_standalone);
  +                     case FormatterListener::OUTPUT_METHOD_HTML:
  +                             {
  +                                     if (doIndent == true && indentAmount < 
0)
  +                                     {
  +                                             indentAmount = 4;
  +                                     }
  +
  +                                     flistener = 
executionContext.createFormatterToHTML(
  +                                             *pw, m_encoding, m_mediatype, 
m_doctypeSystem, m_doctypePublic,
  +                                             doIndent, indentAmount, 
m_version, m_standalone, !m_omitxmlDecl);
  +                             }
                                break;
   
  -                     case Formatter::OUTPUT_METH_TEXT:
  -                             flistener = new FormatterToText(*pw);
  +                     case FormatterListener::OUTPUT_METHOD_TEXT:
  +                             flistener = 
executionContext.createFormatterToText(*pw);
                                break;
   
  -                     case Formatter::OUTPUT_METH_XML:
  +                     case FormatterListener::OUTPUT_METHOD_NONE:
  +                     case FormatterListener::OUTPUT_METHOD_XML:
                        default:
  -                             flistener = new FormatterToXML(
  -                                     *pw, m_version, doIndent, indentAmount, 
m_encoding, m_mediatype,
  -                                     m_doctypeSystem, m_doctypePublic, 
!m_omitxmlDecl, m_standalone);
  +                             {
  +                                     // Make sure we don't have a negative 
indent amount if we're
  +                                     // indenting
  +                                     if (doIndent == true && indentAmount < 
0)
  +                                     {
  +                                             indentAmount = 0;
  +                                     }
  +
  +                                     flistener = 
executionContext.createFormatterToXML(
  +                                             *pw, m_version, doIndent, 
indentAmount, m_encoding, m_mediatype,
  +                                             m_doctypeSystem, 
m_doctypePublic, !m_omitxmlDecl, m_standalone);
  +                             }
                                break;
                        }
   
  -                     theListenerGuard = 
auto_ptr<FormatterListener>(flistener);
  -
                        executionContext.setFormatterListener(flistener);
                }
                /*
  @@ -315,27 +324,25 @@
                        switch(outputTarget.getNode()->getNodeType())
                        {
                        case XalanNode::DOCUMENT_NODE:
  -                             flistener = new 
  -                                     
FormatterToDOM(static_cast<XalanDocument*>(outputTarget.getNode()));
  +                             flistener =
  +                                     
executionContext.createFormatterToDOM(static_cast<XalanDocument*>(outputTarget.getNode()));
                                break;
   
                        case XalanNode::DOCUMENT_FRAGMENT_NODE:
  -                             flistener = new 
  -                                     
FormatterToDOM(executionContext.createDocument(),
  +                             flistener =
  +                                     
executionContext.createFormatterToDOM(executionContext.createDocument(),
                                                
static_cast<XalanDocumentFragment*>(outputTarget.getNode()));
                                break;
   
                        case XalanNode::ELEMENT_NODE:
  -                             flistener = new 
  -                                     
FormatterToDOM(executionContext.createDocument(),
  +                             flistener =
  +                                     
executionContext.createFormatterToDOM(executionContext.createDocument(),
                                                
static_cast<XalanElement*>(outputTarget.getNode()));
                                break;
   
                        default:
                                executionContext.error("Can only output to an 
Element, DocumentFragment, Document, or PrintWriter.");
                        }
  -
  -                     theListenerGuard = 
auto_ptr<FormatterListener>(flistener);
                }
                /*
                 * Create an empty document and set the output target node to 
this
  @@ -343,10 +350,8 @@
                else
                {
                        outputTarget.setNode(executionContext.createDocument());
  -                     flistener = new
  -                             
FormatterToDOM(static_cast<XalanDocument*>(outputTarget.getNode()));
  -
  -                     theListenerGuard = 
auto_ptr<FormatterListener>(flistener);
  +                     flistener =
  +                             
executionContext.createFormatterToDOM(static_cast<XalanDocument*>(outputTarget.getNode()));
                }
                
                executionContext.setFormatterListener(flistener);
  @@ -400,10 +405,10 @@
    * The returned value is one of Formatter.OUTPUT_METH_XML,
    * Formatter.OUTPUT_METH_HTML, or Formatter.OUTPUT_METH_TEXT.
    */
  -int 
  +FormatterListener::eFormat
   StylesheetRoot::getOutputMethod() const
   { 
  -     return m_outputmethod; 
  +     return m_outputMethod; 
   }
   
   
  @@ -499,11 +504,11 @@
                        const XalanDOMChar*     const   method = 
atts.getValue(i);
   
                        if(equals(method, 
Constants::ATTRVAL_OUTPUT_METHOD_HTML))
  -                             m_outputmethod = Formatter::OUTPUT_METH_HTML;
  +                             m_outputMethod = 
FormatterListener::OUTPUT_METHOD_HTML;
                        else if(equals(method, 
Constants::ATTRVAL_OUTPUT_METHOD_XML))
  -                             m_outputmethod = Formatter::OUTPUT_METH_XML;
  +                             m_outputMethod = 
FormatterListener::OUTPUT_METHOD_XML;
                        else if(equals(method, 
Constants::ATTRVAL_OUTPUT_METHOD_TEXT))
  -                             m_outputmethod = Formatter::OUTPUT_METH_TEXT;
  +                             m_outputMethod = 
FormatterListener::OUTPUT_METHOD_TEXT;
                }
                else if(equals(aname, Constants::ATTRNAME_OUTPUT_VERSION))
                {
  @@ -557,7 +562,7 @@
                }
        }
   
  -     if((Formatter::OUTPUT_METH_HTML == m_outputmethod) &&
  +     if((FormatterListener::OUTPUT_METHOD_HTML == m_outputMethod) &&
                 (false == didSpecifyIndent))
        {
                m_indentResult = true;
  
  
  
  1.9       +22 -13    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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- StylesheetRoot.hpp        2000/05/11 19:08:35     1.8
  +++ StylesheetRoot.hpp        2000/05/18 18:38:41     1.9
  @@ -72,6 +72,10 @@
   
   
   
  +#include <XMLSupport/FormatterListener.hpp>
  +
  +
  +
   class SelectionEvent;
   class StylesheetConstructionContext;
   class TraceListener;
  @@ -121,17 +125,22 @@
                        XalanNode*                                              
sourceTree, 
                        XSLTResultTarget&                               
outputTarget,
                        StylesheetExecutionContext&             
executionContext);
  -  
  +
        /** 
         * Return the output method that was specified in the stylesheet. 
  -      * The returned value is one of Formatter.OUTPUT_METH_XML,
  -      * Formatter.OUTPUT_METH_HTML, or Formatter.OUTPUT_METH_TEXT.
  +      * The returned value is one of FormatterLister::eFormat values.
         *
  -      * @return number of output method
  +      * @return value of output method
         */
  -     int 
  +     FormatterListener::eFormat
        getOutputMethod() const;
   
  +     bool
  +     isOutputMethodSet() const
  +     {
  +             return getOutputMethod() == 
FormatterListener::OUTPUT_METHOD_NONE ? false : true;
  +     }
  +
        /**
         * Get the output version string that was specified in the
         * xsl:output element
  @@ -359,15 +368,15 @@
        }
   
        /**
  -      * Change the value of the output method, one of 
Formatter.OUTPUT_METH_XML,
  -      * Formatter.OUTPUT_METH_HTML, or Formatter.OUTPUT_METH_TEXT.
  +      * Change the value of the output method, one of the
  +      * FormatterListener::eFormat values.
         * 
         * @param meth new method number
         */
        void
  -     setOutputMethod(int meth)
  +     setOutputMethod(FormatterListener::eFormat      meth)
        {
  -             m_outputmethod = meth;
  +             m_outputMethod = meth;
        }
   
        /**
  @@ -433,13 +442,13 @@
         * The URL that belongs to the result namespace.
         * @serial
         */
  -     XalanDOMString m_resultNameSpaceURL; // = null;
  +     XalanDOMString  m_resultNameSpaceURL;
     
        /**
         * List of listeners who are interested in tracing what's going on.
         */
        //transient 
  -     ListenersVectorType m_traceListeners; // = null;
  +     ListenersVectorType             m_traceListeners;
     
        /**
         * String buffer for use by AVTs and the like.
  @@ -449,13 +458,13 @@
        /**
         * The output method as specified in xsl:output.
         */
  -     int m_outputmethod; // = Formatter.OUTPUT_METH_XML;
  +     FormatterListener::eFormat      m_outputMethod;
   
        /**
         * List of qnames that specifies elements that should be formatted 
         * as CDATA.
         */
  -     QNameVectorType m_cdataSectionElems; // = null;
  +     QNameVectorType         m_cdataSectionElems;
   
        /**
         * A stack of who's importing who is needed in order to support 
  
  
  
  1.38      +62 -0     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.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- XSLTEngineImpl.cpp        2000/05/15 15:57:45     1.37
  +++ XSLTEngineImpl.cpp        2000/05/18 18:38:41     1.38
  @@ -99,6 +99,8 @@
   #include <XMLSupport/Formatter.hpp>
   #include <XMLSupport/FormatterToDOM.hpp>
   #include <XMLSupport/FormatterToText.hpp>
  +#include <XMLSupport/FormatterToXML.hpp>
  +#include <XMLSupport/FormatterToHTML.hpp>
   #include <XMLSupport/FormatterTreeWalker.hpp>
   #include <XMLSupport/XMLParserLiaison.hpp>
   #include <XMLSupport/FormatterTreeWalker.hpp>
  @@ -228,6 +230,7 @@
        m_contextNodeList(&xpathSupport),
        m_namedTemplates(),
        m_topLevelVariables(),
  +     m_executionContext(0),
        m_needToCheckForInfiniteLoops(false),
        m_stackGuard(*this),
        m_attrSetStack()
  @@ -466,6 +469,8 @@
   
                if(0 != sourceTree)
                {
  +                     executionContext.setStylesheetRoot(m_stylesheetRoot);
  +
                        m_stylesheetRoot->process(sourceTree, outputTarget, 
executionContext);
   
                        if(0 != m_diagnosticsPrintWriter)
  @@ -1087,6 +1092,14 @@
   
   
   
  +void
  +XSLTEngineImpl::setExecutionContext(StylesheetExecutionContext*              
theExecutionContext)
  +{
  +     m_executionContext = theExecutionContext;
  +}
  +
  +
  +
   //==========================================================
   // SECTION: Diagnostic functions
   //==========================================================
  @@ -1481,6 +1494,8 @@
   XSLTEngineImpl::endDocument()
   {
        assert(m_flistener != 0);
  +     assert(m_executionContext != 0);
  +
        flushPending();
        m_flistener->endDocument();
        if(m_traceListeners.size() > 0)
  @@ -1552,12 +1567,59 @@
   
   
   
  +bool
  +XSLTEngineImpl::pendingAttributesHasDefaultNS() const
  +{
  +     const unsigned int      n = m_pendingAttributes.getLength();
  +
  +     for(unsigned int i = 0; i < n; i++)
  +     {
  +             if(equals(m_pendingAttributes.getName(i),
  +                               DOMServices::s_XMLNamespace) == true)
  +             {
  +                     return true;
  +             }
  +     }
  +
  +     return false;
  +}
  +
  +
  +
   void
   XSLTEngineImpl::flushPending()
   {
        if(0 != length(m_pendingElementName))
        {
                assert(m_flistener != 0);
  +             assert(m_executionContext != 0);
  +
  +             if (m_stylesheetRoot->isOutputMethodSet() == false)
  +             {
  +                     if (equalsIgnoreCase(m_pendingElementName,
  +                                                              
XALAN_STATIC_UCODE_STRING("html")) == 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])
  +                                     FormatterToXML* const   theFormatter =
  +                                             
static_cast<FormatterToXML*>(m_flistener);
  +
  +                                     m_flistener =
  +                                             
m_executionContext->createFormatterToHTML(
  +                                                     
theFormatter->getWriter(),
  +                                                     
theFormatter->getEncoding(),
  +                                                     
theFormatter->getMediaType(),
  +                                                     
theFormatter->getDoctypeSystem(),
  +                                                     
theFormatter->getDoctypePublic(),
  +                                                     true,   // indent
  +                                                     
theFormatter->getIndent() > 0 ? theFormatter->getIndent() : 4);
  +                             }
  +                     }
  +             }
  +
                m_cdataStack.push_back(isCDataResultElem(m_pendingElementName)? 
true : false);
                m_flistener->startElement(c_wstr(m_pendingElementName), 
m_pendingAttributes);
                if(m_traceListeners.size() > 0)
  
  
  
  1.31      +24 -3     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.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- XSLTEngineImpl.hpp        2000/05/15 15:57:45     1.30
  +++ XSLTEngineImpl.hpp        2000/05/18 18:38:41     1.31
  @@ -417,7 +417,8 @@
        /**
         * Flush the pending element.
         */
  -     void flushPending();
  +     void
  +     flushPending();
   
        /**
         * Add a namespace declaration to the namespace stack
  @@ -425,8 +426,10 @@
         * @param prefix           namespace prefix
         * @param namespaceVal value of namespace
         */
  -     void addResultNamespaceDecl(const XalanDOMString& prefix, 
  -                                                                        
const XalanDOMString& namespaceVal);
  +     void
  +     addResultNamespaceDecl(
  +                     const XalanDOMString&   prefix, 
  +                     const XalanDOMString&   namespaceVal);
   
        /**
         * Add attribute to attribute list, and if it is a namespace, add it to 
the
  @@ -646,6 +649,14 @@
        setStylesheetRoot(StylesheetRoot*       theStylesheet);
   
        /**
  +      * Set the execution context.
  +      * 
  +      * @param theExecutionContext pointer to new execution context.
  +      */
  +     virtual void
  +     setExecutionContext(StylesheetExecutionContext*         
theExecutionContext);
  +
  +     /**
         * Table of stylesheet documents. Document objects are keyed by URL 
string.
         */
        StylesheetMapType       m_stylesheets;
  @@ -1939,6 +1950,14 @@
   
   private:
   
  +
  +     /**
  +      * Determine if any pending attributes is a default
  +      * namespace.
  +      */
  +     bool
  +     pendingAttributesHasDefaultNS() const; 
  +
     /**
      * The top of this stack should contain the currently processed
      * stylesheet SAX locator object.
  @@ -2289,6 +2308,8 @@
         * Table for defined constants, keyed on the names.
         */
        TopLevelVariablesMapType        m_topLevelVariables;
  +
  +     StylesheetExecutionContext*             m_executionContext;
   
        /**
         * The StackGuard class guard against infinite loops.
  
  
  
  1.9       +9 -0      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XSLTProcessor.hpp 2000/05/15 15:56:00     1.8
  +++ XSLTProcessor.hpp 2000/05/18 18:38:42     1.9
  @@ -259,6 +259,15 @@
        setStylesheetRoot(StylesheetRoot*       theStylesheet) = 0;
   
        /**
  +      * Set the execution context. Must be set if after calling
  +      * setStylesheetRoot.
  +      * 
  +      * @param theExecutionContext pointer to new execution context.
  +      */
  +     virtual void
  +     setExecutionContext(StylesheetExecutionContext*         
theExecutionContext) = 0;
  +
  +     /**
         * Evaluates attribute values for attribute templates (Stuff in curly {}
         * braces that hold expressions).
         *
  
  
  

Reply via email to