dbertoni    2003/01/23 18:31:42

  Added:       c/src/XercesParserLiaison FormatterToXercesDOM.cpp
                        FormatterToXercesDOM.hpp
                        XercesDOMFormatterWalker.cpp
                        XercesDOMFormatterWalker.hpp
                        XercesNamedNodeMapAttributeList.cpp
                        XercesNamedNodeMapAttributeList.hpp
  Log:
  New classes.
  
  Revision  Changes    Path
  1.1                  
xml-xalan/c/src/XercesParserLiaison/FormatterToXercesDOM.cpp
  
  Index: FormatterToXercesDOM.cpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  // Class header file.
  #include "FormatterToXercesDOM.hpp"
  
  
  
  #include <cassert>
  
  
  
  #include <xercesc/sax/AttributeList.hpp>
  
  
  
  #include <xercesc/dom/DOMCDATASection.hpp>
  #include <xercesc/dom/DOMComment.hpp>
  #include <xercesc/dom/DOMDocument.hpp>
  #include <xercesc/dom/DOMDocumentFragment.hpp>
  #include <xercesc/dom/DOMElement.hpp>
  #include <xercesc/dom/DOMEntityReference.hpp>
  #include <xercesc/dom/DOMProcessingInstruction.hpp>
  #include <xercesc/dom/DOMText.hpp>
  
  
  
  #include <XalanDOM/XalanDOMString.hpp>
  
  
  
  #include <PlatformSupport/DOMStringHelper.hpp>
  #include <PlatformSupport/PrefixResolver.hpp>
  
  
  
  XALAN_CPP_NAMESPACE_BEGIN
  
  
  
  const XalanDOMString  FormatterToXercesDOM::s_emptyString;
  
  
  
  FormatterToXercesDOM::FormatterToXercesDOM(
                        DOMDocument_Type*                       doc,
                        DOMDocumentFragmentType*        docFrag,
                        DOMElementType*                         currentElement) 
