Annotation of parser3/src/types/pa_vxdoc.C, revision 1.32
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.32 ! misha 10: static const char * const IDENT_VXDOC="$Date: 2005/12/16 14:48:22 $";
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.32 ! misha 34: Value* VXdoc::as(const char* atype, bool ) {
! 35: return atype && ( strcmp(VXdoc::type(), atype)==0 || strcmp(VXnode::type(), atype)==0 )?this:0;
1.18 paf 36: }
37:
1.2 parser 38: /// VXdoc: $CLASS,$method
1.24 paf 39: Value* VXdoc::get_element(const String& aname, Value& aself, bool looking_up) {
1.28 paf 40: if(aname==SEARCH_NAMESPACES_NAME) {
41: return &search_namespaces;
42: }
43:
1.13 paf 44: // up
1.21 paf 45: try {
1.24 paf 46: return VXnode::get_element(aname, aself, looking_up);
47: } catch(Exception) {
48: // ignore bad node elements, they can be valid here...
49:
50: // fields
1.31 paf 51: xmlDoc& xmldoc=get_xmldoc();
1.24 paf 52:
53: if(aname=="doctype") {
54: // readonly attribute DocumentType doctype;
1.31 paf 55: if(xmlNode* node=(xmlNode*)xmldoc.intSubset)
56: return &wrap(*node);
57: else
58: return 0;
1.24 paf 59: } else if(aname=="implementation") {
60: // readonly attribute DOMImplementation implementation;
61: return 0;
62: } else if(aname=="documentElement") {
63: // readonly attribute Element documentElement;
1.31 paf 64: xmlNode* rootElement=xmlDocGetRootElement(&xmldoc);
65: assert(rootElement);
66: return &wrap(*rootElement);
1.24 paf 67: }
1.31 paf 68:
1.25 paf 69: return bark("%s field not found", &aname);
1.24 paf 70: }
1.2 parser 71: }
72:
1.1 parser 73: #endif
E-mail: