root/trunk/examples/TestAttributesRequired.php

Revision 129, 1.1 kB (checked in by mikey, 1 year ago)

renamed XJConfLoader to XJConf

Line 
1 <?php
2 /**
3  * Example that shows the effect of required attributes that have not been set.
4  *
5  * @author  Stephan Schmidt <stephan.schmidt@schlund.de>
6  * @author  Frank Kleine <frank.kleine@schlund.de>
7  */
8 require_once '../XJConf/XJConf.php';
9 use net::xjconf::DefinitionParser;
10 use net::xjconf::XmlParser;
11 require 'Color.php';
12 /**
13  * Example that shows the effect of required attributes that have not been set.
14  *
15  * @package     XJConf
16  * @subpackage  examples
17  */
18 class TestAttributesRequired
19 {
20     public static function main()
21     {
22         $tagParser = new DefinitionParser();
23         $defs      = $tagParser->parse(getcwd() . '/xml/defines-attributes-required.xml');
24
25         $conf      = new XmlParser();
26         try {
27             $conf->setTagDefinitions($defs);
28             $conf->parse(getcwd() . '/xml/test-attributes-required.xml');
29             $color = $conf->getConfigValue('red');
30             var_dump($color);
31         } catch (Exception $e) {
32             echo 'Caught expected Exception with message: "' . $e->getMessage() . '", showing trace: ';
33             var_dump($e->getTrace());
34             exit(0);
35         }
36     }
37 }
38 TestAttributesRequired::main();
39 ?>
Note: See TracBrowser for help on using the browser.