exip  Alpha 0.5.4
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
genUtils.c File Reference

Implementation of utility functions for generating Schema-informed Grammar definitions. More...

#include "genUtils.h"
#include "memManagement.h"
#include "stringManipulate.h"
#include "grammars.h"
#include "ioUtil.h"
#include "initSchemaInstance.h"

Go to the source code of this file.

Functions

errorCode concatenateGrammars (ProtoGrammar *left, ProtoGrammar *right)
 Grammar Concatenation Operator - extends the rules and productions in the left ProtoGrammar The grammar concatenation operator ⊕ is a binary, associative operator that creates a new grammar from its left and right grammar operands. More...
 
errorCode createSimpleTypeGrammar (Index typeId, ProtoGrammar *simpleGrammar)
 Creates Simple Type Grammar from XML Schema simple type definition. More...
 
errorCode createComplexTypeGrammar (ProtoGrammarArray *attrUseArray, ProtoGrammar *contentTypeGrammar, boolean isMixedContent, ProtoGrammar *complexGrammar)
 Creates Complex Type Proto-Grammar from XML Schema complex type definition Sort the attribute use grammars first by qname local-name, then by qname uri. More...
 
errorCode createComplexUrTypeGrammar (ProtoGrammar *result)
 Creates Complex Ur-Type Grammar from XML Schema complex ur-type. More...
 
errorCode createAttributeUseGrammar (boolean required, Index typeId, ProtoGrammar *attrGrammar, QNameID qnameID)
 Creates Attribute Use Grammar from XML Schema Attribute Use. More...
 
errorCode createParticleGrammar (int minOccurs, int maxOccurs, ProtoGrammar *termGrammar, ProtoGrammar *particleGrammar)
 Creates Particle Proto-Grammar from XML Schema particle. More...
 
errorCode createElementTermGrammar (ProtoGrammar *elemGrammar, QNameIDGrIndx *qnameGrArr, Index count)
 Creates Element Term Proto-Grammar from Particle term that is XML Schema element declaration. More...
 
errorCode createWildcardTermGrammar (String *wildcardArray, Index wildcardArraySize, UriTable *uriT, ProtoGrammar *wildcardGrammar)
 Creates Wildcard Term Proto-Grammar from Particle term that is XML Schema wildcard. More...
 
errorCode createSequenceModelGroupsGrammar (ProtoGrammar **grArray, unsigned int arrSize, ProtoGrammar *seqGrammar)
 Creates Sequence Model Group Proto-Grammar from Particle term that is XML Schema Model Group with {compositor} equal to "sequence". More...
 
errorCode createChoiceModelGroupsGrammar (ProtoGrammarArray *pgArray, ProtoGrammar *modGrpGrammar)
 Creates Choice Model Group Proto-Grammar from Particle term that is XML Schema Model Group with {compositor} equal to "choice". More...
 
errorCode createAllModelGroupsGrammar (ProtoGrammar *pTermArray, unsigned int pTermArraySize, ProtoGrammar *modGrpGrammar)
 Creates All Model Group Proto-Grammar from Particle term that is XML Schema Model Group with {compositor} equal to "all". More...
 
errorCode addEEProduction (ProtoRuleEntry *rule)
 Adds a EE production to a proto grammar rule. More...
 
int compareQNameID (const void *qnameID1, const void *qnameID2, UriTable *uriTbl)
 Compare lexicographically two qnames: first by qname local-name, then by qname uri NOTE: Relies on the fact that the sting tables are sorted beforehand! More...
 

Detailed Description

Date
Nov 23, 2010
Author
Rumen Kyusakov
Version
0.5
[Revision] $Id: genUtils.c 332 2014-05-05 18:22:55Z kjussakov $

Definition in file genUtils.c.

Function Documentation

errorCode addEEProduction ( ProtoRuleEntry rule)
Parameters
[in]ruleproto grammar rule
Returns
Error handling code

Definition at line 651 of file genUtils.c.

int compareQNameID ( const void *  qnameID1,
const void *  qnameID2,
UriTable uriTbl 
)
Parameters
[in]qnameID1qnameId of the first qname
[in]qnameID2qnameId of the second qname
[in]uriTblstring table reference
Returns
0 when the qnames are equal; negative int when qnameID1<qnameID2; positive when qnameID1>qnameID2

The strings in the string tables are sorted beforehand so simple comparison of the indexes is enough.

Definition at line 668 of file genUtils.c.

errorCode concatenateGrammars ( ProtoGrammar left,
ProtoGrammar right 
)

The new grammar accepts any set of symbols accepted by its left operand followed by any set of symbols accepted by its right operand. As opposed to the operator in the specification, the implementation here automatically normalize the resulting grammar

Parameters
[in,out]leftleft operand - grammar
[in]rightright operand - grammar
Returns
Error handling code

