Bug #2173060 bug with element with underscore in schemas

This commit is contained in:
Zane U. Ji 2012-08-06 19:50:48 +08:00
parent c93e94db6f
commit 865701cf62
2 changed files with 46 additions and 19 deletions

View File

@ -24,7 +24,6 @@
#include "xmlencodinghandler.h"
#include "readfile.h"
#include "replace.h"
#include "getword.h"
#include "pathresolver.h"
#undef XMLCALL
@ -462,6 +461,7 @@ void XmlPromptGenerator::handleSchema (
return;
}
char *s;
while ( elemEnum.hasMoreElements() )
{
const SchemaElementDecl& curElem = elemEnum.nextElement();
@ -472,7 +472,9 @@ void XmlPromptGenerator::handleSchema (
const QName *qnm = curElem.getElementName();
if ( qnm )
{
element = XMLString::transcode ( qnm->getRawName() ); // this includes any prefix:localname combinations
s = XMLString::transcode ( qnm->getRawName() ); // this includes any prefix:localname combinations
element = s;
XMLString::release( &s );
}
if ( element.empty() )
continue;
@ -480,23 +482,19 @@ void XmlPromptGenerator::handleSchema (
const XMLCh* fmtCntModel = curElem.getFormattedContentModel();
if ( fmtCntModel != NULL ) // tbd: this does not yet pick up prefix:localname combinations
{
size_t len;
char *s, *word;
std::string structure;
s = ( char * ) XMLString::transcode ( fmtCntModel );
s = XMLString::transcode ( fmtCntModel );
structure = s;
XMLString::release( &s );
d->elementStructureMap.insert ( make_pair ( element, structure ) );
while ( ( word = GetWord::run ( &s, &len ) ) != NULL )
}
const ContentSpecNode *spec = curElem.getContentSpec();
if ( spec != NULL )
{
std::string currentValue ( word, len );
if ( currentValue.size() )
children.insert ( currentValue );
}
}
getContent ( spec, children );
if ( !children.empty() )
d->elementMap.insert ( make_pair ( element, children ) );
}
// fetch attributes
if ( curElem.hasAttDefs() && ! ( curElem.getAttDefList().isEmpty() ) )
@ -518,7 +516,9 @@ void XmlPromptGenerator::handleSchema (
const QName *qnm = pAttr->getAttName();
if ( qnm )
{
attribute = XMLString::transcode ( qnm->getRawName() );
s = XMLString::transcode ( qnm->getRawName() );
attribute = s;
XMLString::release( &s );
}
if ( attribute.empty() )
continue;
@ -526,7 +526,9 @@ void XmlPromptGenerator::handleSchema (
// Value
if ( pAttr->getValue() )
{
attributeValue = XMLString::transcode ( pAttr->getValue() );
s = XMLString::transcode ( pAttr->getValue() );
attributeValue = s;
XMLString::release( &s );
attributeValueSet.insert ( attributeValue );
}
@ -539,3 +541,24 @@ void XmlPromptGenerator::handleSchema (
delete parser;
XMLPlatformUtils::Terminate();
}
void XmlPromptGenerator::getContent (
const ContentSpecNode *spec,
std::set<std::string> &list )
{
//if ( spec == NULL) return;
const QName *qnm = spec->getElement();
if ( qnm )
{
char *element = XMLString::transcode ( qnm->getRawName() );
if ( element != NULL )
list.insert( element );
XMLString::release( &element );
}
if ( spec->getFirst() != NULL)
getContent( spec->getFirst(), list );
if ( spec->getSecond() != NULL)
getContent( spec->getSecond(), list );
}

View File

@ -26,6 +26,7 @@
#include <memory>
#include "wrapexpat.h"
#include "parserdata.h"
#include <xercesc/validators/common/ContentSpecNode.hpp>
struct PromptGeneratorData : public ParserData
{
@ -109,6 +110,9 @@ class XmlPromptGenerator : public WrapExpat
PromptGeneratorData *d,
const XML_Char *el,
const XML_Char **attr );
static void getContent (
const xercesc::ContentSpecNode *spec,
std::set<std::string> &list );
};
#endif