62 string elemName = xpp->
getName();
74 error(
"Fatal error ,container's type is not same as the validated type",xpp);
106 t->sParser_ = sParser_;
113 if (sParser_->
getType(typeId) == 0
140 if (xpp->
getName() != elemName)
141 error(
"Syntax error "+elemName,xpp);
144 error(
"Expected a closing tag for " + elemName,xpp);
173 for (
int i = 0; i < attcnt; i++) {
178 if (!attNsp.empty() && attNsp != sParser_->
getNamespace())
195 error(
"Unknown attribute \"" + attName +
"\"",xpp);
201 checkAttributeOccurence(ct,xpp);
203 checkAttributeOccurence(bt,xpp);
224 if (xpp->
getName() != elemName)
225 error(
"Syntax error",xpp);
228 error(
"Expected a closing tag for " + elemName,xpp);
237 validateContentModel(xpp,
244 validateContentModel(xpp,
261 if (!ipTc && t)
delete t;
277 const string & elemName,
289 for (ci=cit_b;ci!=cit_e;ci++){
291 ci->first.e->nOccurrences=0;
312 if (xpp->
getName() == elemName)
319 if(!findElement(cit_b,cit_e,xpp->
getName(),ci))
320 error(
"Could not find element " +xpp->
getName()+
" in "+elemName,xpp);
321 ci->first.e->nOccurrences++;
323 validate(xpp, ci->first.e->getType(),
332 for (ci=cit_b;ci!=cit_e;ci++){
334 (ci->first.e->nOccurrences<ci->first.e->getMin()||
335 ci->first.e->nOccurrences>ci->first.e->getMax()))
336 error(ci->first.e->getName()+
" did not meet occurrence constraints",xpp);
350 if (xpp->
getName() == elemName)
371 validateContentModel(xpp,ci->first.c,
373 elemName,
true,btCnt);
380 findElement(ci,cit_e,xpp->
getName(), ci)){
382 ci->first.e->nOccurrences++;
383 validate(xpp,ci->first.e->getType(),
394 error(
"Could not find element " +xpp->
getName()+
" in "+elemName,xpp);
404 for (ci=cit_b;ci!=cit_e;ci++){
406 (ci->first.e->nOccurrences<ci->first.e->getMin()||
407 ci->first.e->nOccurrences>ci->first.e->getMax()))
408 error(ci->first.e->getName()+
" did not meet occurrence constraints",xpp);
419 if(findElement(ci,cit_e,xpp->
getName(), ci)) {
421 std::string choiceElem = xpp->
getName();
424 ci->first.e->nOccurrences++;
425 validate(xpp, ci->first.e->getType(),
428 }
while(xpp->
getName() == choiceElem);
439 validateContentModel(xpp,ci->first.c,
441 elemName,
true,btCnt);
447 validateContentModel(xpp,ci->first.c,
449 elemName,
true,btCnt);
454 error(
"Could not find element " +xpp->
getName()+
" in "+elemName,xpp);
465 (ci->first.e->nOccurrences<ci->first.e->getMin()||
466 ci->first.e->nOccurrences>ci->first.e->getMax()))
467 error(ci->first.e->getName()+
"did not meet occurrence constraints",xpp);
475 for (ci=cit_b;ci!=cit_e;ci++){
478 ci->first.e->nOccurrences=0;
514 std::string val = *((std::string*)value);
515 ipTc->
setValue(val,validateListOrUnion(st,val,xpp));
523 int x= *((
int*)value);
535 char c= *((
char*)value);
541 float f = *((
float*)value);
555 double db = *((
double*)value);
561 long l = *((
long*)value);
568 unsigned long ul= *((
unsigned long*)value);
574 bool b = *((
bool*)value);
587 std::string val = *((std::string* )value);
635 return validate(val,contentType,ipTc,xpp);
649 extractSimpleType(val, basetype, ipTc, st, xpp);
673 SchemaValidator::extractSimpleType(
const std::string & val,
682 ipTc->
setValue(val,validateListOrUnion(st,val,xpp));
686 istringstream istr(val);
781 SchemaValidator::validateListOrUnion(
const SimpleType* st,
782 const std::string &val,
789 while(s < val.length()){
790 while(val[s]==
' ')s++;
791 std::string t = val.substr(s,val.find(
' ',s)-s);
801 std::list<int>::const_iterator it= st->
unionTypes()->begin();
836 std::cout<<
"Looking for "<< name<<
" found "<<ci->first.e->getName()<<std::endl;
838 if(ci->first.e->getName()==name ||
839 ci->first.e->getName() ==
"*")
849 void SchemaValidator::error(
const std::string& mesg,
XmlPullParser* xpp)
863 SchemaValidator::checkAttributeOccurence(
const ComplexType* ct ,
880 error(
"Required attribute \"" + at->
getName() +
881 "\" missing or empty",xpp);
909 return instance1(tag,type_id);
913 SchemaValidator::instance1(
const std::string &tag,
918 static bool first =
false;
936 xmlStream_->
text(
"");
957 xmlStream_->
text(
"");
966 xmlStream_->
endTag(nsp,tag);
991 for (ci=cit_b;ci!=cit_e;ci++){
994 ci->first.e->getMax() > 0){
999 if (!ci->first.e->getTypeNamespace().empty() &&
1000 sParser_->
isImported(ci->first.e->getTypeNamespace()) &&
1001 sParser_->
getNamespace() != ci->first.e->getTypeNamespace()) {
1009 instance1(ci->first.e->getName(),t);
1010 sParser_ = s1Parser;
1015 instanceCM(ci->first.c);
1021 instanceCM(ci->first.g->getContents());
std::string getPrefix(void) const
std::string getAttributeNamespace(int index)
std::string getAttributeName(int index)
int getNumAttributes() const
const std::list< int > * unionTypes() const
void setNamespace(std::string uri)
XmlSerializer & attribute(std::string nsp, std::string name, std::string value)
bool instance(const std::string &tag, Schema::Type type_id)
TypeContainer * getChildContainer(std::string elemName, bool create=false)
std::string getName() const
const std::string SchemaInstaceUri
bool isValueValid() const
void startDocument(std::string encoding, bool standalone)
std::string getNamespace(std::string prefix)
const SchemaParser * schemaParser() const
void setValue(const std::string &sValue, bool valid=true)
XmlSerializer & endTag(std::string nsp, std::string name)
virtual bool isSimple() const =0
const XSDType * getType(const Qname &type, bool checkImports=true)
std::string getAttributeValue(int index)
std::string getNamespace(void) const
int getBasicContentType(int typeId) const
XmlSerializer & text(std::string txt)
const Attribute * getAttribute(const std::string &name) const
bool isImported(const std::string &ns) const
XmlSerializer & startTag(std::string nsp, std::string name)
bool isValidFloat(float val) const
Schema::Compositor getCompositor() const
int getContentType() const
void setPrefix(std::string prefix, std::string nsp)
void setValAsString(const std::string &v)
TypeContainer * getAttributeContainer(std::string attName, bool create=false)
std::list< ContentHolder >::iterator ContentsIterator
const SchemaParser * getImportedSchemaParser(const std::string &ns) const
ContentModel * getContents() const
bool isValidInt(int val) const
Schema::ContentModelType getContentModel() const
TypeContainer * getBaseTypeContainer(bool create=false)
int getBaseTypeId() const
bool isBasicType(int sType) const
bool isValidString(std::string val) const
TypeContainer * validate(XmlPullParser *xpp, int typeId, TypeContainer *ipTc=0)
std::string getNamespace() const