Definition at line 32 of file genUtils.c.

errorCode createAllModelGroupsGrammar ( ProtoGrammar pTermArray,
unsigned int  pTermArraySize,
ProtoGrammar modGrpGrammar 
)
Parameters
[in]pTermArrayan array of ParticleTerm grammars included in the All Model Group
[in]pTermArraySizethe size of the ParticleTerm grammar array
[out]modGrpGrammarthe resulted proto-grammar
Returns
Error handling code

Definition at line 646 of file genUtils.c.

errorCode createAttributeUseGrammar ( boolean  required,
Index  typeId,
ProtoGrammar attrGrammar,
QNameID  qnameID 
)
Parameters
[in]required0 - false; otherwise true
[in]typeIdthe id of the attribute type in the simpleTypeTable
[out]attrGrammarthe resulted proto-grammar
[in]qnameIDuri/ln indices in the unsorted string tables
Returns
Error handling code

Definition at line 364 of file genUtils.c.

errorCode createChoiceModelGroupsGrammar ( ProtoGrammarArray pgArray,
ProtoGrammar modGrpGrammar 
)
Parameters
[in,out]pgArrayarray of ParticleTerm grammars included in the Choice Model Group
[out]modGrpGrammarthe resulted proto-grammar
Returns
Error handling code

Definition at line 567 of file genUtils.c.

errorCode createComplexTypeGrammar ( ProtoGrammarArray attrUseArray,
ProtoGrammar contentTypeGrammar,
boolean  isMixedContent,
ProtoGrammar complexGrammar 
)

If {content type} is type definition T-j , generate a grammar Content-i as grammar Type-j Then create a copy H-i of each attribute use grammar Result: Type-i = H-0 ⊕ H-1 ⊕ … ⊕ H-n−1 ⊕ Content-i

Parameters
[in]attrUseArrayarray of attribute uses grammars included in this complex type It should be lexicographically sorted
[in]contentTypeGrammarthe proto-grammar of the complex type content: either Simple Type Grammar, or Particle grammar or empty
[in]isMixedContentif the complex types has mixed content type (TRUE) or not (FALSE)
[in,out]complexGrammarthe resulted proto-grammar
Returns
Error handling code

Definition at line 308 of file genUtils.c.

errorCode createComplexUrTypeGrammar ( ProtoGrammar result)
Parameters
[out]resultthe resulted proto-grammar
Returns
Error handling code

Definition at line 359 of file genUtils.c.

errorCode createElementTermGrammar ( ProtoGrammar elemGrammar,
QNameIDGrIndx qnameGrArr,
Index  count 
)
Parameters
[out]elemGrammarthe resulted proto-grammar
[in]qnameGrArrarray of uri/ln indices of the element in the string tables and the associated grammar indices to be used for processing this SE(qnameID) element
[in]count
Returns
Error handling code

Definition at line 479 of file genUtils.c.

errorCode createParticleGrammar ( int  minOccurs,
int  maxOccurs,
ProtoGrammar termGrammar,
ProtoGrammar particleGrammar 
)
Parameters
[in]minOccursparticle's {min Occurs}
[in]maxOccursparticle's {max Occurs}. If less than 0 then the value is {unbounded}
[in]termGrammarthe grammar created from the particle's term: Element Term, Wildcard Term or Model Group Term
[out]particleGrammarthe resulted proto-grammar
Returns
Error handling code

Definition at line 386 of file genUtils.c.

errorCode createSequenceModelGroupsGrammar ( ProtoGrammar **  grArray,
unsigned int  arrSize,
ProtoGrammar sequenceGrammar 
)
Parameters
[in]grArrayarray of proto ParticleTerm grammars included in the sequence Model Group
[in]arrSizethe size of the array of proto ParticleTerm grammars
[out]sequenceGrammarthe resulted proto-grammar
Returns
Error handling code

Definition at line 540 of file genUtils.c.

errorCode createSimpleTypeGrammar ( Index  typeId,
ProtoGrammar simpleGrammar 
)
Parameters
[in]typeIdindex of the type in the simple type table
[in,out]simpleGrammarThe simple proto-grammar
Returns
Error handling code

Definition at line 292 of file genUtils.c.

errorCode createWildcardTermGrammar ( String wildcardArray,
Index  wildcardArraySize,
UriTable uriT,
ProtoGrammar wildcardGrammar 
)
Parameters
[in]wildcardArrayarray of strings. Possible values: "any" or a set of namespace names and "absent" or 'not' and a namespace name or "not" and "absent"
[in]wildcardArraySizethe size of the wildcard array
[in]uriTthe URI string table
[out]wildcardGrammarthe resulted proto-grammar
Returns
Error handling code

Definition at line 500 of file genUtils.c.