Annotation of parser3/src/types/pa_vxnode.C, revision 1.12
1.1 parser 1: /** @node
2: Parser: @b dnode parser type.
3:
4: Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com)
1.11 paf 5: Author: Alexander Petrosyan <paf@design.ru>(http://paf.design.ru)
1.1 parser 6:
1.12 ! paf 7: $Id: pa_vxnode.C,v 1.11 2001/11/05 11:46:35 paf Exp $
1.1 parser 8: */
9: #include "pa_config_includes.h"
10: #ifdef XML
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"
17:
18: void VXnode_cleanup(void *vxnode) {
19: //_asm int 3;
1.12 ! paf 20: static_cast<VXnode *>(vxnode)->~VXnode();
1.1 parser 21: }
22:
1.3 parser 23: Value *VXnode::get_element(const String& name) {
1.12 ! paf 24: // $CLASS,$method
! 25: if(Value *result=VStateless_object::get_element(name))
! 26: return result;
! 27:
! 28: // fields
! 29:
! 30: GdomeNode *selfNode=get_node(pool(), &name);
! 31: GdomeException exc;
! 32:
! 33: if(name=="nodeName") {
! 34: return NEW VString(transcode(gdome_n_nodeName(selfNode, &exc)));
! 35: } else if(name=="nodeValue") {
! 36: return NEW VString(transcode(gdome_n_nodeValue(selfNode, &exc)));
! 37: } else if(name=="nodeType") {
! 38: return NEW VInt(pool(), gdome_n_nodeType(selfNode, &exc));
! 39: } else if(name=="parentNode") {
! 40: if(XalanNode *result_node=getParentNode(selfNode, &exc))
! 41: return NEW VXnode(pool(), result_node, false);
! 42: } else if(name=="childNodes") {
! 43: if(GdomeNode *currentNode=gdome_n_firstChild(selfNode, &exc)) {
! 44: VHash *result=NEW VHash(pool());
! 45: int i=0;
! 46: do {
! 47: String& skey=*NEW String(pool());
! 48: {
! 49: char *buf=(char *)malloc(MAX_NUMBER);
! 50: snprintf(buf, MAX_NUMBER, "%d", ++i);
! 51: skey << buf;
! 52: }
! 53: result->hash(&name).put(skey, NEW VXnode(pool(), currentNode, false));
! 54: } while(currentNode=gdome_n_nextSibling(currentNode, &exc));
1.3 parser 55: return result;
1.12 ! paf 56: }
! 57: } else if(name=="firstChild") {
! 58: if(XalanNode *result_node=gdome_n_firstChild(selfNode, &exc))
! 59: return NEW VXnode(pool(), result_node, false);
! 60: } else if(name=="lastChild") {
! 61: if(XalanNode *result_node=gdome_n_lastChild(selfNode, &exc))
! 62: return NEW VXnode(pool(), result_node, false);
! 63: } else if(name=="previousSibling") {
! 64: if(XalanNode *result_node=gdome_n_previousSibling(selfNode, &exc))
! 65: return NEW VXnode(pool(), result_node, false);
! 66: } else if(name=="nextSibling") {
! 67: if(XalanNode *result_node=gdome_n_nextSibling(selfNode, &exc))
! 68: return NEW VXnode(pool(), result_node, false);
! 69: } else if(name=="ownerDocument") {
! 70: if(GdomeDocument *document=gdome_n_ownerDocument(selfNode, &exc))
! 71: return NEW VXdoc(pool(), document);
! 72: } else switch(gdome_n_nodeType(selfNodem, &exc)) {
! 73: case XalanNode::ELEMENT_NODE:
! 74: if(name=="attributes") {
! 75: if(const GdomeNamedNodeMap *attributes=gdome_n_attributes(selfNode, &exc)) {
! 76: VHash *result=NEW VHash(pool());
! 77: for(int i=0; i<attributes->getLength(); i++) {
! 78: XalanNode *attr_node=attributes->item(i);
! 79: result->hash(0).put(
! 80: transcode(gdome_n_nodeName(attr_node, &exc)),
! 81: NEW VXnode(pool(), attr_node, false));
1.3 parser 82: }
1.12 ! paf 83: return result;
! 84: }
! 85: } else if(name=="tagName") {
! 86: return NEW VString(transcode(gdome_el_tagName((GdomeElement*)selfNode, &exc)));
1.2 parser 87: }
1.12 ! paf 88: break;
! 89: case XalanNode::ATTRIBUTE_NODE:
! 90: if(name=="specified")
! 91: return NEW VBool(pool(), gdome_a_specified((GdomeAttr *)selfNode, &exc));
! 92: break;
! 93: /*
! 94: case XalanNode::COMMENT_NODE:
! 95: substringData(unsigned int offset, unsigned int count)
! 96: */
! 97: case XalanNode::PROCESSING_INSTRUCTION_NODE:
! 98: if(name=="target")
! 99: return NEW VString(transcode(gdome_pi_target((GdomeProcessingInstruction*)selfNode)));
! 100: break;
! 101: case XalanNode::DOCUMENT_TYPE_NODE:
! 102: {
! 103: GdomeDocumentType *doctype=(GdomeDocumentType*)selfNode;
! 104: if(name=="name") {
! 105: // readonly attribute DOMString name;
! 106: // The name of DTD; i.e., the name immediately following
! 107: // the DOCTYPE keyword in an XML source document.
! 108: return NEW VString(transcode(gdome_dt_name(doctype, &exc)));
1.1 parser 109: }
1.12 ! paf 110: /*
! 111: readonly attribute NamedNodeMap entities;
! 112: readonly attribute NamedNodeMap notations;
! 113: virtual const XalanNamedNodeMap* getEntities () const = 0
! 114: This function returns a NamedNodeMap containing the general entities, both external and internal, declared in the DTD. More...
! 115: virtual const XalanNamedNodeMap* getNotations () const = 0
! 116: This function returns a named selfNode map containing an entry for each notation declared in a document's DTD. More...
! 117: */
! 118: }
! 119: break;
! 120: case XalanNode::NOTATION_NODE:
! 121: {
! 122: GdomeNotation *notation=(GdomeNotation*)selfNode;
! 123: if(name=="publicId") {
! 124: // readonly attribute DOMString publicId;
! 125: return NEW VString(transcode(gdome_not_publicId(notation, &exc)));
! 126: } else if(name=="systemId") {
! 127: // readonly attribute DOMString systemId;
! 128: return NEW VString(transcode(gdome_not_systemId(notation, &exc)));
1.4 parser 129: }
1.12 ! paf 130: }
! 131: break;
! 132: }
1.3 parser 133:
1.1 parser 134: return 0;
135: }
136:
137: #endif
E-mail: