Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

constraints.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "constraints.h"
#include "referenceTables.h"
#include "validator.h"

Functions

int xmlcpgnameForm (const char *s)
 Tests wheter s is in Name form.

int xmlcpgNmTokenForm (const char *s)
int xmlcpgwellFormednessElementTypeMatch (char *stag, char *etag)
 The Name in an element's end-tag must match the element type in the start-tag.

xmlcpgIteratorxmlcpgvalidityChildren (xmlcpgIterator *it, xmlcpgObject *specs)
void xmlcpgvalidityElementValid (xmlcpgElement *element, xmlcpgObject *specs)
 An element is valid if there is a declaration matching elementdecl where the Name matches the element type, and one of the following holds:.

int xmlcpgwellFormednessUniqueAttSpec (const char *name, const xmlcpgList *atts)
 No attribute name may appear more than once in the same start-tag or empty-element tag.

void xmlcpgvalidityAttributeValueType (xmlcpgAttribute *attribute, xmlcpgMap *specs, xmlcpgElement *element)
 The attribute must have been declared; the value must be of the type declared for it.

int xmlcpgwellFormednessNoExternalEntityReferences (const char *entityName)
 Attribute values cannot contain direct or indirect entity references to external entities.

int xmlcpgwellFormednessNoLessThanInAttributeValues (const xmlcpgAttribute *attribute)
 The replacement text of any entity referred to directly or indirectly in an attribute value must not contain a <.

int xmlcpgwellFormednessEntityDeclared (const char *entity)
 In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with "standalone='yes'", for an entity reference that does not occur within the external subset or a parameter entity, the Name given in the entity reference must match that in an entity declaration that does not occur within the external subset or a parameter entity, except that well-formed documents need not declare any of the following entities: amp, lt, gt, apos, quot.

int xmlcpgvalidityEntityDeclared (xmlcpgObject *ast)
 In a document with an external subset or external parameter entities with "standalone='no'", the Name given in the entity reference must match that in an entity declaration.

int xmlcpgwellFormednessParsedEntity (const char *entity)
 An entity reference must not contain the name of an unparsed entity.

int xmlcpgwellFormednessNoRecursion (xmlcpgObject *ast)
 A parsed entity must not contain a recursive reference to itself, either directly or indirectly.

void xmlcpgwellFormednessInDTD (const char *entity)
 Parameter-entity references may only appear in the DTD.

int xmlcpgvalidityNotationDeclared (xmlcpgObject *ast)
 The Name must match the declared name of a notation.

void xmlcpgvalidityUniqueNotationName (xmlcpgString *name)
 Only one notation declaration can declare a given Name.

int xmlcpgvalidityRootElementType (xmlcpgDocument *document)
 The Name in the document type declaration must match the element type of the root element.

int xmlcpgwellFormednessExternalSubset (xmlcpgObject *ast)
 The external subset, if any, must match the production for extSubset.

int xmlcpgvalidityStandaloneDocumentDeclaration (xmlcpgList *dtd)
 The standalone document declaration must have the value "no" if any external markup declarations contain declarations of:.

void xmlcpgvalidityProperDeclarationPENesting (xmlcpgPEDecl *entity)
 Parameter-entity replacement text must be properly nested with markup declarations.

int xmlcpgwellFormednessPEsinInternalSubset (xmlcpgObject *ast)
 In the internal DTD subset, parameter-entity references can occur only where markup declarations can occur, not within markup declarations.

int xmlcpgvalidityUniqueElementTypeDeclaration (xmlcpgString *elementName)
 No element type may be declared more than once.

void xmlcpgvalidityProperGroupPENesting (xmlcpgList *list)
 Parameter-entity replacement text must be properly nested with parenthesized groups.

void xmlcpgvalidityNoDuplicateTypes (xmlcpgList *list)
 The same name must not appear more than once in a single mixed-content declaration.

void xmlcpgvalidityID (xmlcpgString *attributeValue, xmlcpgElement *element)
 Values of type ID must match the Name production.

void xmlcpgvalidityOneIDperElementType (xmlcpgElement *element, xmlcpgMap *specs)
 No element type may have more than one ID attribute specified.

