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

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

E-mail: