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

1.1       parser      1: /** @node
                      2:        Parser: @b dnode parser type.
                      3: 
1.31    ! paf         4:        Copyright(c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com)
1.15      paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.1       parser      6: */
                      7: #include "pa_config_includes.h"
                      8: #ifdef XML
1.18      paf         9: 
1.31    ! paf        10: static const char* IDENT_VXNODE_C="$Date: 2003/04/01 15:42:26 $";
1.1       parser     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"
1.31    ! paf        17: #include "pa_request_charsets.h"
        !            18: #include "pa_charset.h"
1.1       parser     19: 
1.31    ! paf        20: /// @todo strdup properties [now can be: $nodeName[$xdoc.nodeName], free(xdoc), >>print $nodeName<<GPF
        !            21: Value* VXnode::get_element(const String& aname, Value& aself, bool looking_up) { 
1.12      paf        22:        // $CLASS,$method
1.31    ! paf        23:        if(Value* result=VStateless_object::get_element(aname, aself, looking_up))
1.12      paf        24:                return result;
                     25: 
                     26:        // fields
                     27: 
1.31    ! paf        28:        GdomeNode* selfNode=get_node();
1.12      paf        29:        GdomeException exc;
                     30: 
1.21      paf        31:        if(aname=="nodeName") {
1.31    ! paf        32:                return new VString(fcharsets->source().transcode(gdome_n_nodeName(selfNode, &exc)));
1.21      paf        33:        } else if(aname=="nodeValue") {
1.31    ! paf        34:                return new VString(fcharsets->source().transcode(gdome_n_nodeValue(selfNode, &exc)));
1.21      paf        35:        } else if(aname=="nodeType") {
1.31    ! paf        36:                return new VInt(gdome_n_nodeType(selfNode, &exc));
1.21      paf        37:        } else if(aname=="parentNode") {
1.31    ! paf        38:                if(GdomeNode* result_node=gdome_n_parentNode(selfNode, &exc))
        !            39:                        return new VXnode(fcharsets, result_node);
1.25      paf        40:                return 0;
1.21      paf        41:        } else if(aname=="childNodes") {        
1.31    ! paf        42:                if(GdomeNode* currentNode=gdome_n_firstChild(selfNode, &exc)) {
        !            43:                        VHash* result=new VHash;
1.12      paf        44:                        int i=0;
                     45:                        do {
1.31    ! paf        46:                                result->hash().put(
        !            47:                                        StringBody::Format(i++), 
        !            48:                                        new VXnode(fcharsets, currentNode));
1.12      paf        49:                        } while(currentNode=gdome_n_nextSibling(currentNode, &exc));
1.3       parser     50:                        return result;
1.12      paf        51:                }
1.25      paf        52:                return 0;
1.21      paf        53:        } else if(aname=="firstChild") {
1.31    ! paf        54:                if(GdomeNode* result_node=gdome_n_firstChild(selfNode, &exc))
        !            55:                        return new VXnode(fcharsets, result_node);
1.25      paf        56:                return 0;
1.21      paf        57:        } else if(aname=="lastChild") {
1.31    ! paf        58:                if(GdomeNode* result_node=gdome_n_lastChild(selfNode, &exc))
        !            59:                        return new VXnode(fcharsets, result_node);
1.25      paf        60:                return 0;
1.21      paf        61:        } else if(aname=="previousSibling") {
1.31    ! paf        62:                if(GdomeNode* result_node=gdome_n_previousSibling(selfNode, &exc))
        !            63:                        return new VXnode(fcharsets, result_node);
1.25      paf        64:                return 0;
1.21      paf        65:        } else if(aname=="nextSibling") {
1.31    ! paf        66:                if(GdomeNode* result_node=gdome_n_nextSibling(selfNode, &exc))
        !            67:                        return new VXnode(fcharsets, result_node);
1.25      paf        68:                return 0;
1.21      paf        69:        } else if(aname=="ownerDocument") {
1.12      paf        70:                if(GdomeDocument *document=gdome_n_ownerDocument(selfNode, &exc))
1.31    ! paf        71:                        return new VXdoc(fcharsets, document);
1.25      paf        72:                return 0;
1.13      paf        73:        } else switch(gdome_n_nodeType(selfNode, &exc)) {
                     74:                case GDOME_ELEMENT_NODE: 
1.21      paf        75:                        if(aname=="attributes") {
1.13      paf        76:                                if(GdomeNamedNodeMap *attributes=gdome_n_attributes(selfNode, &exc)) {
1.31    ! paf        77:                                        VHash* result=new VHash;
1.13      paf        78:                                        gulong length=gdome_nnm_length(attributes, &exc);
                     79:                                        for(gulong i=0; i<length; i++) {
1.31    ! paf        80:                                                GdomeNode* attr_node=gdome_nnm_item(attributes, i, &exc);
        !            81:                                                result->hash().put(
        !            82:                                                        fcharsets->source().transcode(gdome_n_nodeName(attr_node, &exc)), 
        !            83:                                                        new VXnode(fcharsets, attr_node));
1.3       parser     84:                                        }
1.12      paf        85:                                        return result;
                     86:                                }
1.25      paf        87:                                return 0;
1.21      paf        88:                        } else if(aname=="tagName") {
1.31    ! paf        89:                                return new VString(fcharsets->source().transcode(gdome_el_tagName(GDOME_EL(selfNode), &exc)));
1.2       parser     90:                        }
1.12      paf        91:                        break;
1.13      paf        92:                case GDOME_ATTRIBUTE_NODE: 
1.21      paf        93:                        if(aname=="specified")
1.31    ! paf        94:                                return new VBool(gdome_a_specified(GDOME_A(selfNode), &exc)!=0);
1.27      paf        95:                        else if(aname=="name")
1.31    ! paf        96:                                return new VString(fcharsets->source().transcode(gdome_a_name(GDOME_A(selfNode), &exc)));
1.21      paf        97:                        else if(aname=="value")
1.31    ! paf        98:                                return new VString(fcharsets->source().transcode(gdome_a_value(GDOME_A(selfNode), &exc)));
1.12      paf        99:                        break;
                    100: /*
1.13      paf       101:                case GDOME_COMMENT_NODE: 
1.12      paf       102:                        substringData(unsigned int offset, unsigned int count)
                    103: */
1.13      paf       104:                case GDOME_PROCESSING_INSTRUCTION_NODE: 
1.21      paf       105:                        if(aname=="target")
1.31    ! paf       106:                                return new VString(fcharsets->source().transcode(gdome_pi_target(GDOME_PI(selfNode), &exc)));
1.21      paf       107:                        else if(aname=="data")
1.31    ! paf       108:                                return new VString(fcharsets->source().transcode(gdome_pi_data(GDOME_PI(selfNode), &exc)));
1.12      paf       109:                        break;
1.13      paf       110:                case GDOME_DOCUMENT_TYPE_NODE: 
1.12      paf       111:                        {
1.13      paf       112:                                GdomeDocumentType *doctype=GDOME_DT(selfNode);
1.26      paf       113:                                if(aname=="name") {
1.21      paf       114:                                        // readonly attribute DOMString aname;
                    115:                                        // The aname of DTD; i.e., the aname immediately following 
1.12      paf       116:                                        // the DOCTYPE keyword in an XML source document.
1.31    ! paf       117:                                        return new VString(fcharsets->source().transcode(gdome_dt_name(doctype, &exc)));
1.1       parser    118:                                }
1.12      paf       119:                                /*
                    120:                                readonly attribute NamedNodeMap entities;
                    121:                                readonly attribute NamedNodeMap notations;
                    122:                                virtual const XalanNamedNodeMap* getEntities () const = 0 
                    123:                                This function returns a NamedNodeMap containing the general entities, both external and internal, declared in the DTD. More...
                    124:                                virtual const XalanNamedNodeMap* getNotations () const = 0 
                    125:                                This function returns a named selfNode map containing an entry for each notation declared in a document's DTD. More...
                    126:                                */
                    127:                        }
                    128:                        break;
1.13      paf       129:                case GDOME_NOTATION_NODE:
1.12      paf       130:                        {
1.13      paf       131:                                GdomeNotation *notation=GDOME_NOT(selfNode);
1.21      paf       132:                                if(aname=="publicId") {
1.12      paf       133:                                        // readonly attribute DOMString publicId;
1.31    ! paf       134:                                        return new VString(fcharsets->source().transcode(gdome_not_publicId(notation, &exc)));
1.21      paf       135:                                } else if(aname=="systemId") {
1.12      paf       136:                                        // readonly attribute DOMString systemId;
1.31    ! paf       137:                                        return new VString(fcharsets->source().transcode(gdome_not_systemId(notation, &exc)));
1.4       parser    138:                                }
1.12      paf       139:                        }
                    140:                        break;
                    141:        }
1.3       parser    142:                
1.24      paf       143:        bark("%s field not found", 0, &aname); return 0;
1.1       parser    144: }
                    145: 
                    146: #endif

E-mail: