00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "schemaparser/SchemaParser.h"
00021
00022 #ifdef LOGGING
00023 using namespace std;
00024 namespace Schema {
00025 void SchemaParser::print(ostream & out)
00026 {
00027 typesTable_.printTypes(out);
00028 }
00029
00030
00031 void TypesTable::printTypes(ostream & out)
00032 {
00033 out << numTypes << endl;
00034 for (int i = 0; i < numTypes; i++)
00035 {
00036 typesArray[i]->print(out);
00037 out << XmlUtils::blk;
00038 }
00039 }
00040
00041 void
00042 ComplexType::print (ostream & out)
00043 {
00044 out << getName() << XmlUtils::dbsp << getTypeId() << XmlUtils::dbsp << isSimple () << endl;
00045 out << getContentModel() << XmlUtils::dbsp;
00046 if (getContentModel() == Schema::Simple)
00047 out << simpleContentTypeId_;
00048 out << endl;
00049
00050 out << attList_.size()<< endl;
00051 list < Attribute >::iterator pAttr = attList_.begin ();
00052 while (pAttr != attList_.end ()){
00053 out << *pAttr;
00054 pAttr++;
00055 }
00056
00057 if(getContentModel() != Schema::Simple && cm_ ){
00058
00059 out << cm_->getNumParticles()<< endl;
00060 ContentModel::ContentsIterator cit_b=cm_->begin();
00061 ContentModel::ContentsIterator cit_e=cm_->end();
00062 ContentModel::ContentsIterator ci=cit_b;
00063
00064 for (ci=cit_b;ci!=cit_e;ci++){
00065 if(ci->second==ContentModel::Particle){
00066 out<<*(ci->first.e);
00067 }
00068 }
00069 }
00070 }
00071
00072
00073 ostream & operator << (ostream & stream, Attribute & a)
00074 {
00075 stream << "@" << a.getName () << XmlUtils::dbsp << a.getType () << XmlUtils::dbsp << XmlUtils::dbsp;
00076 stream << a.isRequired () << XmlUtils::dbsp;
00077
00078 if (!(a.defaultVal ()).empty ())
00079 {
00080 stream << 1 << XmlUtils::dbsp << a.defaultVal ();
00081 } else
00082 stream << 0 << XmlUtils::dbsp;
00083 if (!(a.fixedVal ()).empty ())
00084 {
00085 stream << 1 << XmlUtils::dbsp << a.fixedVal ();
00086 } else
00087 stream << 0 << XmlUtils::dbsp;
00088 stream << endl;
00089
00090 return stream;
00091
00092 }
00093
00094
00095 ostream & operator << (ostream & stream, Element & e)
00096 {
00097 stream << e.getName () << XmlUtils::dbsp << e.getType () << XmlUtils::dbsp << XmlUtils::dbsp;
00098 stream << e.getMin () << XmlUtils::dbsp << e.getMax () << XmlUtils::dbsp;
00099 if (!(e.defaultVal ()).empty ())
00100 {
00101 stream << 1 << XmlUtils::dbsp << e.defaultVal ();
00102 } else
00103 stream << 0 << XmlUtils::dbsp;
00104 if (!(e.fixedVal ()).empty ())
00105 {
00106 stream << 1 << XmlUtils::dbsp << e.fixedVal ();
00107 } else
00108 stream << 0 << XmlUtils::dbsp;
00109
00110 stream << endl;
00111
00112 return stream;
00113 }
00114
00115 void
00116 SimpleType::print (ostream & out)
00117 {
00118
00119 out << getName() << XmlUtils::dbsp << getTypeId() << XmlUtils::dbsp << isSimple () << endl;
00120 out << getBaseTypeId() << endl;
00121 out << getBaseDerivation() << XmlUtils::dbsp;
00122 out << facetId_.size() << endl;
00123 for (size_t j = 0; j < facetId_.size(); j++)
00124 {
00125 out << facetId_[j] << XmlUtils::dbsp;
00126 if (facetId_[j] == ENUM)
00127 {
00128 out << facetValue_.numEnums << XmlUtils::dbsp;
00129 for (list < string >::iterator pEnums = enumValues_.begin ();
00130 pEnums != enumValues_.end (); pEnums++)
00131 out << *pEnums << XmlUtils::dbsp;
00132 }
00133 out << endl;
00134 }
00135 out << endl;
00136
00137 }
00138 }
00139 #endif