Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions
txCopyBase Class Reference

#include <txInstructions.h>

Inheritance diagram for txCopyBase:
Inheritance graph
[legend]
Collaboration diagram for txCopyBase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual nsresult execute (txExecutionState &aEs)=0

Public Attributes

txInstructionmNext

Protected Member Functions

nsresult copyNode (const txXPathNode &aNode, txExecutionState &aEs)

Detailed Description

Definition at line 153 of file txInstructions.h.


Member Function Documentation

nsresult txCopyBase::copyNode ( const txXPathNode aNode,
txExecutionState aEs 
) [protected]

Definition at line 280 of file txInstructions.cpp.

{
    switch (txXPathNodeUtils::getNodeType(aNode)) {
        case txXPathNodeType::ATTRIBUTE_NODE:
        {
            nsAutoString nodeName, nodeValue;
            txXPathNodeUtils::getNodeName(aNode, nodeName);
            txXPathNodeUtils::appendNodeValue(aNode, nodeValue);
            aEs.mResultHandler->attribute(nodeName,
                                          txXPathNodeUtils::getNamespaceID(aNode),
                                          nodeValue);
            break;
        }
        case txXPathNodeType::COMMENT_NODE:
        {
            nsAutoString nodeValue;
            txXPathNodeUtils::appendNodeValue(aNode, nodeValue);
            aEs.mResultHandler->comment(nodeValue);
            break;
        }
        case txXPathNodeType::DOCUMENT_NODE:
        case txXPathNodeType::DOCUMENT_FRAGMENT_NODE:
        {
            // Copy children
            txXPathTreeWalker walker(aNode);
            PRBool hasChild = walker.moveToFirstChild();
            while (hasChild) {
                copyNode(walker.getCurrentPosition(), aEs);
                hasChild = walker.moveToNextSibling();
            }
            break;
        }
        case txXPathNodeType::ELEMENT_NODE:
        {
            nsAutoString name;
            txXPathNodeUtils::getNodeName(aNode, name);
            PRInt32 nsID = txXPathNodeUtils::getNamespaceID(aNode);
            aEs.mResultHandler->startElement(name, nsID);

            // Copy attributes
            txXPathTreeWalker walker(aNode);
            if (walker.moveToFirstAttribute()) {
                do {
                    nsAutoString nodeName, nodeValue;
                    walker.getNodeName(nodeName);
                    walker.appendNodeValue(nodeValue);
                    aEs.mResultHandler->attribute(nodeName,
                                                  walker.getNamespaceID(),
                                                  nodeValue);
                } while (walker.moveToNextAttribute());
                walker.moveToParent();
            }

            // Copy children
            PRBool hasChild = walker.moveToFirstChild();
            while (hasChild) {
                copyNode(walker.getCurrentPosition(), aEs);
                hasChild = walker.moveToNextSibling();
            }

            aEs.mResultHandler->endElement(name, nsID);
            break;
        }
        case txXPathNodeType::PROCESSING_INSTRUCTION_NODE:
        {
            nsAutoString target, data;
            txXPathNodeUtils::getNodeName(aNode, target);
            txXPathNodeUtils::appendNodeValue(aNode, data);
            aEs.mResultHandler->processingInstruction(target, data);
            break;
        }
        case txXPathNodeType::TEXT_NODE:
        case txXPathNodeType::CDATA_SECTION_NODE:
        {
            nsAutoString nodeValue;
            txXPathNodeUtils::appendNodeValue(aNode, nodeValue);
            aEs.mResultHandler->characters(nodeValue, PR_FALSE);
            break;
        }
    }
    
    return NS_OK;
}

Here is the call graph for this function:

virtual nsresult txInstruction::execute ( txExecutionState aEs) [pure virtual, inherited]

Here is the caller graph for this function:


Member Data Documentation

Definition at line 67 of file txInstructions.h.


The documentation for this class was generated from the following files: