00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "schemaparser/ComplexType.h"
00023
00024 namespace Schema {
00025
00026 ComplexType::ComplexType(const std::string & ns)
00027 :XSDType(ns),
00028 simpleContentTypeId_ (0),
00029 cm_(0),
00030 fwdElemRef_(false),
00031 fwdAttrRef_(false)
00032 {
00033
00034 setContentModel(Schema::Complex);
00035 }
00036
00037 void
00038 ComplexType::addAttribute(const Attribute& a,
00039 bool ref)
00040 {
00041 fwdAttrRef_=ref;
00042
00043 Attribute *at= (Attribute *)getAttribute(a.getName());
00044 if(at){
00045 *at=a;
00046 }else{
00047 attList_.push_back(a);
00048 }
00049 }
00050
00051
00052 void
00053 ComplexType::addAttributeGroupName(const Qname & qn)
00054 {
00055
00056
00057
00058 }
00059
00060 void
00061 ComplexType::matchElementRef(const std::string & name, Element & e)
00062 {
00063 if(cm_) {
00064 cm_->matchforwardRef(name,e);
00065 }
00066 }
00067
00068 void
00069 ComplexType::matchAttributeRef(const std::string & nam,
00070 Attribute & a)
00071 {
00072 if (fwdAttrRef_) {
00073 Attribute *at = (Attribute*)getAttribute(nam);
00074 if (at)
00075 *at = a;
00076 }
00077 }
00078
00079 const Attribute *
00080 ComplexType::getAttribute(const std::string & nam) const
00081 {
00082 std::list < Attribute >::const_iterator pAttr = attList_.begin();
00083 while (pAttr != attList_.end())
00084 {
00085 if (pAttr->getName() == nam)
00086 return &(*pAttr);
00087 pAttr++;
00088 }
00089 return 0;
00090 }
00091
00092
00093 void ComplexType::error(std::string msg) const
00094 {
00095 msg+="Complex Type "+ getName() +msg;
00096 SchemaParserException spe(msg);
00097 throw spe;
00098 return;
00099 }
00100
00101 const Attribute *
00102 ComplexType::getAttribute(int index) const
00103 {
00104
00105 int i=0;
00106 for (std::list<Attribute>::const_iterator ali=attList_.begin();
00107 ali!=attList_.end();ali++,i++) {
00108 if(i==index)
00109 return &(*ali);
00110 }
00111 return 0;
00112
00113 }
00114 }