Version 0.7
Home
Help


Validating Character Entities

SDValidator supports two methods for character entity validation. Regular expression validation allows users to define a define valid character entity strings directly within an SDD. File-based validation allows for validation based on character entities defined in character entity definition files. These two methods can be mixed within an SDD.

Regular Expression Validation

The following sdd illustrates the two ways in which character entities can be constrained using regular expressions.

The char_ent_def keyword is used to define name-value pairs. In this case it defines a name, xml-char-ents, that is mapped to a regular expression, "amp|lt|gt". Defining a name-value pair allows the mapped regular expression to be reused for multiple tags by referencing its name.

The char_ents keyword is used to define a list of regular expressions and name mappings for use in validating character entities discovered during validation. Regular expressions and names in the list are separated by semi-colons.

<?sdd version="2.1" type="XML"?>
char_ent_def=xml-char-ents=>"amp|lt|gt"

<tag>1{ENTITIES} char_ents="nbsp|copy";xml-char-ents </tag>
<tag2>1{ENTITIES} char_ents=xml-char-ents </tag2>

File-Based Validation

The following sdd illustrates the use of character entity definition files in constraining character entities.

In this case, a char_ent_def keyword is used to define a name-value pair for a character entity definition file. (For information on creating and managing character entity definition files, see How to Use Character Entities.) When an sdd is compiled, the application will try to resolve references to character entity definition files and load them. If the application cannot find a definition file or there is a problem loading the file, an error will be issued during sdd compilation.

<?sdd version="2.1" type="XML"?>
char_ent_def=xml-char-ents=>"amp|lt|gt"
char_ent_def=greek-characters=>greekdiacrits.xml

<tag>1{ENTITIES} char_ents="nbsp|copy";xml-char-ents;greek-characters </tag>
<tag2>1{ENTITIES} char_ents=xml-char-ents </tag2>