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

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.35    ! misha      10: static const char * const IDENT_VXDOC="$Date: 2007/02/09 18:06:37 $";
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.32      misha      35: Value* VXdoc::as(const char* atype, bool ) {
                     36:        return atype && ( strcmp(VXdoc::type(), atype)==0 || strcmp(VXnode::type(), atype)==0 )?this:0;
1.33      misha      37: 
                     38:        /*
                     39:        if(Value* result=Value::as(atype, looking_up))
                     40:                return result;
                     41:        else
                     42:                return VXnode::as(atype, looking_up);
                     43:        */
1.18      paf        44: }
                     45: 
1.34      misha      46: /// VXdoc: true         
1.35    ! misha      47: Value& VXdoc::as_expr_result(bool /*return_string_as_is=false*/) { return VBool::get(as_bool()); }
1.34      misha      48: 
1.33      misha      49: 
1.2       parser     50: /// VXdoc: $CLASS,$method
1.24      paf        51: Value* VXdoc::get_element(const String& aname, Value& aself, bool looking_up) { 
1.28      paf        52:        if(aname==SEARCH_NAMESPACES_NAME) {
                     53:                return &search_namespaces;
                     54:        }
                     55: 
1.13      paf        56:        // up
1.21      paf        57:        try {
1.24      paf        58:                return VXnode::get_element(aname, aself, looking_up);
                     59:        } catch(Exception) { 
                     60:                // ignore bad node elements, they can be valid here...
                     61: 
                     62:                // fields
1.31      paf        63:                xmlDoc& xmldoc=get_xmldoc();
1.24      paf        64: 
                     65:                if(aname=="doctype") {
                     66:                        // readonly attribute DocumentType doctype;
1.31      paf        67:                        if(xmlNode* node=(xmlNode*)xmldoc.intSubset)
                     68:                                return &wrap(*node);
                     69:                        else
                     70:                                return 0;
1.24      paf        71:                } else if(aname=="implementation") {
                     72:                        // readonly attribute DOMImplementation implementation;
                     73:                        return 0;
                     74:                } else if(aname=="documentElement") {
                     75:                        // readonly attribute Element documentElement;
1.31      paf        76:                        xmlNode* rootElement=xmlDocGetRootElement(&xmldoc);
                     77:                        assert(rootElement);
                     78:                        return &wrap(*rootElement);
1.24      paf        79:                }       
1.31      paf        80: 
1.25      paf        81:                return bark("%s field not found", &aname);
1.24      paf        82:        }
1.2       parser     83: }
                     84: 
1.1       parser     85: #endif

E-mail: