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

1.1       parser      1: /** @dom
                      2:        Parser: @b dom parser type.
                      3: 
1.29      paf         4:        Copyright(c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com)
1.11      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.14      paf         9: 
1.31    ! paf        10: static const char * const IDENT_VXDOC="$Date: 2005/12/16 10:15:12 $";
1.1       parser     11: 
                     12: #include "pa_vxdoc.h"
                     13: 
1.28      paf        14: // defines
                     15: 
                     16: #define SEARCH_NAMESPACES_NAME "search-namespaces"
                     17: 
1.30      paf        18: 
                     19: VXnode& VXdoc::wrap(xmlNode& anode) {
                     20:        VXnode* result;
                     21:        if((result=static_cast<VXnode*>(anode._private))) {
                     22:                assert(anode.doc==fdocument);
                     23:                return *result;
                     24:        }
                     25: 
                     26:        result=new VXnode(anode);
                     27:        anode._private=result;
                     28:        anode.doc=fdocument;
                     29: 
                     30:        return *result;
                     31: }
                     32: 
                     33: 
1.24      paf        34: Value* VXdoc::as(const char* atype, bool looking_up) {
                     35:        if(Value* result=Value::as(atype, looking_up))
1.19      paf        36:                return result;
1.18      paf        37:        else
1.19      paf        38:                return VXnode::as(atype, looking_up);
1.18      paf        39: }
                     40: 
1.2       parser     41: /// VXdoc: $CLASS,$method
1.24      paf        42: Value* VXdoc::get_element(const String& aname, Value& aself, bool looking_up) { 
1.28      paf        43:        if(aname==SEARCH_NAMESPACES_NAME) {
                     44:                return &search_namespaces;
                     45:        }
                     46: 
1.13      paf        47:        // up
1.21      paf        48:        try {
1.24      paf        49:                return VXnode::get_element(aname, aself, looking_up);
                     50:        } catch(Exception) { 
                     51:                // ignore bad node elements, they can be valid here...
                     52: 
                     53:                // fields
1.31    ! paf        54:                xmlDoc& xmldoc=get_xmldoc();
1.24      paf        55: 
                     56:                if(aname=="doctype") {
                     57:                        // readonly attribute DocumentType doctype;
1.31    ! paf        58:                        if(xmlNode* node=(xmlNode*)xmldoc.intSubset)
        !            59:                                return &wrap(*node);
        !            60:                        else
        !            61:                                return 0;
1.24      paf        62:                } else if(aname=="implementation") {
                     63:                        // readonly attribute DOMImplementation implementation;
                     64:                        return 0;
                     65:                } else if(aname=="documentElement") {
                     66:                        // readonly attribute Element documentElement;
1.31    ! paf        67:                        xmlNode* rootElement=xmlDocGetRootElement(&xmldoc);
        !            68:                        assert(rootElement);
        !            69:                        return &wrap(*rootElement);
1.24      paf        70:                }       
1.31    ! paf        71: 
1.25      paf        72:                return bark("%s field not found", &aname);
1.24      paf        73:        }
1.2       parser     74: }
                     75: 
1.1       parser     76: #endif

E-mail: