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

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

E-mail: