19 #include "stringManipulate.h"
25 #define DEFAULT_GLOBAL_QNAME_COUNT 200
30 static GrammarRule static_grammar_rule_empty[1] = {{static_grammar_prod_empty, 1, 0x01}};
31 static EXIGrammar static_grammar_empty = {static_grammar_rule_empty, 0x42000000, 1};
232 static int compareProductions(
const void* prod1,
const void* prod2);
246 static int compareAttrUse(
const void* attrPG1,
const void* attrPG2);
249 static int compareGlobalElemQName(
const void* QNameId1,
const void* QNameId2);
255 static errorCode parseOccuranceAttribute(
const String occurance,
int* outInt);
281 static void sortEnumTable(
EXIPSchema *schema);
292 static void sortSubsitutionGroup(
struct subsGroupElTbl* subsElGrTbl);
305 globalSchemaPtr = schema;
313 for(i = 0; i < count; i++)
315 qEntry.
treeT = &treeT[i];
317 for(j = 0; j < treeT[i].
count; j++)
323 tmp_err_code = handleElementEl(&ctx, &qEntry,
TRUE, &qGrIndex);
326 tmp_err_code = handleSimpleTypeEl(&ctx, &qEntry);
329 tmp_err_code = handleComplexTypeEl(&ctx, &qEntry);
375 sortGlobalElemQnameTable(&ctx.
gElTbl);
380 sortEnumTable(schema);
398 static errorCode parseOccuranceAttribute(
const String occurance,
int* outInt)
412 static int compareAttrUse(
const void* attrPG1,
const void* attrPG2)
417 return compareQNameID(&((*a1)->rule[0].prod[0].qnameId), &((*a2)->rule[0].prod[0].qnameId), &globalSchemaPtr->
uriTable);
439 if(minOccurs < 0 || maxOccurs < -1)
444 TRY(recursiveSubsitutionGroupAdd(ctx, qGrIndex, &subsElGrTbl));
446 sortSubsitutionGroup(&subsElGrTbl);
453 if(elParticleGrammar ==
NULL)
460 *elTerm = elParticleGrammar;
471 boolean isNillable =
FALSE;
473 #if DEBUG_GRAMMAR_GEN == ON && EXIP_DEBUG_LEVEL == INFO
506 qNmGrIndex->
qnameId = elQNameID;
545 TRY(getSimpleTypeProtoGrammar(ctx, &treeTEntry->
entry->
child, &pg));
549 TRY(getComplexTypeProtoGrammar(ctx, &treeTEntry->
entry->
child, &pg));
555 return handleElementEl(ctx, &treeTEntry->
entry->
child,
TRUE, qNmGrIndex);
579 boolean prodFound =
FALSE;
605 TRY(storeGrammar(ctx, elQNameID, pg, isNillable, &qNmGrIndex->
grIndex));
633 TRY(getSimpleTypeProtoGrammar(ctx, &treeTEntry->
entry->
child, &pg));
637 TRY(getComplexTypeProtoGrammar(ctx, &treeTEntry->
entry->
child, &pg));
661 boolean prodFound =
FALSE;
687 TRY(storeGrammar(ctx, typeQNameID, pg, isNillable, &qNmGrIndex->
grIndex));
723 boolean required =
FALSE;
729 required = isRequired;
765 TRY(getTypeId(ctx, stQNameID, &attrEntry->
entry->
child, &typeId));
779 return getAttributeProtoGrammar(ctx, &attrEntry->
entry->
child,
TRUE, required, attr);
784 TRY(getAnonymousTypeId(ctx, &attrEntry->
entry->
child, &typeId));
808 TRY(getRestrictionSimpleProtoGrammar(ctx, &simpleEntry->
entry->
child, simplType));
812 TRY(getListProtoGrammar(ctx, &simpleEntry->
entry->
child, simplType));
817 if(*simplType ==
NULL)
832 #if DEBUG_GRAMMAR_GEN == ON && EXIP_DEBUG_LEVEL == INFO
854 TRY(getSimpleTypeProtoGrammar(ctx, stEntry, &simpleProtoGrammar));
855 TRY(storeGrammar(ctx, stQNameID, simpleProtoGrammar,
FALSE, &grIndex));
907 tmp_err_code = getRestrictionSimpleProtoGrammar(ctx, &sContEntry->
entry->
child, sCont);
911 tmp_err_code = getExtensionSimpleProtoGrammar(ctx, &sContEntry->
entry->
child, sCont);
933 tmp_err_code = getSimpleContentProtoGrammar(ctx, &contEntry->
entry->
child, content);
937 tmp_err_code = getComplexContentProtoGrammar(ctx, &contEntry->
entry->
child, content);
941 tmp_err_code = getSequenceProtoGrammar(ctx, &contEntry->
entry->
child, content);
945 tmp_err_code = getGroupProtoGrammar(ctx, &contEntry->
entry->
child, content);
949 tmp_err_code = getAllProtoGrammar(ctx, &contEntry->
entry->
child, content);
953 tmp_err_code = getChoiceProtoGrammar(ctx, &contEntry->
entry->
child, content);
1029 if(!isAttrAlreadyPresent(aName, aNamesTbl))
1035 TRY(getAttributeProtoGrammar(ctx, &attrUse,
FALSE,
FALSE, &attrPG));
1044 TRY(getAttributeUseProtoGrammars(ctx, &attrUse.
entry->
child, attrUseArray, attrWildcardNS, aNamesTbl));
1068 TRY(getAttributeUseProtoGrammars(ctx, &attrEntry->
entry->
child.
entry->
child, attrUseArray, attrWildcardNS, aNamesTbl));
1077 TRY(getAttributeUseProtoGrammars(ctx, &attrEntry->
entry->
supertype, attrUseArray, attrWildcardNS, aNamesTbl));
1101 boolean isMixedContent =
FALSE;
1127 isMixedContent =
TRUE;
1130 TRY(getContentTypeProtoGrammar(ctx, complEntry, &contentTypeGrammar));
1136 TRY(getAttributeUseProtoGrammars(ctx, complEntry, &attrUseArray, &attrWildcardNS, &aNamesTbl));
1141 sortAttributeUseGrammars(&attrUseArray);
1143 if(attrWildcardNS !=
NULL)
1156 if(pAttrWildGrammar ==
NULL)
1164 if(nsTable.
count == 0 ||
1165 (nsTable.
count == 1 &&
1170 for(i = 0; i < attrUseArray.
count; i++)
1177 else if(nsTable.
count >= 1)
1183 for(j = 0; j < nsTable.
count; j++)
1188 for(i = 0; i < attrUseArray.
count; i++)
1200 if(contentTypeGrammar ==
NULL && attrUseArray.
count == 0)
1207 if(*complType ==
NULL)
1212 if(contentTypeGrammar !=
NULL)
1216 for(i = 0; i < attrUseArray.
count; i++)
1230 #if DEBUG_GRAMMAR_GEN == ON && EXIP_DEBUG_LEVEL == INFO
1251 TRY(getComplexTypeProtoGrammar(ctx, ctEntry, &complType));
1257 if(complType !=
NULL)
1261 assignCodes(complType);
1271 boolean prodFound =
FALSE;
1297 TRY(storeGrammar(ctx, ctQNameID, complType,
FALSE, &grIndex));
1341 tmp_err_code = getRestrictionComplexProtoGrammar(ctx, &cConEntry->
entry->
child, cCont);
1345 tmp_err_code = getExtensionComplexProtoGrammar(ctx, &cConEntry->
entry->
child, cCont);
1350 return tmp_err_code;
1371 if(minOccurs < 0 || maxOccurs < -1)
1381 TRY(handleElementEl(ctx, &nextIterator,
FALSE, &qGrIndex));
1382 TRY(getElementTermProtoGrammar(ctx, &nextIterator, qGrIndex, &particleGrammar));
1386 TRY(getGroupProtoGrammar(ctx, &nextIterator, &particleGrammar));
1390 TRY(getChoiceProtoGrammar(ctx, &nextIterator, &particleGrammar));
1394 TRY(getSequenceProtoGrammar(ctx, &nextIterator, &particleGrammar));
1398 TRY(getAnyProtoGrammar(ctx, &nextIterator, &particleGrammar));
1409 for(i = 0; i < partGrammarTbl.
count; i++)
1417 if(seqPartGrammar ==
NULL)
1423 *seq = seqPartGrammar;
1444 if(minOccurs < 0 || maxOccurs < -1)
1450 if(wildParticleGrammar ==
NULL)
1458 *any = wildParticleGrammar;
1480 if(minOccurs < 0 || maxOccurs < -1)
1491 TRY(handleElementEl(ctx, &nextIterator,
FALSE, &qGrIndex));
1492 TRY(getElementTermProtoGrammar(ctx, &nextIterator, qGrIndex, &particleGrammar));
1496 TRY(getGroupProtoGrammar(ctx, &nextIterator, &particleGrammar));
1500 TRY(getChoiceProtoGrammar(ctx, &nextIterator, &particleGrammar));
1504 TRY(getSequenceProtoGrammar(ctx, &nextIterator, &particleGrammar));
1508 TRY(getAnyProtoGrammar(ctx, &nextIterator, &particleGrammar));
1519 for(i = 0; i < particleProtoGrammarArray.
count; i++)
1527 if(choicePartGrammar ==
NULL)
1532 *choice = choicePartGrammar;
1550 #if DEBUG_GRAMMAR_GEN == ON && EXIP_DEBUG_LEVEL == INFO
1558 if(minOccurs < 0 || maxOccurs < -1)
1588 if(grPartGrammar ==
NULL)
1594 *group = grPartGrammar;
1606 #if DEBUG_GRAMMAR_GEN == ON && EXIP_DEBUG_LEVEL == INFO
1614 if(resultProtoGrammar ==
NULL)
1621 *ext = resultProtoGrammar;
1636 #if DEBUG_GRAMMAR_GEN == ON && EXIP_DEBUG_LEVEL == INFO
1644 if(resultProtoGrammar ==
NULL)
1653 TRY(handleComplexTypeEl(ctx, &base));
1654 TRY(getContentTypeProtoGrammar(ctx, &base, &contentTypeGrammarBase));
1666 TRY(getContentTypeProtoGrammar(ctx, extEntry, &contentTypeGrammarExt));
1668 contGrArr[0] = contentTypeGrammarBase;
1669 contGrArr[1] = contentTypeGrammarExt;
1672 if(contentTypeGrammarBase !=
NULL)
1674 if(contentTypeGrammarExt !=
NULL)
1677 *ext = resultProtoGrammar;
1691 unsigned int enumCount = 0;
1719 while(tmpEntry !=
NULL)
1756 newSimpleType.
length = (
unsigned int) ml;
1760 int totalDigits = 0;
1767 int fractionDigits = 0;
1792 tmpEntry = tmpEntry->
next;
1802 if(newSimpleType.
min >= 0)
1807 if(newSimpleType.
max - newSimpleType.
min + 1 <= 4096)
1812 if(newSimpleType.
max - newSimpleType.
min <= 4096)
1818 if(newSimpleType.
min >= -1)
1823 if(newSimpleType.
max - newSimpleType.
min - 1 <= 4096)
1828 if(newSimpleType.
max - newSimpleType.
min <= 4096)
1839 unsigned int enumIter = 0;
1844 eDef.
count = enumCount;
1855 valSize =
sizeof(
String);
1858 valSize =
sizeof(char);
1871 valSize =
sizeof(
Float);
1889 while(enumEntry !=
NULL)
1939 enumEntry = enumEntry->
next;
1949 if(simpleRestrictedGrammar ==
NULL)
1953 *restr = simpleRestrictedGrammar;
1963 #if DEBUG_GRAMMAR_GEN == ON && EXIP_DEBUG_LEVEL == INFO
1975 TRY(getContentTypeProtoGrammar(ctx, resEntry, restr));
1996 *typeId = typeQnameId.
lnId;
2007 TRY(handleSimpleTypeEl(ctx, typeEntry));
2040 TRY(getSimpleTypeProtoGrammar(ctx, typeEntry, &tmpGr));
2062 Index listEntrySimplID;
2072 listSimpleType.
max = 0;
2073 listSimpleType.
min = 0;
2074 listSimpleType.
length = 0;
2085 TRY(getTypeId(ctx, itemTypeQnameId, &listEntry->
entry->
supertype, &itemTypeId));
2089 TRY(getAnonymousTypeId(ctx, &listEntry->
entry->
child, &itemTypeId));
2092 listSimpleType.
length = itemTypeId;
2105 if(pGrammar ==
NULL)
2107 exiGr = static_grammar_empty;
2117 assignCodes(pGrammar);
2131 boolean prodFound =
FALSE;
2152 #if DEBUG_GRAMMAR_GEN == ON && EXIP_DEBUG_LEVEL == INFO
2161 for(t = 0; t < exiGr.
count; t++)
2171 static int compareGlobalElemQName(
const void* QNameId1,
const void* QNameId2)
2184 static void sortEnumTable(
EXIPSchema *schema)
2193 for(i = 0; i < lAttrTbl->
count; i++)
2206 for (i = 0; i < grammar->
count; i++)
2212 static int compareProductions(
const void* prod1,
const void* prod2)
2260 boolean isHeadFound =
FALSE;
2284 TRY(recursiveSubsitutionGroupAdd(ctx, subsEl, subsElGrTbl));
2291 static int compareSubsitutionGroupMembers(
const void* elem1,
const void* elem2)
2299 static void sortSubsitutionGroup(
struct subsGroupElTbl* subsElGrTbl)