00001
00002
00003 #include "ACEXML/common/SAXExceptions.h"
00004 #include "ACEXML/parser/debug_validator/Debug_Element_Builder.h"
00005
00006 ACEXML_Debug_Element_Builder::ACEXML_Debug_Element_Builder ()
00007 : type_ (UNDEFINED),
00008 root_ (0)
00009 {
00010 }
00011
00012 ACEXML_Debug_Element_Builder::~ACEXML_Debug_Element_Builder ()
00013 {
00014 delete this->root_;
00015 }
00016
00017 int
00018 ACEXML_Debug_Element_Builder::setElementName (const ACEXML_Char *,
00019 const ACEXML_Char *,
00020 const ACEXML_Char *qName ACEXML_ENV_ARG_DECL_NOT_USED)
00021 ACE_THROW_SPEC ((ACEXML_SAXException))
00022 {
00023 this->element_.set (qName, 0);
00024 return 0;
00025 }
00026
00027 int
00028 ACEXML_Debug_Element_Builder::setContentType (CONTENT_TYPE type ACEXML_ENV_ARG_DECL)
00029 ACE_THROW_SPEC ((ACEXML_SAXException))
00030 {
00031 if (this->type_ == UNDEFINED)
00032 {
00033 this->type_ = type;
00034 return 0;
00035 }
00036
00037 ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("Element type redefinition in Debug_Validator.")), -1);
00038 }
00039
00040 int
00041 ACEXML_Debug_Element_Builder::insertMixedElement (const ACEXML_Char *,
00042 const ACEXML_Char *,
00043 const ACEXML_Char *qName ACEXML_ENV_ARG_DECL_NOT_USED)
00044 ACE_THROW_SPEC ((ACEXML_SAXException))
00045 {
00046 ACEXML_Element_Tree_Name_Node *node;
00047
00048
00049 ACE_NEW_RETURN (node,
00050 ACEXML_Element_Tree_Name_Node (qName),
00051 -1);
00052
00053 if (this->root_ == 0)
00054
00055 ACE_NEW_RETURN (this->root_,
00056 ACEXML_Element_Tree_List_Node (),
00057 -1);
00058
00059
00060 return this->root_->insert (node);
00061 }
00062
00063 int
00064 ACEXML_Debug_Element_Builder::startChildGroup ()
00065 {
00066 ACEXML_Element_Tree_List_Node *lnode;
00067
00068 ACE_NEW_RETURN (lnode,
00069 ACEXML_Element_Tree_List_Node (),
00070 -1);
00071
00072 if (this->root_ == 0)
00073 {
00074 this->root_ = lnode;
00075 }
00076 else
00077 {
00078
00079 this->root_->insert (lnode);
00080 }
00081
00082 this->active_list_.push (lnode);
00083 return 0;
00084 }
00085
00086 int
00087 ACEXML_Debug_Element_Builder::endChildGroup (CARDINALITY ACEXML_ENV_ARG_DECL_NOT_USED)
00088 {
00089 this->active_list_.pop ();
00090 return 0;
00091 }
00092
00093 int
00094 ACEXML_Debug_Element_Builder::setChoice ()
00095 {
00096 this->active_list_.top ()->set (ACEXML_Element_Tree_List_Node::CHOICE);
00097 return 0;
00098 }
00099
00100 int
00101 ACEXML_Debug_Element_Builder::setSequence ()
00102 {
00103 this->active_list_.top ()->set (ACEXML_Element_Tree_List_Node::SEQUENCE);
00104 return 0;
00105 }
00106
00107 int
00108 ACEXML_Debug_Element_Builder::insertElement (const ACEXML_Char *,
00109 const ACEXML_Char *,
00110 const ACEXML_Char *qName ACEXML_ENV_ARG_DECL_NOT_USED)
00111 ACE_THROW_SPEC ((ACEXML_SAXException))
00112 {
00113 ACEXML_Element_Tree_Name_Node *node;
00114
00115
00116 ACE_NEW_RETURN (node,
00117 ACEXML_Element_Tree_Name_Node (qName),
00118 -1);
00119
00120 return this->active_list_.top ()->insert (node);
00121 }
00122
00123 void
00124 ACEXML_Debug_Element_Builder::dump ()
00125 {
00126 cout << "<!ELEMENT " << this->element_;
00127
00128
00129 switch (this->type_)
00130 {
00131 case EMPTY:
00132 cout << "EMPTY";
00133 break;
00134 case ANY:
00135 cout << "ANY";
00136 break;
00137 case MIXED:
00138 case CHILDREN:
00139
00140 cout << "*** not implemented ***";
00141 break;
00142 default:
00143 cout << "*** Unidentified element type ***";
00144 break;
00145 }
00146
00147 cout << ">" << endl;
00148 }