int xmlcpgvalidityIDAttributeDefault (xmlcpgObject *attType, xmlcpgObject *defaultDecl, char *nameAttribute)
 An ID attribute must have a declared default of IMPLIED or REQUIRED.

void xmlcpgvalidityIDREF (xmlcpgString *attribute, xmlcpgElement *element)
 Values of type IDREF must match the Name production, and values of type IDREFS must match Names; each Name must match the value of an ID attribute on some element in the XML document; i.e.

void xmlcpgvalidityIDREFS (xmlcpgString *attribute, xmlcpgElement *element)
 Values of type IDREF must match the Name production, and values of type IDREFS must match Names; each Name must match the value of an ID attribute on some element in the XML document; i.e.

void xmlcpgvalidityEntityName (xmlcpgString *attribute, xmlcpgElement *element)
 Values of type ENTITY must match the Name production, values of type ENTITIES must match Names; each Name must match the name of an unparsed entity declared in the DTD.

void xmlcpgvalidityEntityNames (xmlcpgString *attribute, xmlcpgElement *element)
 Values of type ENTITY must match the Name production, values of type ENTITIES must match Names; each Name must match the name of an unparsed entity declared in the DTD.

void xmlcpgvalidityNameToken (xmlcpgString *attribute, xmlcpgElement *element)
 Values of type NMTOKEN must match the Nmtoken production.

void xmlcpgvalidityNameTokens (xmlcpgString *attribute, xmlcpgElement *element)
 Values of type NMTOKEN must match the Nmtoken production; values of type NMTOKENS must match Nmtokens.

void xmlcpgvalidityNotationAttributes (xmlcpgString *attribute, xmlcpgObject *names, xmlcpgElement *element)
 Values of this type must match one of the notation names included in the declaration; all notation names in the declaration must be declared.

void xmlcpgvalidityOneNotationPerElementType (xmlcpgObject *ast, xmlcpgMap *specs)
 No element type may have more than one NOTATION attribute specified.

void xmlcpgvalidityNoNotationonEmptyElement (xmlcpgElement *element, xmlcpgMap *specs)
 For compatibility, an attribute of type NOTATION must not be declared on an element declared EMPTY.

void xmlcpgvalidityEnumeration (xmlcpgString *attribute, xmlcpgObject *nameTokens, xmlcpgElement *element)
 Values of this type must match one of the Nmtoken tokens in the declaration.

void xmlcpgvalidityRequiredAttribute (xmlcpgObject *container, xmlcpgElement *element)
 If the default declaration is the keyword REQUIRED, then the attribute must be specified for all elements of the type in the attribute-list declaration.

void xmlcpgvalidityAttributeDefaultLegal (xmlcpgAttDef *attDef)
 The declared default value must meet the lexical constraints of the declared attribute type.

void xmlcpgvalidityFixedAttributeDefault (xmlcpgString *attribute, xmlcpgFixed *defaultDecl, xmlcpgElement *element)
 If an attribute has a default value declared with the FIXED keyword, instances of that attribute must match the default value.

void xmlcpgvalidityLegalCharacter (xmlcpgObject *ast)
 Characters referred to using character references must match the production for Char.

int xmlcpgwellFormednessPEBetweenDeclarations (xmlcpgObject *ast)
 The replacement text of a parameter entity reference in a DeclSep must match the production extSubsetDecl.

void xmlcpgvalidityIDReferences ()
 Test whether each Name match the value of an ID attribute on some element in the XML document; i.e.

void xmlcpgcompatibilityError (const char *message)
 Signals a compatibility error.

void xmlcpgvalidityWarning (const char *message)
 Signals a validity warning.

void xmlcpgwellFormedConstraintFailure (const char *message)
 Signals a "Well Formed Constraint" test failure.

void xmlcpgconstraintsInit ()
 Initializes variables for validation purposes.

void xmlcpgconstraintsDestroy ()
 Destroys variables for validation purposes.


Variables

xmlcpgListusedIDs = NULL
xmlcpgListidRefs = NULL
xmlcpgListusedNameNotation = NULL
xmlcpgListelementList = NULL

Function Documentation

void xmlcpgcompatibilityError const char *    message
 

Signals a compatibility error.

Parameters:
message  the error message string.

void xmlcpgconstraintsDestroy  
 

Destroys variables for validation purposes.

void xmlcpgconstraintsInit  
 