:
        FormatterListener(OUTPUT_METHOD_DOM),
        m_doc(doc),
        m_docFrag(docFrag),
        m_currentElem(currentElement),
        m_elemStack(),
        m_buffer(),
        m_textBuffer()
  {
        assert(m_doc != 0 && m_docFrag != 0);
  }
  
  
  
  FormatterToXercesDOM::FormatterToXercesDOM(
                        DOMDocument_Type*       doc,
                        DOMElementType*         elem) :
        FormatterListener(OUTPUT_METHOD_DOM),
        m_doc(doc),
        m_docFrag(0),
        m_currentElem(elem),
        m_elemStack(),
        m_buffer(),
        m_textBuffer()
  {
        assert(m_doc != 0);
  }
  
  
  
  FormatterToXercesDOM::~FormatterToXercesDOM()
  {
  }
  
  
  
  void
  FormatterToXercesDOM::setDocumentLocator(const LocatorType* const     /* 
locator */)
  {
        // No action for the moment.
  }
  
  
  
  void
  FormatterToXercesDOM::startDocument()
  {
        // No action for the moment.
  }
  
  
  
  void
  FormatterToXercesDOM::endDocument()
  {
        // No action for the moment.
  }
  
  
  
  void
  FormatterToXercesDOM::startElement(
                        const   XMLCh* const    name,
                        AttributeListType&              attrs)
  {
        processAccumulatedText();
  
        DOMElementType* const   elem = createElement(name, attrs);
        assert(elem != 0);
  
        append(elem);
  
        m_elemStack.push_back(m_currentElem);
  
        m_currentElem = elem;
  }
  
  
  
  void
  FormatterToXercesDOM::endElement(const        XMLCh* const    /* name */)
  {
        processAccumulatedText();
  
        if(m_elemStack.empty() == false)
        {
                m_currentElem = m_elemStack.back();
  
                m_elemStack.pop_back();
        }
        else
        {
                m_currentElem = 0;
        }
  }
  
  
  
  void
  FormatterToXercesDOM::characters(
                        const XMLCh* const      chars,
                        const unsigned int      length)
  {
        m_textBuffer.append(chars, length);
  }
  
  
  
  void
  FormatterToXercesDOM::charactersRaw(
                const XMLCh* const      chars,
                const unsigned int      length)
  {
        processAccumulatedText();
  
        cdata(chars, length);
  }             
  
  
  
  void
  FormatterToXercesDOM::entityReference(const XMLCh* const      name)
  {
        processAccumulatedText();
  
        append(m_doc->createEntityReference(name));
  }
  
  
  
  void
  FormatterToXercesDOM::ignorableWhitespace(
                        const XMLCh* const      chars,
                        const unsigned int      length)
  {
        processAccumulatedText();
  
        assign(m_buffer, chars, length);
  
        append(m_doc->createTextNode(m_buffer.c_str()));
  }
  
  
  
  void
  FormatterToXercesDOM::processingInstruction(
                        const XMLCh* const      target,
                        const XMLCh* const      data)
  {
        processAccumulatedText();
  
        append(m_doc->createProcessingInstruction(target, data));
  }
  
  
  
  void
  FormatterToXercesDOM::resetDocument()
  {
  }
  
  
  
  void
  FormatterToXercesDOM::comment(const XMLCh* const      data)
  {
        processAccumulatedText();
  
        append(m_doc->createComment(data));
  }
  
  
  
  void
  FormatterToXercesDOM::cdata(
                        const XMLCh* const      ch,
                        const unsigned int      length)
  {
        processAccumulatedText();
  
        assign(m_buffer, ch, length);
  
        append(m_doc->createCDATASection(m_buffer.c_str()));
  }
  
  
  
  void
  FormatterToXercesDOM::append(DOMNodeType*     newNode)
  {
        assert(newNode != 0);
  
        if(0 != m_currentElem)
        {
                m_currentElem->appendChild(newNode);
        }
        else if(0 != m_docFrag)
        {
                m_docFrag->appendChild(newNode);
        }
        else
        {
                m_doc->appendChild(newNode);
        }
  }
  
  
  
  DOMElementType*
  FormatterToXercesDOM::createElement(
                        const XalanDOMChar*             theElementName,
                        AttributeListType&              attrs)
  {
        DOMElementType* theElement = 0;
  
        if (m_prefixResolver == 0)
        {
                theElement = m_doc->createElement(theElementName);
  
                addAttributes(theElement, attrs);
        }
        else
        {
                // Check for the namespace...
                const XalanDOMString* const             theNamespace =
                                        getNamespaceForPrefix(theElementName, 
*m_prefixResolver, m_buffer);
  
                if (theNamespace == 0 || length(*theNamespace) == 0)
                {
                        theElement = m_doc->createElement(theElementName);
                }
                else
                {
                        theElement = 
m_doc->createElementNS(theNamespace->c_str(), theElementName);
                }
  
                addAttributes(theElement, attrs);
        }
  
        return theElement;
  }
  
  
  
  void
  FormatterToXercesDOM::addAttributes(
                        DOMElementType*         theElement,
                        AttributeListType&      attrs)
  {
        const unsigned int      nAtts = attrs.getLength();
  
        if (m_prefixResolver == 0)
        {
                for(unsigned int i = 0; i < nAtts; i++)
                {
                        theElement->setAttribute(attrs.getName(i), 
attrs.getValue(i));
                }
        }
        else
        {
                for(unsigned int i = 0; i < nAtts; i++)
                {
                        const XalanDOMChar* const       theName = 
attrs.getName(i);
                        assert(theName != 0);
  
                        // Check for the namespace...
                        const XalanDOMString* const             theNamespace =
                                        getNamespaceForPrefix(theName, 
*m_prefixResolver, m_buffer);
  
                        if (theNamespace == 0 || length(*theNamespace) == 0)
                        {
                                theElement->setAttribute(theName, 
attrs.getValue(i));
                        }
                        else
                        {
                                
theElement->setAttributeNS(theNamespace->c_str(), theName, attrs.getValue(i));
                        }
                }
        }
  }
  
  
  
  const XalanDOMString*
  FormatterToXercesDOM::getNamespaceForPrefix(
                        const XalanDOMChar*             theName,
                        const PrefixResolver&   thePrefixResolver,
                        XalanDOMString&                 thePrefix)
  {
        const XalanDOMString::size_type         theLength = length(theName);
        const XalanDOMString::size_type         theColonIndex = 
indexOf(theName, XalanUnicode::charColon);
  
        if (theColonIndex == theLength)
        {
                clear(thePrefix);
  
                return thePrefixResolver.getNamespaceForPrefix(s_emptyString);
        }
        else
        {
                // Get the prefix from theName...
                assign(thePrefix, theName, theColonIndex);
                assert(length(thePrefix) != 0);
  
                return thePrefixResolver.getNamespaceForPrefix(thePrefix);
        }
  }
  
  
  
  void
  FormatterToXercesDOM::processAccumulatedText()
  {
        if (isEmpty(m_textBuffer) == false)
        {
                append(m_doc->createTextNode(m_textBuffer.c_str()));
  
                clear(m_textBuffer);
        }
  }
  
  
  
  XALAN_CPP_NAMESPACE_END
  
  
  
  1.1                  
