00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
#ifndef OMF_XMIREADER20_HPP
00026
#define OMF_XMIREADER20_HPP
00027
00028
00029
#include <string>
00030
#include <list>
00031
#include <map>
00032
00033
00034
#include <libxml/tree.h>
00035
00036
namespace OMF
00037 {
00038
00039
class ModelObject;
00040
class Property;
00041
class Association;
00042
00048 class XmiReader_2_0
00049 {
00050
public:
00051
XmiReader_2_0();
00052
~XmiReader_2_0();
00053
00054
00055
void document(
Model *model, xmlDocPtr doc);
00056
00057
protected:
00058
bool isXmi(xmlNsPtr ns);
00059
bool isVersionAttr(xmlAttrPtr attr);
00060
bool isIdAttr(xmlAttrPtr attr);
00061
bool isLabelAttr(xmlAttrPtr attr);
00062
bool isUuidAttr(xmlAttrPtr attr);
00063
bool isTypeAttr(xmlAttrPtr attr);
00064
bool isIdrefAttr(xmlAttrPtr attr);
00065
bool isHrefAttr(xmlAttrPtr attr);
00066
00067
void createObject();
00068
void resolveDeferred();
00069
00070
00071
void xmi();
00072
void startAttribs();
00073
void xmiVersion();
00074
void namespaces();
00075
00076
00077
void contentElements();
00078
00079
00080
void objectAsElement();
00081
void objectTagName();
00082
void objectAttribs();
00083
void identityAttribs();
00084
void typeAttrib();
00085
void featureAttribs();
00086
void dataValueAttrib();
00087
void refValueAttrib();
00088
00089
00090
void linkAttribs();
00091
00092
00093
void objectContents();
00094
void contentElement();
00095
void dataValue();
00096
void primitiveValue();
00097
void structureValue();
00098
00099
00100
void extension();
00101
00102
00103
void classAttributes();
00104
00105
00106
void otherLinks();
00107
00108
private:
00114
struct Context
00115 {
00116 Context() :
00117 node(0),
00118 attr(0),
00119 previous(0),
00120 object(0),
00121 prop(),
00122 context(),
00123 end(
false)
00124 {}
00125
00126 xmlNodePtr node;
00127 xmlNodePtr child;
00128 xmlAttrPtr attr;
00129
00130 Context *previous;
00131
ModelObject *object;
00132
Property *prop;
00133
Property *context;
00134
00135
bool end;
00136
00137 std::string uri;
00138 std::string metaclass;
00139 std::string feature;
00140 std::string xmiId;
00141 std::string xmiUuid;
00142 std::string xmiLabel;
00143 std::string xmiType;
00144 std::string xmiIdref;
00145 std::string href;
00146 };
00147
00154
struct Deferred
00155 {
00156 Deferred() :
00157 id(),
00158 prop(0),
00159 object(0)
00160 {}
00161
00162 std::string
id;
00163
Property *prop;
00164
ModelObject *object;
00165 };
00166
00167
typedef std::map<std::string, xmlNsPtr> PrefixMap;
00168
typedef std::list<Deferred *> DeferredList;
00169
00170 xmlDocPtr _doc;
00171 xmlNodePtr _xmi;
00172 PrefixMap _prefix;
00173 DeferredList _deferred;
00174 Context *_current;
00175
Model *_model;
00176 };
00177 }
00178
00179
#endif