Initializes variables for validation purposes.

It is used by xmlcpgspecializedValidator.

int xmlcpgnameForm const char *    s
 

Tests wheter s is in Name form.

Parameters:
s  the string to test.
Returns:
1 if s is in Name form.

int xmlcpgNmTokenForm const char *    s
 

void xmlcpgvalidityAttributeDefaultLegal xmlcpgAttDef   attDef
 

The declared default value must meet the lexical constraints of the declared attribute type.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

void xmlcpgvalidityAttributeValueType xmlcpgAttribute   attribute,
xmlcpgMap   specs,
xmlcpgElement   element
 

The attribute must have been declared; the value must be of the type declared for it.

(For attribute types, see 3.3 Attribute-List Declarations.)

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

xmlcpgIterator* xmlcpgvalidityChildren xmlcpgIterator   it,
xmlcpgObject   specs
[static]
 

void xmlcpgvalidityElementValid xmlcpgElement   element,
xmlcpgObject   specs
 

An element is valid if there is a declaration matching elementdecl where the Name matches the element type, and one of the following holds:.

1.The declaration matches EMPTY and the element has no content.

2.The declaration matches children and the sequence of child elements belongs to the language generated by the regular expression in the content model, with optional white space (characters matching the nonterminal S) between the start-tag and the first child element, between child elements, or between the last child element and the end-tag. Note that a CDATA section containing only white space does not match the nonterminal S, and hence cannot appear in these positions.

3.The declaration matches Mixed and the content consists of character data and child elements whose types match names in the content model.

4.The declaration matches ANY, and the types of any child elements have been declared.

int xmlcpgvalidityEntityDeclared xmlcpgObject   ast
 

In a document with an external subset or external parameter entities with "standalone='no'", the Name given in the entity reference must match that in an entity declaration.

For interoperability, valid documents should declare the entities amp, lt, gt, apos, quot, in the form specified in 4.6 Predefined Entities. The declaration of a parameter entity must precede any reference to it. Similarly, the declaration of a general entity must precede any attribute-list declaration containing a default value with a direct or indirect reference to that general entity.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

void xmlcpgvalidityEntityName xmlcpgString   attribute,
xmlcpgElement   element
 

Values of type ENTITY must match the Name production, values of type ENTITIES must match Names; each Name must match the name of an unparsed entity declared in the DTD.

Parameters:
attribute  the Name to xmlcpgvalidate.
element  the element that defines the entity reference.

void xmlcpgvalidityEntityNames xmlcpgString   attribute,
xmlcpgElement   element
 

Values of type ENTITY must match the Name production, values of type ENTITIES must match Names; each Name must match the name of an unparsed entity declared in the DTD.

Parameters:
attribute  the Names to xmlcpgvalidate.
element  the element that defines the entities references.

void xmlcpgvalidityEnumeration xmlcpgString   attribute,
xmlcpgObject   names,
xmlcpgElement   element
 

Values of this type must match one of the Nmtoken tokens in the declaration.

Parameters:
attribute  the attribute value to match.
names  the name token collection.
element  the element that contains the attribute.

void xmlcpgvalidityFixedAttributeDefault xmlcpgString   attribute,
xmlcpgFixed   defaultDecl,
xmlcpgElement   element
 

If an attribute has a default value declared with the FIXED keyword, instances of that attribute must match the default value.

Parameters:
attribute  the attribute value to match.
defaultDecl  the fixed default attribute.
element  the element that contains the attribute.

void xmlcpgvalidityID xmlcpgString   attributeValue,
xmlcpgElement   element
 

Values of type ID must match the Name production.

A name must not appear more than once in an XML document as a value of this type; i.e., ID values must uniquely identify the elements which bear them.

Parameters:
attributeValue  the attribute value to test.
element  the element that defines the attribute.

int xmlcpgvalidityIDAttributeDefault xmlcpgObject   attType,
xmlcpgObject   defaultDecl,
char *    name
 

An ID attribute must have a declared default of IMPLIED or REQUIRED.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

void xmlcpgvalidityIDREF xmlcpgString   attribute,
xmlcpgElement   element
 

Values of type IDREF must match the Name production, and values of type IDREFS must match Names; each Name must match the value of an ID attribute on some element in the XML document; i.e.

