Annotation of parser3/src/types/pa_vxnode.C, revision 1.2

1.1       parser      1: /** @node
                      2:        Parser: @b dnode parser type.
                      3: 
                      4:        Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com)
                      5:        Author: Alexander Petrosyan <paf@design.ru>(http://design.ru/paf)
                      6: 
1.2     ! parser      7:        $Id: pa_vxnode.C,v 1.1 2001/09/26 11:24:07 parser Exp $
1.1       parser      8: */
                      9: #include "pa_config_includes.h"
                     10: #ifdef XML
                     11: 
                     12: #include "pa_vxnode.h"
                     13: #include "pa_vxdoc.h"
                     14: #include "pa_vstring.h"
                     15: #include "pa_vbool.h"
                     16: #include "pa_vhash.h"
                     17: 
                     18: #include <util/XMLString.hpp>
                     19: #include <util/PlatformUtils.hpp>
                     20: #include <util/TransService.hpp>
                     21: #include <XalanDOM/XalanNamedNodeMap.hpp>
                     22: #include <XalanDOM/XalanAttr.hpp>
                     23: #include <XalanDOM/XalanProcessingInstruction.hpp>
1.2     ! parser     24: #include <XalanDOM/XalanNodeList.hpp>
1.1       parser     25: 
                     26: /*
                     27: void VXnode_cleanup(void *vxnode) {
                     28:        //_asm int 3;
                     29:        static_cast<VXnode *>(vxnode)->cleanup();
                     30: }
                     31: */
                     32: 
                     33: /// VXnode: $CLASS,$method
                     34: Value *VXnode::get_element(const String& aname) { 
                     35:        // $CLASS,$method
                     36:        if(Value *result=VStateless_object::get_element(aname))
                     37:                return result;
                     38: 
                     39:        // fields
                     40: 
                     41:        XalanNode *self=&get_node(pool(), &aname);
                     42: 
1.2     ! parser     43:        if(aname=="nodeName") {
1.1       parser     44:                return NEW VString(transcode(self->getNodeName()));
1.2     ! parser     45:        } else if(aname=="nodeValue") {
1.1       parser     46:                return NEW VString(transcode(self->getNodeValue()));
1.2     ! parser     47:        } else if(aname=="nodeType") {
        !            48:                return NEW VInt(pool(), self->getNodeType());
        !            49:        } else if(aname=="parentNode") {
1.1       parser     50:                if(XalanNode *result_node=self->getParentNode())
                     51:                        return NEW VXnode(pool(), result_node);
1.2     ! parser     52:        } else if(aname=="childNodes") {        
        !            53:                if(const XalanNodeList *nodes=self->getChildNodes()) {
        !            54:                        VHash *result=NEW VHash(pool());
        !            55:                        for(int i=0; i<nodes->getLength(); i++) {
        !            56:                                String& skey=*NEW String(pool());
        !            57:                                {
        !            58:                                        char *buf=(char *)malloc(MAX_NUMBER);
        !            59:                                        snprintf(buf, MAX_NUMBER, "%d", i);
        !            60:                                        skey << buf;
        !            61:                                }
        !            62: 
        !            63:                                result->hash().put(skey, NEW VXnode(pool(), nodes->item(i)));
        !            64:                        }
        !            65:                        return result;
        !            66:                }
        !            67:        } else if(aname=="firstChild") {
1.1       parser     68:                if(XalanNode *result_node=self->getFirstChild())
                     69:                        return NEW VXnode(pool(), result_node);
1.2     ! parser     70:        } else if(aname=="lastChild") {
1.1       parser     71:                if(XalanNode *result_node=self->getLastChild())
                     72:                        return NEW VXnode(pool(), result_node);
1.2     ! parser     73:        } else if(aname=="previousSibling") {
1.1       parser     74:                if(XalanNode *result_node=self->getPreviousSibling())
                     75:                        return NEW VXnode(pool(), result_node);
1.2     ! parser     76:        } else if(aname=="nextSibling") {
1.1       parser     77:                if(XalanNode *result_node=self->getNextSibling())
                     78:                        return NEW VXnode(pool(), result_node);
1.2     ! parser     79:        } else if(aname=="ownerDocument") {
1.1       parser     80:                if(XalanDocument *document=self->getOwnerDocument())
                     81:                        return NEW VXdoc(pool(), document);
                     82:        } else switch(self->getNodeType()) {
                     83:                case XalanNode::ELEMENT_NODE: 
                     84:                        if(aname=="attributes") {
                     85:                                if(const XalanNamedNodeMap *attributes=self->getAttributes()) {
                     86:                                        VHash *result=NEW VHash(pool());
                     87:                                        for(int i=0; i<attributes->getLength(); i++) {
                     88:                                                XalanNode *attr_node=attributes->item(i);
                     89:                                                result->hash().put(
                     90:                                                        transcode(attr_node->getNodeName()), 
                     91:                                                        NEW VXnode(pool(), attr_node));
                     92:                                        }
                     93:                                        return result;
                     94:                                }
                     95:                        }
                     96:                        break;
                     97:                case XalanNode::ATTRIBUTE_NODE: 
                     98:                        if(aname=="specified")
                     99:                                return NEW VBool(pool(), static_cast<XalanAttr *>(self)->getSpecified());
                    100:                        break;
                    101: /*
                    102:                case XalanNode::TEXT_NODE: 
                    103:                case XalanNode::CDATA_SECTION_NODE: 
                    104:                case XalanNode::COMMENT_NODE: 
                    105:                        substringData(unsigned int offset, unsigned int count)
                    106: */
                    107:                //case XalanNode::ENTITY_REFERENCE_NODE: 
                    108:                //case XalanNode::ENTITY_NODE: 
                    109:                case XalanNode::PROCESSING_INSTRUCTION_NODE: 
                    110:                        if(aname=="target")
                    111:                                return NEW VString(transcode(static_cast<XalanProcessingInstruction *>(self)->getTarget()));
                    112:                        break;
                    113: /*
                    114:                case XalanNode::DOCUMENT_NODE: 
                    115: virtual XalanDocumentType* getDoctype () const = 0 
                    116:        Get Document Type Declaration (see DocumentType) associated with this document. More...
                    117: virtual XalanDOMImplementation* getImplementation () const = 0 
                    118:        Return the DOMImplementation object that handles this document.
                    119: virtual XalanElement* getDocumentElement () const = 0 
                    120:        Return a reference to the root element of the document.
                    121: virtual XalanNodeList* getElementsByTagName (const XalanDOMString& tagname) const = 0 
                    122:        Returns a NodeList of all the elements with a given tag name. More...
                    123: */
                    124: /*
                    125:                case XalanNode::DOCUMENT_TYPE_NODE: 
                    126: virtual const XalanDOMString& getName () const = 0 
                    127:        The name of DTD; i.e., the name immediately following the DOCTYPE keyword in an XML source document.
                    128: virtual const XalanNamedNodeMap* getEntities () const = 0 
                    129:        This function returns a NamedNodeMap containing the general entities, both external and internal, declared in the DTD. More...
                    130: virtual const XalanNamedNodeMap* getNotations () const = 0 
                    131:        This function returns a named node map containing an entry for each notation declared in a document's DTD. More...*/
                    132: //             case XalanNode::DOCUMENT_FRAGMENT_NODE: 
                    133: //             case XalanNode::NOTATION_NODE;
                    134:        }
                    135:        
                    136: 
                    137:        return 0;
                    138: }
                    139: 
                    140: #endif

E-mail: