File: test.php

package info (click to toggle)
php-xml-dtd 0.5.2%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 268 kB
  • sloc: xml: 684; php: 416; makefile: 5
file content (32 lines) | stat: -rwxr-xr-x 764 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/php -Cq
<?php
ob_implicit_flush(true);
$path = ini_get('include_path');
ini_set('include_path', realpath('..') . ":$path");
$argv = $_SERVER['argv'];
if (!is_file(@$argv[1])) {
	help();
}
$dtd = $argv[1];
if (isset($argv[2]) && !is_file($argv[2])) {
	help();
}
$xml = isset($argv[2]) ? $argv[2] : false;
if (!$xml) {
	include 'XML/DTD.php';
	$a = new XML_DTD_Parser;
	print_r($a->parse($dtd));
} else {
	include 'XML/DTD/XmlValidator.php';
	$a = new XML_DTD_XmlValidator;
	if (!$a->isValid($dtd, $xml)) {
		echo $a->getMessage();
	}
}
function help() {
	echo "Usage: test.php <dtd file> [<xml file>]\n";
	echo "Passing only <dtd file> will dump the parsed DTD Tree\n";
	echo "Passing both, will try to validate <xml file> with <dtd file>\n";
	exit;
}
?>