IDREF values must match the value of some ID attribute.

Parameters:
attribute  the Name to xmlcpgvalidate.
element  the element that defines the id reference.

void xmlcpgvalidityIDReferences  
 

Test whether each Name match the value of an ID attribute on some element in the XML document; i.e.

IDREF values must match the value of some ID attribute.

void xmlcpgvalidityIDREFS xmlcpgString   attribute,
xmlcpgElement   element
 

Values of type IDREF must match the Name production, and values of type IDREFS must match Names; each Name must match the value of an ID attribute on some element in the XML document; i.e.

IDREF values must match the value of some ID attribute.

Parameters:
attribute  the Names to xmlcpgvalidate.
element  the element that defines the id references.

void xmlcpgvalidityLegalCharacter xmlcpgObject   ast
 

Characters referred to using character references must match the production for Char.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

void xmlcpgvalidityNameToken xmlcpgString   attribute,
xmlcpgElement   element
 

Values of type NMTOKEN must match the Nmtoken production.

Parameters:
attribute  the NameToken to xmlcpgvalidate.
element  the element that defines the name token.

void xmlcpgvalidityNameTokens xmlcpgString   attribute,
xmlcpgElement   element
 

Values of type NMTOKEN must match the Nmtoken production; values of type NMTOKENS must match Nmtokens.

Parameters:
attribute  the NameTokens to xmlcpgvalidate.
element  the element that defines the name tokens.

void xmlcpgvalidityNoDuplicateTypes xmlcpgList   list
 

The same name must not appear more than once in a single mixed-content declaration.

Parameters:
element  the element to test.

void xmlcpgvalidityNoNotationonEmptyElement xmlcpgElement   element,
xmlcpgMap   specs
 

For compatibility, an attribute of type NOTATION must not be declared on an element declared EMPTY.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

void xmlcpgvalidityNotationAttributes xmlcpgString   attribute,
xmlcpgObject   names,
xmlcpgElement   element
 

Values of this type must match one of the notation names included in the declaration; all notation names in the declaration must be declared.

Parameters:
attribute  the attribute value to match.
names  the name collection.
element  the element that contains the attribute.

int xmlcpgvalidityNotationDeclared xmlcpgObject   ast
 

The Name must match the declared name of a notation.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

void xmlcpgvalidityOneIDperElementType xmlcpgElement   element,
xmlcpgMap   specs
 

No element type may have more than one ID attribute specified.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

void xmlcpgvalidityOneNotationPerElementType xmlcpgObject   ast,
xmlcpgMap   specs
 

No element type may have more than one NOTATION attribute specified.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

void xmlcpgvalidityProperDeclarationPENesting xmlcpgPEDecl   entity
 

Parameter-entity replacement text must be properly nested with markup declarations.

That is to say, if either the first character or the last character of a markup declaration (markupdecl above) is contained in the replacement text for a parameter-entity reference, both must be contained in the same replacement text.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

void xmlcpgvalidityProperGroupPENesting xmlcpgList   list
 

Parameter-entity replacement text must be properly nested with parenthesized groups.

That is to say, if either of the opening or closing parentheses in a choice, seq, or Mixed construct is contained in the replacement text for a parameter entity, both must be contained in the same replacement text.

For interoperability, if a parameter-entity reference appears in a choice, seq, or Mixed construct, its replacement text should contain at least one non-blank character, and neither the first nor last non-blank character of the replacement text should be a connector (| or ,).

Parameters:
list  the list to test.

void xmlcpgvalidityRequiredAttribute xmlcpgObject   container,
xmlcpgElement   element
 

If the default declaration is the keyword REQUIRED, then the attribute must be specified for all elements of the type in the attribute-list declaration.

Parameters:
container  the object containing the unprocessed required attribute names.
element  the element structure processed.

int xmlcpgvalidityRootElementType xmlcpgDocument   document
 

The Name in the document type declaration must match the element type of the root element.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

int xmlcpgvalidityStandaloneDocumentDeclaration xmlcpgList   dtd
 

The standalone document declaration must have the value "no" if any external markup declarations contain declarations of:.

The standalone document declaration must have the value "no" if any external markup declarations contain declarations of:

o attributes with default values, if elements to which these attributes apply appear in the document without specifications of values for these attributes, or

