Fixed required attributes list

This commit is contained in:
Zane U. Ji 2012-08-06 23:27:22 +08:00
parent 9c9a141c96
commit 16b9efaf3d
1 changed files with 36 additions and 51 deletions

View File

@ -280,18 +280,16 @@ void XMLCALL XmlPromptGenerator::attlistdeclhandler (
PromptGeneratorData *d; PromptGeneratorData *d;
d = ( PromptGeneratorData * ) data; d = ( PromptGeneratorData * ) data;
std::set<std::string> attributeValues; std::set<std::string> &attributeValues = d->attributeMap[elname][attname];
if ( *att_type == '(' ) // change to exclude _known_ identifiers? if ( *att_type == '(' ) // change to exclude _known_ identifiers?
{ {
char *s, *word; const char *s, *word;
s = ( char * ) att_type; s = att_type;
do { do {
s++; s++;
while ( wxIsspace( *s ) )
s++;
word = s; word = s;
while ( *s != '|' && *s != ')' && !wxIsspace( *s ) ) while ( *s != '|' && *s != ')' )
s++; s++;
std::string currentValue ( word, s - word ); std::string currentValue ( word, s - word );
@ -299,18 +297,9 @@ void XMLCALL XmlPromptGenerator::attlistdeclhandler (
while ( *s != '|' && *s != ')') while ( *s != '|' && *s != ')')
s++; s++;
} while ( *s != ')' && *s ); } while ( *s != ')' );
} }
if ( attributeValues.empty() )
{
d->attributeMap[elname][attname].insert ( "" );
return;
}
std::set<std::string>::iterator it;
for ( it = attributeValues.begin(); it != attributeValues.end(); it++ )
d->attributeMap[elname][attname].insert ( *it );
if ( isrequired ) if ( isrequired )
{ {
d->requiredAttributeMap[elname].insert ( attname ); d->requiredAttributeMap[elname].insert ( attname );
@ -531,15 +520,13 @@ void XmlPromptGenerator::handleSchema (
} }
// fetch attributes // fetch attributes
if ( curElem.hasAttDefs() && ! ( curElem.getAttDefList().isEmpty() ) ) if ( !curElem.hasAttDefs() )
{ continue;
std::map<std::string, std::set<std::string> > attributeMap;
XMLAttDefList& attIter = curElem.getAttDefList(); XMLAttDefList& attIter = curElem.getAttDefList();
for ( unsigned int i = 0; i < attIter.getAttDefCount(); i++ ) for ( unsigned int i = 0; i < attIter.getAttDefCount(); i++ )
{ {
std::string attribute, attributeValue; std::string attribute, attributeValue;
std::set<std::string> attributeValueSet;
XMLAttDef& attr = attIter.getAttDef ( i ); XMLAttDef& attr = attIter.getAttDef ( i );
XMLAttDef::DefAttTypes ty = attr.getDefaultType(); XMLAttDef::DefAttTypes ty = attr.getDefaultType();
@ -563,13 +550,11 @@ void XmlPromptGenerator::handleSchema (
s = XMLString::transcode ( pAttr->getValue() ); s = XMLString::transcode ( pAttr->getValue() );
attributeValue = s; attributeValue = s;
XMLString::release( &s ); XMLString::release( &s );
attributeValueSet.insert ( attributeValue );
} }
attributeMap.insert ( make_pair ( attribute, attributeValueSet ) ); d->attributeMap[element][attribute].insert( attributeValue );
} if ( ty == XMLAttDef::Required || ty == XMLAttDef::Required_And_Fixed)
if ( !attributeMap.empty() ) d->requiredAttributeMap[element].insert ( attribute );
d->attributeMap.insert( make_pair ( element, attributeMap ) );
} }
} }
delete parser; delete parser;