/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if !defined(FORMATTERTOHTML_HEADER_GUARD_1357924680) #define FORMATTERTOHTML_HEADER_GUARD_1357924680 // Base include file. Must be first. #include #include // Base class header file. #include #include #include namespace XALAN_CPP_NAMESPACE { /** * FormatterToHTML formats SAX-style events into HTML. */ class XALAN_XMLSUPPORT_EXPORT FormatterToHTML : public FormatterToXML { public: typedef XalanVector ElementPropertiesStackType; enum { eDefaultIndentAmount = 0 }; /** * Constructor for customized encoding and doctype. * @param writer The character output stream to use. * @param encoding The character encoding in use by writer. * @param doctypeSystem The system ID for the DOCTYPE. * @param doctypePublic The public ID for the DOCTYPE. * @param doIndent true if indenting should be enabled * @param indent Number of spaces to indent at each nesting level. * @param escapeURLs Whether or not to escape URLs according to the recommendation. The default is true. * @param omitMetaTag Whether or not to output a META TAG according to the recommendation. The default is false. */ FormatterToHTML( Writer& writer, const XalanDOMString& encoding = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), const XalanDOMString& mediaType = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), const XalanDOMString& doctypeSystem = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), const XalanDOMString& doctypePublic = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), bool doIndent = true, int indent = eDefaultIndentAmount, bool escapeURLs = true, bool omitMetaTag = false, MemoryManager& theManager XALAN_DEFAULT_MEMMGR); static FormatterToHTML* create( MemoryManager& theManager, Writer& writer, const XalanDOMString& encoding, const XalanDOMString& mediaType, const XalanDOMString& doctypeSystem, const XalanDOMString& doctypePublic, bool doIndent, int indent, bool escapeURLs, bool omitMetaTag); virtual ~FormatterToHTML(); // These methods are inherited from DocumentHandler ... virtual void startDocument(); virtual void endDocument(); virtual void startElement( const XMLCh* const name, AttributeListType& attrs); virtual void endElement(const XMLCh* const name); virtual void characters( const XMLCh* const chars, const size_type length); // These methods are inherited from FormatterToXML... virtual bool accumDefaultEntity( XalanDOMChar ch, bool escLF); // These methods are inherited from FormatterListener ... virtual void entityReference(const XMLCh* const name); virtual void cdata( const XMLCh* const ch, const size_type length); virtual void processingInstruction( const XMLCh* const target, const XMLCh* const data); bool getEscapeURLs() const { return m_escapeURLs; } void setEscapeURLs(bool flag) { m_escapeURLs = flag; } struct Entity { enum { eMaxLength = 8 }; XalanDOMChar m_char; size_type m_length; XalanDOMChar m_string[eMaxLength + 1]; }; protected: virtual void writeAttrString( const XalanDOMChar* theString, size_type theStringLength); virtual void accumCommentData(const XalanDOMChar* data); void writeCharacters(const XalanDOMString& theString); void writeCharacters( const XalanDOMChar* theString, size_type theLength); private: /** * The string "