xml-xalan/c/src/XercesParserLiaison/FormatterToXercesDOM.hpp
  
  Index: FormatterToXercesDOM.hpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  #if !defined(FORMATTERTOXERCESDOM_HEADER_GUARD_1357924680)
  #define FORMATTERTOXERCESDOM_HEADER_GUARD_1357924680
  
  
  
  // Base include file.  Must be first.
  #include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
  
  
  
  #include <vector>
  
  
  
  // Base class header file.
  #include <PlatformSupport/FormatterListener.hpp>
  
  
  
  #include <XalanDOM/XalanDOMString.hpp>
  
  
  
  #include <XercesParserLiaison/XercesWrapperTypes.hpp>
  
  
  
  XALAN_CPP_NAMESPACE_BEGIN
  
  
  
  /**
   * This class takes SAX events (in addition to some extra events that SAX
   * doesn't handle yet) and adds the result to a document or document fragment.
   */
  class XALAN_XERCESPARSERLIAISON_EXPORT FormatterToXercesDOM : public 
FormatterListener
  {
  public:
  
        /**
         * Construct a FormatterToXercesDOM instance.  it will add the DOM 
nodes 
         * to the document fragment.
         *
         * @param doc            document for nodes
         * @param docFrag        document fragment for nodes
         * @param currentElement current element for nodes
         */
        FormatterToXercesDOM(
                        DOMDocument_Type*                       doc,
                        DOMDocumentFragmentType*        docFrag,
                        DOMElementType*                         currentElement);
  
        /**
         * Construct a FormatterToDOM instance.  it will add the DOM nodes 
         * to the document.
         *
         * @param doc  document for nodes
         * @param elem current element for nodes
         */
        FormatterToXercesDOM(
                        DOMDocument_Type*                       doc,
                        DOMElementType*                         currentElement);
  
        virtual
        ~FormatterToXercesDOM();
  
  
        // These methods are inherited from DocumentHandler ...
  
        virtual void
        charactersRaw(
                        const XMLCh* const      chars,
                        const unsigned int      length);
  
        virtual void
        comment(const XMLCh* const      data);
  
        virtual void
        cdata(
                        const XMLCh* const      ch,
                        const unsigned int      length);
  
        virtual void
        entityReference(const XMLCh* const      name);
  
        virtual void
        setDocumentLocator(const LocatorType* const             locator);
  
        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 unsigned int      length);
  
        virtual void
        ignorableWhitespace(
                                const XMLCh* const      chars,
                                const unsigned int      length);
  
        virtual void
        processingInstruction(
                        const XMLCh* const      target,
                        const XMLCh* const      data);
  
        virtual void
        resetDocument();
  
        DOMDocument_Type*
        getDocument() const
        {
                return m_doc;
        }
  
        void
        setDocument(DOMDocument_Type*   theDocument)
        {
                m_doc = theDocument;
        }
  
        DOMDocumentFragmentType*
        getDocumentFragment() const
        {
                return m_docFrag;
        }
  
        void
        setDocumentFragment(DOMDocumentFragmentType*    theDocumentFragment)
        {
                m_docFrag = theDocumentFragment;
        }
  
        DOMElementType*
        getCurrentElement() const
        {
                return m_currentElem;
        }
  
        void
        setCurrentElement(DOMElementType*               theElement)
        {
                m_currentElem = theElement;
        }
  
  private:
  
        /**
         * Process any accumulated text and create a node for it.
         */
        void
        processAccumulatedText();
  
        /**
         * Append a node to the current container.
         */
        void
        append(DOMNodeType*     newNode);
  
        /**
         * Create the appropriate element, complete with attributes set.
         *
         * @param theElementName The name for the new element
         * @param attrs The SAX AttributeList for the new attributes.
         * @return A pointer to the new instance.
         */
        DOMElementType*
        createElement(
                        const XalanDOMChar*             theElementName,
                        AttributeListType&              attrs);
  
        void
        addAttributes(
                        DOMElementType*         theElement,
                        AttributeListType&      attrs);
  
        const XalanDOMString*
        getNamespaceForPrefix(
                        const XalanDOMChar*             theName,
                        const PrefixResolver&   thePrefixResolver,
                        XalanDOMString&                 thePrefix);
  
  
        // Data members...
        DOMDocument_Type*                               m_doc;
  
        DOMDocumentFragmentType*                m_docFrag;
  
        DOMElementType*                                 m_currentElem;
  
  #if defined(XALAN_NO_STD_NAMESPACE)
        typedef vector<DOMElementType*>                 ElementStackType;
  #else
        typedef std::vector<DOMElementType*>    ElementStackType;
  #endif
  
        ElementStackType                                m_elemStack;
  
        XalanDOMString                                  m_buffer;
  
        XalanDOMString                                  m_textBuffer;
  
        static const XalanDOMString             s_emptyString;
  };
  
  
  
  XALAN_CPP_NAMESPACE_END
  
  
  
  #endif        // FORMATTERTODOM_HEADER_GUARD_1357924680
  
  
  
  1.1                  
