Annotation of parser3/src/types/pa_vxnode.C, revision 1.1
1.1 ! parser 1: /** @node
! 2: Parser: @b dnode parser type.
! 3:
! 4: Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com)
! 5: Author: Alexander Petrosyan <paf@design.ru>(http://design.ru/paf)
! 6:
! 7: $Id: pa_vdnode.C,v 1.8 2001/09/26 10:32:26 parser Exp $
! 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: #include <util/XMLString.hpp>
! 19: #include <util/PlatformUtils.hpp>
! 20: #include <util/TransService.hpp>
! 21: #include <XalanDOM/XalanNamedNodeMap.hpp>
! 22: #include <XalanDOM/XalanAttr.hpp>
! 23: #include <XalanDOM/XalanProcessingInstruction.hpp>
! 24:
! 25: /*
! 26: void VXnode_cleanup(void *vxnode) {
! 27: //_asm int 3;
! 28: static_cast<VXnode *>(vxnode)->cleanup();
! 29: }
! 30: */
! 31:
! 32: /// VXnode: $CLASS,$method
! 33: Value *VXnode::get_element(const String& aname) {
! 34: // $CLASS,$method
! 35: if(Value *result=VStateless_object::get_element(aname))
! 36: return result;
! 37:
! 38: // fields
! 39:
! 40: XalanNode *self=&get_node(pool(), &aname);
! 41:
! 42: if(aname=="name") {
! 43: return NEW VString(transcode(self->getNodeName()));
! 44: } else if(aname=="value") {
! 45: return NEW VString(transcode(self->getNodeValue()));
! 46: } else if(aname=="type") {
! 47: static const char *type_names[]={
! 48: "unknown", "element", "attribute", "text", "cdata", "entityref",
! 49: "entity", "pi", "comment", "document", "doctype", "docfragment",
! 50: "notation"
! 51: };
! 52: XalanNode::NodeType node_type=self->getNodeType();
! 53: if(node_type > sizeof(type_names)/sizeof(type_names[0]))
! 54: node_type=XalanNode::UNKNOWN_NODE;
! 55: return NEW VString(*NEW String(pool(), type_names[node_type]));
! 56: } else if(aname=="parent") {
! 57: if(XalanNode *result_node=self->getParentNode())
! 58: return NEW VXnode(pool(), result_node);
! 59: } else if(aname=="first-child") {
! 60: if(XalanNode *result_node=self->getFirstChild())
! 61: return NEW VXnode(pool(), result_node);
! 62: } else if(aname=="last-child") {
! 63: if(XalanNode *result_node=self->getLastChild())
! 64: return NEW VXnode(pool(), result_node);
! 65: } else if(aname=="previous-sibling") {
! 66: if(XalanNode *result_node=self->getPreviousSibling())
! 67: return NEW VXnode(pool(), result_node);
! 68: } else if(aname=="next-sibling") {
! 69: if(XalanNode *result_node=self->getNextSibling())
! 70: return NEW VXnode(pool(), result_node);
! 71: } else if(aname=="owner") {
! 72: if(XalanDocument *document=self->getOwnerDocument())
! 73: return NEW VXdoc(pool(), document);
! 74: } else switch(self->getNodeType()) {
! 75: case XalanNode::ELEMENT_NODE:
! 76: if(aname=="attributes") {
! 77: if(const XalanNamedNodeMap *attributes=self->getAttributes()) {
! 78: VHash *result=NEW VHash(pool());
! 79: for(int i=0; i<attributes->getLength(); i++) {
! 80: XalanNode *attr_node=attributes->item(i);
! 81: result->hash().put(
! 82: transcode(attr_node->getNodeName()),
! 83: NEW VXnode(pool(), attr_node));
! 84: }
! 85: return result;
! 86: }
! 87: }
! 88: break;
! 89: case XalanNode::ATTRIBUTE_NODE:
! 90: if(aname=="specified")
! 91: return NEW VBool(pool(), static_cast<XalanAttr *>(self)->getSpecified());
! 92: break;
! 93: /*
! 94: case XalanNode::TEXT_NODE:
! 95: case XalanNode::CDATA_SECTION_NODE:
! 96: case XalanNode::COMMENT_NODE:
! 97: substringData(unsigned int offset, unsigned int count)
! 98: */
! 99: //case XalanNode::ENTITY_REFERENCE_NODE:
! 100: //case XalanNode::ENTITY_NODE:
! 101: case XalanNode::PROCESSING_INSTRUCTION_NODE:
! 102: if(aname=="target")
! 103: return NEW VString(transcode(static_cast<XalanProcessingInstruction *>(self)->getTarget()));
! 104: break;
! 105: /*
! 106: case XalanNode::DOCUMENT_NODE:
! 107: virtual XalanDocumentType* getDoctype () const = 0
! 108: Get Document Type Declaration (see DocumentType) associated with this document. More...
! 109: virtual XalanDOMImplementation* getImplementation () const = 0
! 110: Return the DOMImplementation object that handles this document.
! 111: virtual XalanElement* getDocumentElement () const = 0
! 112: Return a reference to the root element of the document.
! 113: virtual XalanNodeList* getElementsByTagName (const XalanDOMString& tagname) const = 0
! 114: Returns a NodeList of all the elements with a given tag name. More...
! 115: */
! 116: /*
! 117: case XalanNode::DOCUMENT_TYPE_NODE:
! 118: virtual const XalanDOMString& getName () const = 0
! 119: The name of DTD; i.e., the name immediately following the DOCTYPE keyword in an XML source document.
! 120: virtual const XalanNamedNodeMap* getEntities () const = 0
! 121: This function returns a NamedNodeMap containing the general entities, both external and internal, declared in the DTD. More...
! 122: virtual const XalanNamedNodeMap* getNotations () const = 0
! 123: This function returns a named node map containing an entry for each notation declared in a document's DTD. More...*/
! 124: // case XalanNode::DOCUMENT_FRAGMENT_NODE:
! 125: // case XalanNode::NOTATION_NODE;
! 126: }
! 127:
! 128:
! 129: return 0;
! 130: }
! 131:
! 132: #endif
E-mail: