<?
-// BIFE: Build It FastEr - draft 1
+// BIFE: Build It FastEr - draft 4
-define('TAB', ' ');
+require_once 'HTML/Template/Sigma.php';
+require_once 'BIFE/Parser.php';
+require_once 'BIFE/Page.php';
+require_once 'BIFE/Title.php';
+require_once 'BIFE/Album.php';
+#require_once 'BIFE.php';
-$file = "data.xml";
-$depth = array();
-$stack = array();
+$file = "simple.xbf";
-function startElement($parser, $name, $attrs) {
- global $depth, $stack;
- $stack[] = $name;
- echo str_repeat(TAB, @$depth[$parser]);
- echo "<$name> ";
- foreach ($attrs as $attr => $val) {
- echo "$attr: '$val' ";
- }
- echo "\n";
- @$depth[$parser]++;
-}
+$template =& new HTML_Template_Sigma('templates');
+$template->setErrorHandling(PEAR_ERROR_PRINT);
-function endElement($parser, $name) {
- global $depth, $stack;
- array_pop($stack);
- $depth[$parser]--;
-}
-
-function characterData($parser, $data) {
- static $last = '';
- global $depth, $stack;
- $current = join('/', $stack);
- $data = trim($data);
- if ($data) {
- echo str_repeat(TAB, @$depth[$parser]);
- if ($current !== $last) {
- $last = $current;
- echo "En $current: ";
- } else {
- echo " ";
- }
- echo "'$data'\n";
- }
-}
-
-$xml_parser = xml_parser_create();
-xml_set_element_handler($xml_parser, "startElement", "endElement");
-xml_set_character_data_handler($xml_parser, "characterData");
-if (!($fp = @fopen($file, "r"))) {
- die("could not open XML input\n");
-}
-
-while ($data = fread($fp, 4096)) {
- if (!xml_parse($xml_parser, $data, feof($fp))) {
- die(sprintf("XML error: %s at line %d\n",
- xml_error_string(xml_get_error_code($xml_parser)),
- xml_get_current_line_number($xml_parser)));
- }
-}
-xml_parser_free($xml_parser);
+$parser =& new BIFE_Parser($template);
+$parser->parseFile($file);
+echo $parser->getOutput();
+$parser->__destruct();
?>