xml-xalan/c/src/XercesParserLiaison/XercesDOMFormatterWalker.cpp
  
  Index: XercesDOMFormatterWalker.cpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  // Class header file.
  #include "XercesDOMFormatterWalker.hpp"
  
  
  
  // Xerces header files...
  #include <xercesc/dom/DOMElement.hpp>
  
  
  
  #include <PlatformSupport/AttributeListImpl.hpp>
  #include <PlatformSupport/DOMStringHelper.hpp>
  #include <PlatformSupport/FormatterListener.hpp>
  
  
  
  #include <XercesParserLiaison/XercesNamedNodeMapAttributeList.hpp>
  
  
  
  XALAN_CPP_NAMESPACE_BEGIN
  
  
  
  XercesDOMFormatterWalker::XercesDOMFormatterWalker(FormatterListener&         
formatterListener) :
        XercesDOMWalker(),
        m_formatterListener(formatterListener)
  {
  }
  
  
  
  XercesDOMFormatterWalker::~XercesDOMFormatterWalker()
  {
  }
  
  
  
  void
  XercesDOMFormatterWalker::startNode(const DOMNodeType*        node)
  {
        assert(node != 0);
  
        switch(node->getNodeType())
        {
        case DOMNodeType::COMMENT_NODE:
                {
                        m_formatterListener.comment(node->getNodeValue());
                }
                break;
  
        case DOMNodeType::DOCUMENT_FRAGMENT_NODE:
                // ??
                break;
  
        case DOMNodeType::DOCUMENT_NODE:
                m_formatterListener.startDocument();
                break;
  
        case DOMNodeType::ELEMENT_NODE:
                {
                        const DOMElementType* const             theElementNode =
  #if defined(XALAN_OLD_STYLE_CASTS)
                                (const DOMElementType*)node;
  #else
                                static_cast<const DOMElementType*>(node);
  #endif
  
                        const DOMNamedNodeMapType* const        atts = 
theElementNode->getAttributes();
                        assert(atts != 0);
  
                        XercesNamedNodeMapAttributeList         
theAttributeList(atts);
  
                        m_formatterListener.startElement(
                                        theElementNode->getNodeName(),
                                        theAttributeList);
                }
                break;
  
        case DOMNodeType::PROCESSING_INSTRUCTION_NODE:
                {
                        m_formatterListener.processingInstruction(
                                        node->getNodeName(),
                                        node->getNodeValue());
                }
                break;
  
        case DOMNodeType::CDATA_SECTION_NODE:
                {
                        const XMLCh* const      data = node->getNodeValue();
  
                        assert(length(data) == 
FormatterListener::size_type(length(data)));
  
                        m_formatterListener.cdata(data, 
FormatterListener::size_type(length(data)));
                }
                break;
  
        case DOMNodeType::TEXT_NODE:
                {
                        const XMLCh* const      data = node->getNodeValue();
  
                        assert(length(data) == 
FormatterListener::size_type(length(data)));
  
                        m_formatterListener.characters(data, 
FormatterListener::size_type(length(data)));
                }
                break;
  
        case DOMNodeType::ENTITY_REFERENCE_NODE:
                m_formatterListener.entityReference(node->getNodeName());
                break;
  
        default:
                // Do nothing...
                break;
        }
  }
  
  
  
  void
  XercesDOMFormatterWalker::endNode(const DOMNodeType*  node)
  {
        assert(node != 0);
  
        switch(node->getNodeType())
        {
        case DOMNodeType::DOCUMENT_NODE:
                m_formatterListener.endDocument();
                break;
  
        case DOMNodeType::ELEMENT_NODE:
                m_formatterListener.endElement(node->getNodeName());
                break;
  
        default:
                // Do nothing
                break;
        }
  }
  
  
  
  XALAN_CPP_NAMESPACE_END
  
  
  
  1.1                  