o entities (other than amp, lt, gt, apos, quot), if references to those entities appear in the document, or

o attributes with values subject to normalization, where the attribute appears in the document with a value which will change as a result of normalization, or

o element types with element content, if white space occurs directly within any instance of those types.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

int xmlcpgvalidityUniqueElementTypeDeclaration xmlcpgString   elementName
 

No element type may be declared more than once.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

void xmlcpgvalidityUniqueNotationName xmlcpgString   name
 

Only one notation declaration can declare a given Name.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

void xmlcpgvalidityWarning const char *    message
 

Signals a validity warning.

Parameters:
message  the error message string.

void xmlcpgwellFormedConstraintFailure const char *    message
 

Signals a "Well Formed Constraint" test failure.

Parameters:
message  the error message string.

int xmlcpgwellFormednessElementTypeMatch char *    stag,
char *    etag
 

The Name in an element's end-tag must match the element type in the start-tag.

Parameters:
stag  the element start-tag name.
etag  the element end-tag name.
Returns:
whether the tags conforms to this constraint.

int xmlcpgwellFormednessEntityDeclared const char *    entity
 

In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with "standalone='yes'", for an entity reference that does not occur within the external subset or a parameter entity, the Name given in the entity reference must match that in an entity declaration that does not occur within the external subset or a parameter entity, except that well-formed documents need not declare any of the following entities: amp, lt, gt, apos, quot.

The declaration of a general entity must precede any reference to it which appears in a default value in an attribute-list declaration.

Note that if entities are declared in the external subset or in external parameter entities, a non-validating processor is not obligated to read and process their declarations; for such documents, the rule that an entity must be declared is a well-formedness constraint only if standalone='yes'.

Parameters:
entity  the entity name.
Returns:
whether the name conforms to this constraint.

int xmlcpgwellFormednessExternalSubset xmlcpgObject   ast
 

The external subset, if any, must match the production for extSubset.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

void xmlcpgwellFormednessInDTD const char *    entity
 

Parameter-entity references may only appear in the DTD.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

int xmlcpgwellFormednessNoExternalEntityReferences const char *    entityName
 

Attribute values cannot contain direct or indirect entity references to external entities.

Parameters:
entityName  the entity name to test.
Returns:
0 if the entityName is not present in the General Entity Reference table, 1 otherwise.

int xmlcpgwellFormednessNoLessThanInAttributeValues const xmlcpgAttribute   attribute
 

The replacement text of any entity referred to directly or indirectly in an attribute value must not contain a <.

Parameters:
attribute  the attribute to test.
Returns:
0 if the attribute contains a < character, 1 otherwise.

int xmlcpgwellFormednessNoRecursion xmlcpgObject   ast
 

A parsed entity must not contain a recursive reference to itself, either directly or indirectly.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

int xmlcpgwellFormednessParsedEntity const char *    entity
 

An entity reference must not contain the name of an unparsed entity.

Unparsed entities may be referred to only in attribute values declared to be of type ENTITY or ENTITIES.

Parameters:
entity  the entity name
Returns:
whether the name conforms to this constraint.

int xmlcpgwellFormednessPEBetweenDeclarations xmlcpgObject   ast
 

The replacement text of a parameter entity reference in a DeclSep must match the production extSubsetDecl.

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

int xmlcpgwellFormednessPEsinInternalSubset xmlcpgObject   ast
 

In the internal DTD subset, parameter-entity references can occur only where markup declarations can occur, not within markup declarations.

(This does not apply to references that occur in external parameter entities or to the external subset.)

Parameters:
ast  the subtree to test.
Returns:
whether the ast conforms to this constraint.

int xmlcpgwellFormednessUniqueAttSpec const char *    name,
const xmlcpgList   atts
 

No attribute name may appear more than once in the same start-tag or empty-element tag.

Parameters:
name  the name of the element.
atts  the element's attribute list.
Returns:
whether the element conforms to this constraint


Variable Documentation

xmlcpgList* elementList = NULL [static]
 

xmlcpgList* idRefs = NULL [static]
 

xmlcpgList* usedIDs = NULL [static]
 

xmlcpgList* usedNameNotation = NULL [static]
 


Generated on Tue Nov 11 14:59:45 2003 for xmlcpg by doxygen1.2.18