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