xml-xalan/c/src/XercesParserLiaison/XercesDOMFormatterWalker.hpp
  
  Index: XercesDOMFormatterWalker.hpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  #if !defined(XERCESDOMFORMATTERWALKER_HEADER_GUARD_1357924680)
  #define XERCESDOMFORMATTERWALKER_HEADER_GUARD_1357924680
  
  
  
  #include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
  #include <XercesParserLiaison/XercesDOMWalker.hpp>
  
  
  
  XALAN_CPP_NAMESPACE_BEGIN
  
  
  
  class FormatterListener;
  
  
  
  class XALAN_XERCESPARSERLIAISON_EXPORT XercesDOMFormatterWalker : public 
XercesDOMWalker
  {
  public:
  
        /**
         * Constructor.
         */
        XercesDOMFormatterWalker(FormatterListener&             
theFormatterListener);
  
        virtual
        ~XercesDOMFormatterWalker();
  
  protected:
  
        virtual void
        startNode(const DOMNodeType*    node);
  
        virtual void
        endNode(const DOMNodeType*      node);
  
  private:
  
        FormatterListener&      m_formatterListener;
  
  };
  
  
  
  XALAN_CPP_NAMESPACE_END
  
  
  
  #endif        // XERCESDOMFORMATTERWALKER_HEADER_GUARD_1357924680
  
  
  
  1.1                  
