4 * Generic schema interchange format that can be converted to a runtime
5 * representation (HTMLPurifier_ConfigSchema) or HTML documentation. Members
6 * are completely validated.
8 class HTMLPurifier_ConfigSchema_Interchange
12 * Name of the application this schema is describing.
17 * Array of Namespace ID => array(namespace info)
19 public $namespaces = array();
22 * Array of Directive ID => array(directive info)
24 public $directives = array();
27 * Adds a namespace array to $namespaces
29 public function addNamespace($namespace) {
30 if (isset($this->namespaces
[$i = $namespace->namespace])) {
31 throw new HTMLPurifier_ConfigSchema_Exception("Cannot redefine namespace '$i'");
33 $this->namespaces
[$i] = $namespace;
37 * Adds a directive array to $directives
39 public function addDirective($directive) {
40 if (isset($this->directives
[$i = $directive->id
->toString()])) {
41 throw new HTMLPurifier_ConfigSchema_Exception("Cannot redefine directive '$i'");
43 $this->directives
[$i] = $directive;
47 * Convenience function to perform standard validation. Throws exception
48 * on failed validation.
50 public function validate() {
51 $validator = new HTMLPurifier_ConfigSchema_Validator();
52 return $validator->validate($this);