xml-xalan/c/src/XercesParserLiaison/XercesNamedNodeMapAttributeList.cpp
  
  Index: XercesNamedNodeMapAttributeList.cpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "XercesNamedNodeMapAttributeList.hpp"
  
  
  #include <xercesc/dom/DOMNamedNodeMap.hpp>
  #include <xercesc/dom/DOMNode.hpp>
  
  
  
  #include <PlatformSupport/DOMStringHelper.hpp>
  #include <PlatformSupport/XalanUnicode.hpp>
  
  
  
  XALAN_CPP_NAMESPACE_BEGIN
  
  
  
  const XMLCh           XercesNamedNodeMapAttributeList::s_typeString[] = 
  {
        XalanUnicode::charLetter_C,
        XalanUnicode::charLetter_D,
        XalanUnicode::charLetter_A,
        XalanUnicode::charLetter_T,
        XalanUnicode::charLetter_A,
        0
  };
  
  
  
  XercesNamedNodeMapAttributeList::XercesNamedNodeMapAttributeList(const 
DOMNamedNodeMapType*           theMap) :
        ParentType(),
        m_nodeMap(theMap),
        m_lastIndex(theMap->getLength() - 1)
  {
  }
  
  
  
  XercesNamedNodeMapAttributeList::~XercesNamedNodeMapAttributeList()
  {
  }
  
  
  
  unsigned int
  XercesNamedNodeMapAttributeList::getLength() const
  {
        return m_lastIndex + 1;
  }
  
  
  
  const XMLCh*
  XercesNamedNodeMapAttributeList::getName(const unsigned int index) const
  {
        const DOMNodeType* const        theAttribute = 
m_nodeMap->item(m_lastIndex - index);
        assert(theAttribute != 0);
  
        return theAttribute->getNodeName();
  }
  
  
  
  const XMLCh*
  XercesNamedNodeMapAttributeList::getType(const unsigned int /* index */) const
  {
        assert(length(s_typeString) > 0);
  
        return s_typeString;
  }
  
  
  
  const XMLCh*
  XercesNamedNodeMapAttributeList::getValue(const unsigned int index) const
  {
        const DOMNodeType* const        theAttribute = 
m_nodeMap->item(m_lastIndex - index);
        assert(theAttribute != 0);
  
        return theAttribute->getNodeValue();
  }
  
  
  
  const XMLCh*
  XercesNamedNodeMapAttributeList::getType(const XMLCh* const /* name */) const
  {
        assert(length(s_typeString) > 0);
  
        return s_typeString;
  }
  
  
  
  const XMLCh*
  XercesNamedNodeMapAttributeList::getValue(const XMLCh* const name) const
  {
        const DOMNodeType*      theNode = m_nodeMap->getNamedItem(name);
  
        if (theNode == 0)
        {
                return 0;
        }
        else
        {
                return theNode->getNodeValue();
        }
  }
  
  
  
  const XMLCh* 
  XercesNamedNodeMapAttributeList::getValue(const char* const name) const
  {
        return getValue(c_wstr(TranscodeFromLocalCodePage(name)));
  }
  
  
  
  XALAN_CPP_NAMESPACE_END
  
  
  
  1.1                  
xml-xalan/c/src/XercesParserLiaison/XercesNamedNodeMapAttributeList.hpp
  
  Index: XercesNamedNodeMapAttributeList.hpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  #if !defined(XERCESNAMEDNODEMAPATTRIBUTELIST_HEADER_GUARD_1357924680)
  #define XERCESNAMEDNODEMAPATTRIBUTELIST_HEADER_GUARD_1357924680
  
  
  
  // Base include file.  Must be first.
  #include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
  
  
  
  #include <vector>
  
  
  
  #include <xercesc/sax/AttributeList.hpp>
  
  
  
  #include <XercesParserLiaison/XercesWrapperTypes.hpp>
  
  
  
  XALAN_CPP_NAMESPACE_BEGIN
  
  
  
  class XALAN_XERCESPARSERLIAISON_EXPORT XercesNamedNodeMapAttributeList : 
public XERCES_CPP_NAMESPACE_QUALIFIER AttributeList
  {
  public:
  
        typedef XERCES_CPP_NAMESPACE_QUALIFIER AttributeList    ParentType;
  
        explicit
        XercesNamedNodeMapAttributeList(const DOMNamedNodeMapType*      theMap);
  
        virtual
        ~XercesNamedNodeMapAttributeList();
  
        // These are inherited from AttributeList
      virtual unsigned int
        getLength() const;
  
      virtual const XMLCh*
        getName(const unsigned int index) const;
  
      virtual const XMLCh*
        getType(const unsigned int index) const;
  
      virtual const XMLCh*
        getValue(const unsigned int index) const;
  
      virtual const XMLCh*
        getType(const XMLCh* const name) const;
  
      virtual const XMLCh*
        getValue(const XMLCh* const name) const;
  
        virtual const XMLCh* 
        getValue(const char* const name) const;
  
  private:
  
        // Not implemented...
        XercesNamedNodeMapAttributeList&
        operator=(const XercesNamedNodeMapAttributeList&);
  
        bool
        operator==(const XercesNamedNodeMapAttributeList&);
  
  
        // Data members...
        const DOMNamedNodeMapType* const        m_nodeMap;
  
        const XMLSizeType                                       m_lastIndex;
  
        static const XMLCh      s_typeString[];
  };
  
  
  
  XALAN_CPP_NAMESPACE_END
  
  
  
  #endif        // XERCESNAMEDNODEMAPATTRIBUTELIST_HEADER_GUARD_1357924680
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to