summaryrefslogtreecommitdiff
path: root/ext/xmlreader
diff options
context:
space:
mode:
Diffstat (limited to 'ext/xmlreader')
-rw-r--r--ext/xmlreader/config.m47
-rw-r--r--ext/xmlreader/config.w324
-rw-r--r--ext/xmlreader/php_xmlreader.c72
-rw-r--r--ext/xmlreader/php_xmlreader.h8
-rw-r--r--ext/xmlreader/tests/001.phpt29
-rw-r--r--ext/xmlreader/tests/002.phpt41
-rw-r--r--ext/xmlreader/tests/003.phpt84
-rw-r--r--ext/xmlreader/tests/004.phpt44
-rw-r--r--ext/xmlreader/tests/005.phpt37
-rw-r--r--ext/xmlreader/tests/006.phpt36
-rw-r--r--ext/xmlreader/tests/007.phpt57
-rw-r--r--ext/xmlreader/tests/008.phpt71
-rw-r--r--ext/xmlreader/tests/009.phpt28
-rw-r--r--ext/xmlreader/tests/010.phpt27
-rw-r--r--ext/xmlreader/tests/dtdexample.dtd8
-rw-r--r--ext/xmlreader/tests/relaxNG.rng11
-rw-r--r--ext/xmlreader/tests/relaxNG2.rng23
-rw-r--r--ext/xmlreader/tests/relaxNG3.rng8
18 files changed, 558 insertions, 37 deletions
diff --git a/ext/xmlreader/config.m4 b/ext/xmlreader/config.m4
index 64e617bf9..3c3e8b76e 100644
--- a/ext/xmlreader/config.m4
+++ b/ext/xmlreader/config.m4
@@ -1,9 +1,9 @@
dnl
-dnl $Id: config.m4,v 1.3 2005/05/29 23:16:45 sniper Exp $
+dnl $Id: config.m4,v 1.3.2.2 2005/12/17 15:40:37 helly Exp $
dnl
-PHP_ARG_WITH(xmlreader, for XMLReader support,
-[ --with-xmlreader Include XMLReader support])
+PHP_ARG_ENABLE(xmlreader, whether to enable XMLReader support,
+[ --disable-xmlreader Disable XMLReader support], yes)
if test -z "$PHP_LIBXML_DIR"; then
PHP_ARG_WITH(libxml-dir, libxml2 install dir,
@@ -19,6 +19,7 @@ if test "$PHP_XMLREADER" != "no"; then
PHP_SETUP_LIBXML(XMLREADER_SHARED_LIBADD, [
AC_DEFINE(HAVE_XMLREADER,1,[ ])
PHP_NEW_EXTENSION(xmlreader, php_xmlreader.c, $ext_shared)
+ PHP_ADD_EXTENSION_DEP(xmlreader, dom, true)
PHP_SUBST(XMLREADER_SHARED_LIBADD)
], [
AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
diff --git a/ext/xmlreader/config.w32 b/ext/xmlreader/config.w32
index e33536643..a84725d5c 100644
--- a/ext/xmlreader/config.w32
+++ b/ext/xmlreader/config.w32
@@ -1,7 +1,7 @@
-// $Id: config.w32,v 1.2 2004/07/29 20:42:49 edink Exp $
+// $Id: config.w32,v 1.2.2.1 2005/12/01 08:54:22 sniper Exp $
// vim:ft=javascript
-ARG_WITH("xmlreader", "XMLReader support", "no");
+ARG_ENABLE("xmlreader", "XMLReader support", "yes");
if (PHP_XMLREADER == "yes" && PHP_LIBXML == "yes") {
EXTENSION("xmlreader", "php_xmlreader.c");
diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c
index 23bf828eb..d70fb9d93 100644
--- a/ext/xmlreader/php_xmlreader.c
+++ b/ext/xmlreader/php_xmlreader.c
@@ -2,12 +2,12 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2005 The PHP Group |
+ | Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
+ | This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_0.txt. |
+ | http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_xmlreader.c,v 1.13.2.3 2005/11/15 14:28:40 dmitry Exp $ */
+/* $Id: php_xmlreader.c,v 1.13.2.8 2006/01/01 12:50:16 sniper Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -53,7 +53,7 @@ typedef struct _xmlreader_prop_handler {
#define XMLREADER_LOAD_STRING 0
#define XMLREADER_LOAD_FILE 1
-
+/* {{{ xmlreader_register_prop_handler */
static void xmlreader_register_prop_handler(HashTable *prop_handler, char *name, xmlreader_read_int_t read_int_func, xmlreader_read_char_t read_char_func, int rettype TSRMLS_DC)
{
xmlreader_prop_handler hnd;
@@ -63,7 +63,9 @@ static void xmlreader_register_prop_handler(HashTable *prop_handler, char *name,
hnd.type = rettype;
zend_hash_add(prop_handler, name, strlen(name)+1, &hnd, sizeof(xmlreader_prop_handler), NULL);
}
+/* }}} */
+/* {{{ xmlreader_property_reader */
static int xmlreader_property_reader(xmlreader_object *obj, xmlreader_prop_handler *hnd, zval **retval TSRMLS_DC)
{
char *retchar = NULL;
@@ -106,6 +108,7 @@ static int xmlreader_property_reader(xmlreader_object *obj, xmlreader_prop_handl
return SUCCESS;
}
+/* }}} */
/* {{{ xmlreader_read_property */
zval *xmlreader_read_property(zval *object, zval *member, int type TSRMLS_DC)
@@ -185,6 +188,7 @@ void xmlreader_write_property(zval *object, zval *member, zval *value TSRMLS_DC)
}
/* }}} */
+/* {{{ _xmlreader_get_valid_file_path */
/* _xmlreader_get_valid_file_path and _xmlreader_get_relaxNG should be made a
common function in libxml extension as code is common to a few xml extensions */
char *_xmlreader_get_valid_file_path(char *source, char *resolved_path, int resolved_path_len TSRMLS_DC) {
@@ -231,8 +235,10 @@ char *_xmlreader_get_valid_file_path(char *source, char *resolved_path, int reso
return file_dest;
}
+/* }}} */
#ifdef LIBXML_SCHEMAS_ENABLED
+/* {{{ _xmlreader_get_relaxNG */
static xmlRelaxNGPtr _xmlreader_get_relaxNG(char *source, int source_len, int type,
xmlRelaxNGValidityErrorFunc error_func,
xmlRelaxNGValidityWarningFunc warn_func TSRMLS_DC)
@@ -274,6 +280,7 @@ static xmlRelaxNGPtr _xmlreader_get_relaxNG(char *source, int source_len, int ty
return sptr;
}
+/* }}} */
#endif
static zend_module_dep xmlreader_deps[] = {
@@ -309,6 +316,7 @@ void xmlreader_objects_clone(void *object, void **object_clone TSRMLS_DC)
}
/* }}} */
+/* {{{ xmlreader_free_resources */
static void xmlreader_free_resources(xmlreader_object *intern) {
if (intern) {
if (intern->input) {
@@ -328,6 +336,7 @@ static void xmlreader_free_resources(xmlreader_object *intern) {
#endif
}
}
+/* }}} */
/* {{{ xmlreader_objects_free_storage */
void xmlreader_objects_free_storage(void *object TSRMLS_DC)
@@ -368,6 +377,7 @@ zend_object_value xmlreader_objects_new(zend_class_entry *class_type TSRMLS_DC)
}
/* }}} */
+/* {{{ php_xmlreader_string_arg */
static void php_xmlreader_string_arg(INTERNAL_FUNCTION_PARAMETERS, xmlreader_read_one_char_t internal_function) {
zval *id;
int name_len = 0;
@@ -398,7 +408,9 @@ static void php_xmlreader_string_arg(INTERNAL_FUNCTION_PARAMETERS, xmlreader_rea
RETVAL_EMPTY_STRING();
}
}
+/* }}} */
+/* {{{ php_xmlreader_no_arg */
static void php_xmlreader_no_arg(INTERNAL_FUNCTION_PARAMETERS, xmlreader_read_int_t internal_function) {
zval *id;
int retval;
@@ -416,6 +428,7 @@ static void php_xmlreader_no_arg(INTERNAL_FUNCTION_PARAMETERS, xmlreader_read_in
RETURN_FALSE;
}
+/* }}} */
/* This function not yet needed until some additional functions are implemented in libxml
static void php_xmlreader_no_arg_string(INTERNAL_FUNCTION_PARAMETERS, xmlreader_read_char_t internal_function) {
@@ -439,6 +452,7 @@ static void php_xmlreader_no_arg_string(INTERNAL_FUNCTION_PARAMETERS, xmlreader_
}
*/
+/* {{{ php_xmlreader_set_relaxng_schema */
static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int type) {
#ifdef LIBXML_SCHEMAS_ENABLED
zval *id;
@@ -452,7 +466,7 @@ static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int t
}
if (source != NULL && !source_len) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Schema data source is requried");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Schema data source is required");
RETURN_FALSE;
}
@@ -490,8 +504,9 @@ static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int t
RETURN_FALSE;
#endif
}
+/* }}} */
-/* {{{ proto boolean close()
+/* {{{ proto boolean XMLReader::close()
Closes xmlreader - current frees resources until xmlTextReaderClose is fixed in libxml */
PHP_METHOD(xmlreader, close)
{
@@ -507,8 +522,9 @@ PHP_METHOD(xmlreader, close)
RETURN_TRUE;
}
+/* }}} */
-/* {{{ proto string getAttribute(string name)
+/* {{{ proto string XMLReader::getAttribute(string name)
Get value of an attribute from current element */
PHP_METHOD(xmlreader, getAttribute)
{
@@ -516,7 +532,7 @@ PHP_METHOD(xmlreader, getAttribute)
}
/* }}} */
-/* {{{ proto string getAttributeNo(int index)
+/* {{{ proto string XMLReader::getAttributeNo(int index)
Get value of an attribute at index from current element */
PHP_METHOD(xmlreader, getAttributeNo)
{
@@ -545,7 +561,7 @@ PHP_METHOD(xmlreader, getAttributeNo)
}
/* }}} */
-/* {{{ proto string getAttributeNs(string name, string namespaceURI)
+/* {{{ proto string XMLReader::getAttributeNs(string name, string namespaceURI)
Get value of a attribute via name and namespace from current element */
PHP_METHOD(xmlreader, getAttributeNs)
{
@@ -579,8 +595,8 @@ PHP_METHOD(xmlreader, getAttributeNs)
}
/* }}} */
-/* {{{ proto boolean getParserProperty(int property)
-Indicates wether given property (one of the parser option constants) is set or not on parser */
+/* {{{ proto boolean XMLReader::getParserProperty(int property)
+Indicates whether given property (one of the parser option constants) is set or not on parser */
PHP_METHOD(xmlreader, getParserProperty)
{
zval *id;
@@ -606,7 +622,7 @@ PHP_METHOD(xmlreader, getParserProperty)
}
/* }}} */
-/* {{{ proto boolean isValid()
+/* {{{ proto boolean XMLReader::isValid()
Returns boolean indicating if parsed document is valid or not.
Must set XMLREADER_LOADDTD or XMLREADER_VALIDATE parser option prior to the first call to read
or this method will always return FALSE */
@@ -616,7 +632,7 @@ PHP_METHOD(xmlreader, isValid)
}
/* }}} */
-/* {{{ proto string lookupNamespace(string prefix)
+/* {{{ proto string XMLReader::lookupNamespace(string prefix)
Return namespaceURI for associated prefix on current node */
PHP_METHOD(xmlreader, lookupNamespace)
{
@@ -624,7 +640,7 @@ PHP_METHOD(xmlreader, lookupNamespace)
}
/* }}} */
-/* {{{ proto boolean moveToAttribute(string name)
+/* {{{ proto boolean XMLReader::moveToAttribute(string name)
Positions reader at specified attribute - Returns TRUE on success and FALSE on failure */
PHP_METHOD(xmlreader, moveToAttribute)
{
@@ -656,7 +672,7 @@ PHP_METHOD(xmlreader, moveToAttribute)
}
/* }}} */
-/* {{{ proto boolean moveToAttributeNo(int index)
+/* {{{ proto boolean XMLReader::moveToAttributeNo(int index)
Positions reader at attribute at spcecified index.
Returns TRUE on success and FALSE on failure */
PHP_METHOD(xmlreader, moveToAttributeNo)
@@ -683,7 +699,7 @@ PHP_METHOD(xmlreader, moveToAttributeNo)
}
/* }}} */
-/* {{{ proto boolean moveToAttributeNs(string name, string namespaceURI)
+/* {{{ proto boolean XMLReader::moveToAttributeNs(string name, string namespaceURI)
Positions reader at attribute spcified by name and namespaceURI.
Returns TRUE on success and FALSE on failure */
PHP_METHOD(xmlreader, moveToAttributeNs)
@@ -716,7 +732,7 @@ PHP_METHOD(xmlreader, moveToAttributeNs)
}
/* }}} */
-/* {{{ proto boolean moveToElement()
+/* {{{ proto boolean XMLReader::moveToElement()
Moves the position of the current instance to the node that contains the current Attribute node. */
PHP_METHOD(xmlreader, moveToElement)
{
@@ -724,7 +740,7 @@ PHP_METHOD(xmlreader, moveToElement)
}
/* }}} */
-/* {{{ proto boolean moveToFirstAttribute()
+/* {{{ proto boolean XMLReader::moveToFirstAttribute()
Moves the position of the current instance to the first attribute associated with the current node. */
PHP_METHOD(xmlreader, moveToFirstAttribute)
{
@@ -732,7 +748,7 @@ PHP_METHOD(xmlreader, moveToFirstAttribute)
}
/* }}} */
-/* {{{ proto boolean moveToNextAttribute()
+/* {{{ proto boolean XMLReader::moveToNextAttribute()
Moves the position of the current instance to the next attribute associated with the current node. */
PHP_METHOD(xmlreader, moveToNextAttribute)
{
@@ -740,7 +756,7 @@ PHP_METHOD(xmlreader, moveToNextAttribute)
}
/* }}} */
-/* {{{ proto boolean read()
+/* {{{ proto boolean XMLReader::read()
Moves the position of the current instance to the next node in the stream. */
PHP_METHOD(xmlreader, read)
{
@@ -765,7 +781,7 @@ PHP_METHOD(xmlreader, read)
}
/* }}} */
-/* {{{ proto boolean next([string localname])
+/* {{{ proto boolean XMLReader::next([string localname])
Moves the position of the current instance to the next node in the stream. */
PHP_METHOD(xmlreader, next)
{
@@ -807,7 +823,7 @@ PHP_METHOD(xmlreader, next)
}
/* }}} */
-/* {{{ proto boolean open(string URI)
+/* {{{ proto boolean XMLReader::open(string URI)
Sets the URI that the the XMLReader will parse. */
PHP_METHOD(xmlreader, open)
{
@@ -884,7 +900,7 @@ PHP_METHOD(xmlreader, resetState)
}
*/
-/* {{{ proto boolean setParserProperty(int property, boolean value)
+/* {{{ proto boolean XMLReader::setParserProperty(int property, boolean value)
Sets parser property (one of the parser option constants).
Properties must be set after open() or XML() and before the first read() is called */
PHP_METHOD(xmlreader, setParserProperty)
@@ -913,7 +929,7 @@ PHP_METHOD(xmlreader, setParserProperty)
}
/* }}} */
-/* {{{ proto boolean setRelaxNGSchemaSource(string filename)
+/* {{{ proto boolean XMLReader::setRelaxNGSchemaSource(string filename)
Sets the string that the the XMLReader will parse. */
PHP_METHOD(xmlreader, setRelaxNGSchema)
{
@@ -921,7 +937,7 @@ PHP_METHOD(xmlreader, setRelaxNGSchema)
}
/* }}} */
-/* {{{ proto boolean setRelaxNGSchemaSource(string source)
+/* {{{ proto boolean XMLReader::setRelaxNGSchemaSource(string source)
Sets the string that the the XMLReader will parse. */
PHP_METHOD(xmlreader, setRelaxNGSchemaSource)
{
@@ -929,7 +945,7 @@ PHP_METHOD(xmlreader, setRelaxNGSchemaSource)
}
/* }}} */
-/* {{{ proto boolean XML(string source)
+/* {{{ proto boolean XMLReader::XML(string source)
Sets the string that the the XMLReader will parse. */
PHP_METHOD(xmlreader, XML)
{
@@ -1005,7 +1021,7 @@ PHP_METHOD(xmlreader, XML)
}
/* }}} */
-/* {{{ proto boolean expand()
+/* {{{ proto boolean XMLReader::expand()
Moves the position of the current instance to the next node in the stream. */
PHP_METHOD(xmlreader, expand)
{
diff --git a/ext/xmlreader/php_xmlreader.h b/ext/xmlreader/php_xmlreader.h
index 32c7d40e4..bf406e1b8 100644
--- a/ext/xmlreader/php_xmlreader.h
+++ b/ext/xmlreader/php_xmlreader.h
@@ -2,12 +2,12 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2005 The PHP Group |
+ | Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
+ | This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_0.txt. |
+ | http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_xmlreader.h,v 1.3.2.1 2005/10/13 21:20:11 rrichards Exp $ */
+/* $Id: php_xmlreader.h,v 1.3.2.2 2006/01/01 12:50:16 sniper Exp $ */
#ifndef PHP_XMLREADER_H
#define PHP_XMLREADER_H
diff --git a/ext/xmlreader/tests/001.phpt b/ext/xmlreader/tests/001.phpt
new file mode 100644
index 000000000..cf3d312b9
--- /dev/null
+++ b/ext/xmlreader/tests/001.phpt
@@ -0,0 +1,29 @@
+--TEST--
+XMLReader: libxml2 XML Reader, string data
+--SKIPIF--
+<?php if (!extension_loaded("xmlreader")) print "skip"; ?>
+--FILE--
+<?php
+/* $Id: 001.phpt,v 1.1.2.2 2005/12/21 03:58:59 pajoye Exp $ */
+
+$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
+<books></books>';
+
+$reader = new XMLReader();
+$reader->XML($xmlstring);
+
+// Only go through
+while ($reader->read()) {
+ echo $reader->name."\n";
+}
+$xmlstring = '';
+$reader = new XMLReader();
+$reader->XML($xmlstring);
+?>
+===DONE===
+--EXPECTF--
+books
+books
+
+Warning: XMLReader::XML(): Empty string supplied as input in %s on line %d
+===DONE===
diff --git a/ext/xmlreader/tests/002.phpt b/ext/xmlreader/tests/002.phpt
new file mode 100644
index 000000000..c9bf68ba1
--- /dev/null
+++ b/ext/xmlreader/tests/002.phpt
@@ -0,0 +1,41 @@
+--TEST--
+XMLReader: libxml2 XML Reader, file data
+--SKIPIF--
+<?php if (!extension_loaded("xmlreader")) print "skip"; ?>
+--FILE--
+<?php
+/* $Id: 002.phpt,v 1.1.2.3 2006/01/04 19:44:46 rrichards Exp $ */
+$filename = dirname(__FILE__) . '/_002.xml';
+$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
+<books></books>';
+file_put_contents($filename, $xmlstring);
+
+$reader = new XMLReader();
+if ($reader->open('')) exit();
+
+$reader = new XMLReader();
+if (!$reader->open($filename)) {
+ $reader->close();
+ exit();
+}
+
+// Only go through
+while ($reader->read()) {
+ echo $reader->name."\n";
+}
+$reader->close();
+unlink($filename);
+touch($filename);
+$reader = new XMLReader();
+$reader->open($filename);
+$reader->close();
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+
+Warning: XMLReader::open(): Empty string supplied as input in %s on line %d
+books
+books
+===DONE===
diff --git a/ext/xmlreader/tests/003.phpt b/ext/xmlreader/tests/003.phpt
new file mode 100644
index 000000000..bddb58dea
--- /dev/null
+++ b/ext/xmlreader/tests/003.phpt
@@ -0,0 +1,84 @@
+--TEST--
+XMLReader: libxml2 XML Reader, attributes test
+--SKIPIF--
+<?php if (!extension_loaded("xmlreader")) print "skip"; ?>
+--FILE--
+<?php
+/* $Id: 003.phpt,v 1.1.2.3 2006/01/04 19:44:46 rrichards Exp $ */
+$filename = dirname(__FILE__) . '/_002.xml';
+
+$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
+<books><book num="1" idx="2">book1</book></books>';
+file_put_contents($filename, $xmlstring);
+
+$reader = new XMLReader();
+if (!$reader->open($filename)) {
+ exit();
+}
+
+// Only go through
+while ($reader->read()) {
+ if ($reader->nodeType != XMLREADER::END_ELEMENT) {
+ if ($reader->nodeType == XMLREADER::ELEMENT && $reader->hasAttributes) {
+ $attr = $reader->moveToFirstAttribute();
+ echo $reader->name . ": ";
+ echo $reader->value . "\n";
+
+ if ($reader->getAttribute($reader->name) == $reader->value) {
+ echo "1st attr (num) failed\n";
+ }
+
+
+ $attr = $reader->moveToNextAttribute();
+ echo $reader->name . ": ";
+ echo $reader->value . "\n";
+
+ if ($reader->getAttribute($reader->name) == $reader->value) {
+ echo "2nd attr (idx) failed\n";
+ }
+
+ // Named attribute
+ $attr = $reader->moveToAttribute('num');
+ echo $reader->name . ": ";
+ echo $reader->value . "\n";
+
+ if ($reader->getAttribute('num') == $reader->value) {
+ echo "attr num failed\n";
+ }
+
+ $attr = $reader->moveToAttribute('idx');
+ echo $reader->name . ": ";
+ echo $reader->value . "\n";
+
+ if ($reader->getAttribute('idx') == $reader->value) {
+ echo "attr idx failed\n";
+ }
+
+ // Numeric positions of attributes
+ $attr = $reader->moveToAttributeNo(0);
+ echo $reader->name . ": ";
+ echo $reader->value . "\n";
+
+ if ($reader->getAttributeNo(0) == $reader->value) {
+ echo "attr 0 failed\n";
+ }
+
+ $attr = $reader->moveToAttributeNo(1);
+ echo $reader->name . ": ";
+ echo $reader->value . "\n";
+
+ }
+ }
+}
+$reader->close();
+unlink($filename);
+?>
+===DONE===
+--EXPECT--
+num: 1
+idx: 2
+num: 1
+idx: 2
+num: 1
+idx: 2
+===DONE===
diff --git a/ext/xmlreader/tests/004.phpt b/ext/xmlreader/tests/004.phpt
new file mode 100644
index 000000000..ff22cce8e
--- /dev/null
+++ b/ext/xmlreader/tests/004.phpt
@@ -0,0 +1,44 @@
+--TEST--
+XMLReader: libxml2 XML Reader, attributes test
+--SKIPIF--
+<?php if (!extension_loaded("xmlreader")) print "skip"; ?>
+--FILE--
+<?php
+/* $Id: 004.phpt,v 1.1.2.3 2006/01/04 19:44:46 rrichards Exp $ */
+$filename = dirname(__FILE__) . '/_002.xml';
+
+$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
+<books><book num="1" idx="2">book1</book></books>';
+file_put_contents($filename, $xmlstring);
+
+$reader = new XMLReader();
+if (!$reader->open($filename)) {
+ exit();
+}
+
+while ($reader->read()) {
+ if ($reader->nodeType != XMLREADER::END_ELEMENT) {
+ echo $reader->name."\n";
+ if ($reader->nodeType == XMLREADER::ELEMENT && $reader->hasAttributes) {
+ $attr = $reader->moveToFirstAttribute();
+ while ($attr) {
+ echo " Attribute Name: ".$reader->name."\n";
+ echo " Attribute Value: ".$reader->value."\n";
+ $attr = $reader->moveToNextAttribute();
+ }
+ }
+ }
+}
+$reader->close();
+unlink($filename);
+?>
+===DONE===
+--EXPECT--
+books
+book
+ Attribute Name: num
+ Attribute Value: 1
+ Attribute Name: idx
+ Attribute Value: 2
+#text
+===DONE===
diff --git a/ext/xmlreader/tests/005.phpt b/ext/xmlreader/tests/005.phpt
new file mode 100644
index 000000000..ce2a5361d
--- /dev/null
+++ b/ext/xmlreader/tests/005.phpt
@@ -0,0 +1,37 @@
+--TEST--
+XMLReader: libxml2 XML Reader, parser property set/get
+--SKIPIF--
+<?php if (!extension_loaded("xmlreader")) print "skip"; ?>
+--FILE--
+<?php
+/* $Id: 005.phpt,v 1.1.2.2 2005/12/21 03:58:59 pajoye Exp $ */
+
+$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
+<books></books>';
+
+$reader = new XMLReader();
+
+$reader->XML($xmlstring);
+
+
+$a = $reader->setParserProperty(XMLReader::LOADDTD, false);
+$b = $reader->getParserProperty(XMLReader::LOADDTD);
+
+if (!$a && !$b) {
+ echo "ok\n";
+}
+
+$a = $reader->setParserProperty(XMLReader::SUBST_ENTITIES, true);
+$b = $reader->getParserProperty(XMLReader::SUBST_ENTITIES);
+
+if ($a && $b) {
+ echo "ok\n";
+}
+// Only go through
+while ($reader->read());
+$reader->close();
+?>
+===DONE===
+--EXPECT--
+ok
+===DONE===
diff --git a/ext/xmlreader/tests/006.phpt b/ext/xmlreader/tests/006.phpt
new file mode 100644
index 000000000..d482d020b
--- /dev/null
+++ b/ext/xmlreader/tests/006.phpt
@@ -0,0 +1,36 @@
+--TEST--
+XMLReader: libxml2 XML Reader, moveToElement
+--SKIPIF--
+<?php if (!extension_loaded("xmlreader")) print "skip"; ?>
+--FILE--
+<?php
+/* $Id: 006.phpt,v 1.1.2.2 2005/12/21 03:58:59 pajoye Exp $ */
+
+$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
+<books><book num="1"></book><test /></books>';
+
+$reader = new XMLReader();
+
+$reader->XML($xmlstring);
+
+// 2 read to get on the 2nd node
+$reader->read();
+$reader->read();
+
+if ($reader->nodeType != XMLREADER::END_ELEMENT) {
+ if ($reader->nodeType == XMLREADER::ELEMENT && $reader->hasAttributes) {
+ $attr = $reader->moveToFirstAttribute();
+ if ($reader->moveToElement()) {
+ if ($reader->name == 'book') {
+ echo "ok\n";
+ }
+ }
+ }
+}
+
+$reader->close();
+?>
+===DONE===
+--EXPECT--
+ok
+===DONE===
diff --git a/ext/xmlreader/tests/007.phpt b/ext/xmlreader/tests/007.phpt
new file mode 100644
index 000000000..a94bc3859
--- /dev/null
+++ b/ext/xmlreader/tests/007.phpt
@@ -0,0 +1,57 @@
+--TEST--
+XMLReader: libxml2 XML Reader, setRelaxNGSchema
+--SKIPIF--
+<?php if (!extension_loaded("xmlreader")) print "skip"; ?>
+--FILE--
+<?php
+/* $Id: 007.phpt,v 1.1.2.2 2005/12/21 03:58:59 pajoye Exp $ */
+
+$xmlstring = '<TEI.2>hello</TEI.2>';
+$relaxngfile = dirname(__FILE__) . '/relaxNG.rng';
+$file = dirname(__FILE__) . '/__007.xml';
+file_put_contents($file, $xmlstring);
+
+$reader = new XMLReader();
+$reader->open($file);
+
+if ($reader->setRelaxNGSchema($relaxngfile)) {
+ while ($reader->read());
+}
+if ($reader->isValid()) {
+ print "file relaxNG: ok\n";
+} else {
+ print "file relaxNG: failed\n";
+}
+$reader->close();
+unlink($file);
+
+
+$reader = new XMLReader();
+$reader->XML($xmlstring);
+
+if ($reader->setRelaxNGSchema($relaxngfile)) {
+ while ($reader->read());
+}
+if ($reader->isValid()) {
+ print "string relaxNG: ok\n";
+} else {
+ print "string relaxNG: failed\n";
+}
+
+$reader->close();
+
+$reader = new XMLReader();
+$reader->XML($xmlstring);
+
+if ($reader->setRelaxNGSchema('')) {
+ echo 'failed';
+}
+$reader->close();
+?>
+===DONE===
+--EXPECTF--
+file relaxNG: ok
+string relaxNG: ok
+
+Warning: XMLReader::setRelaxNGSchema(): Schema data source is required in %s on line %d
+===DONE===
diff --git a/ext/xmlreader/tests/008.phpt b/ext/xmlreader/tests/008.phpt
new file mode 100644
index 000000000..8f3354726
--- /dev/null
+++ b/ext/xmlreader/tests/008.phpt
@@ -0,0 +1,71 @@
+--TEST--
+XMLReader: libxml2 XML Reader, DTD
+--SKIPIF--
+<?php if (!extension_loaded("xmlreader")) print "skip"; ?>
+--FILE--
+<?php
+/* $Id: 008.phpt,v 1.1.2.3 2006/01/04 19:44:46 rrichards Exp $ */
+
+$xmlstring = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE LIST SYSTEM "dtdexample.dtd">
+<LIST>
+<MOVIE ID="x200338360">
+<TITLE>Move Title 1</TITLE>
+<ORGTITLE/><LOC>Location 1</LOC>
+<INFO/>
+</MOVIE>
+<MOVIE ID="m200338361">
+<TITLE>Move Title 2</TITLE>
+<ORGTITLE/>
+<LOC>Location 2</LOC>
+<INFO/>
+</MOVIE>
+</LIST>';
+
+$dtdfile = rawurlencode(dirname(__FILE__)) . '/dtdexample.dtd';
+$file = dirname(__FILE__) . '/__008.xml';
+file_put_contents($file, $xmlstring);
+
+
+$reader = new XMLReader();
+$reader->open($file);
+$reader->setParserProperty(XMLREADER::LOADDTD, TRUE);
+$reader->setParserProperty(XMLREADER::VALIDATE, TRUE);
+while($reader->read());
+if ($reader->isValid()) {
+ echo "file DTD: ok\n";
+}
+$reader->close();
+unlink($file);
+
+$xmlstring = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE LIST SYSTEM "file:///' . $dtdfile. '">
+<LIST>
+<MOVIE ID="x200338360">
+<TITLE>Move Title 1</TITLE>
+<ORGTITLE/><LOC>Location 1</LOC>
+<INFO/>
+</MOVIE>
+<MOVIE ID="m200338361">
+<TITLE>Move Title 2</TITLE>
+<ORGTITLE/>
+<LOC>Location 2</LOC>
+<INFO/>
+</MOVIE>
+</LIST>';
+
+$reader = new XMLReader();
+$reader->XML($xmlstring);
+
+$reader->setParserProperty(XMLREADER::LOADDTD, TRUE);
+$reader->setParserProperty(XMLREADER::VALIDATE, TRUE);
+while($reader->read());
+if ($reader->isValid()) {
+ echo "string DTD: ok\n";
+}
+?>
+===DONE===
+--EXPECTF--
+file DTD: ok
+string DTD: ok
+===DONE===
diff --git a/ext/xmlreader/tests/009.phpt b/ext/xmlreader/tests/009.phpt
new file mode 100644
index 000000000..3e9957d3e
--- /dev/null
+++ b/ext/xmlreader/tests/009.phpt
@@ -0,0 +1,28 @@
+--TEST--
+XMLReader: libxml2 XML Reader, next
+--SKIPIF--
+<?php if (!extension_loaded("xmlreader")) print "skip"; ?>
+--FILE--
+<?php
+/* $Id: 009.phpt,v 1.1.2.2 2005/12/21 03:58:59 pajoye Exp $ */
+
+$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
+<books><book num="1"><test /></book><book num="2" /></books>';
+
+$reader = new XMLReader();
+$reader->XML($xmlstring);
+
+// Only go through
+$reader->read();
+$reader->read();
+
+$reader->next();
+echo $reader->name;
+echo " ";
+echo $reader->getAttribute('num');
+echo "\n";
+?>
+===DONE===
+--EXPECTF--
+book 2
+===DONE===
diff --git a/ext/xmlreader/tests/010.phpt b/ext/xmlreader/tests/010.phpt
new file mode 100644
index 000000000..37d2a8ede
--- /dev/null
+++ b/ext/xmlreader/tests/010.phpt
@@ -0,0 +1,27 @@
+--TEST--
+XMLReader: libxml2 XML Reader, next
+--SKIPIF--
+<?php if (!extension_loaded("xmlreader")) print "skip"; ?>
+--FILE--
+<?php
+/* $Id: 010.phpt,v 1.1.2.2 2005/12/21 03:58:59 pajoye Exp $ */
+$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
+<prefix:books xmlns:prefix="uri" isbn="" prefix:isbn="12isbn">book1</prefix:books>';
+
+$reader = new XMLReader();
+$reader->XML($xmlstring);
+
+// Only go through
+$reader->read();
+$reader->read();
+
+$reader->next();
+echo $reader->name;
+echo " ";
+echo $reader->getAttributeNs('isbn', 'uri');
+echo "\n";
+?>
+===DONE===
+--EXPECTF--
+prefix:books 12isbn
+===DONE===
diff --git a/ext/xmlreader/tests/dtdexample.dtd b/ext/xmlreader/tests/dtdexample.dtd
new file mode 100644
index 000000000..ce53f0bc1
--- /dev/null
+++ b/ext/xmlreader/tests/dtdexample.dtd
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!ELEMENT LIST (MOVIE+)>
+<!ELEMENT MOVIE (TITLE, ORGTITLE, LOC, INFO)>
+<!ATTLIST MOVIE ID ID #REQUIRED>
+<!ELEMENT TITLE (#PCDATA)>
+<!ELEMENT ORGTITLE (#PCDATA)>
+<!ELEMENT LOC (#PCDATA)>
+<!ELEMENT INFO (#PCDATA)>
diff --git a/ext/xmlreader/tests/relaxNG.rng b/ext/xmlreader/tests/relaxNG.rng
new file mode 100644
index 000000000..f4357e04e
--- /dev/null
+++ b/ext/xmlreader/tests/relaxNG.rng
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<grammar xmlns="http://relaxng.org/ns/structure/1.0"
+ datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+
+<include href="relaxNG2.rng">
+<define name="TEI.prose"><ref name="INCLUDE"/></define>
+</include>
+</grammar>
+
+
+
diff --git a/ext/xmlreader/tests/relaxNG2.rng b/ext/xmlreader/tests/relaxNG2.rng
new file mode 100644
index 000000000..4adae7b15
--- /dev/null
+++ b/ext/xmlreader/tests/relaxNG2.rng
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:t="http://www.thaiopensource.com/ns/annotations" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+
+ <start>
+ <ref name="TEI.2"/>
+ </start>
+ <define name="IGNORE">
+ <notAllowed/>
+ </define>
+ <define name="INCLUDE">
+ <empty/>
+ </define>
+
+
+ <include href="relaxNG3.rng"/>
+
+ <define name="TEI.2">
+ <element name="TEI.2">
+ <text/>
+ </element>
+ </define>
+
+</grammar> \ No newline at end of file
diff --git a/ext/xmlreader/tests/relaxNG3.rng b/ext/xmlreader/tests/relaxNG3.rng
new file mode 100644
index 000000000..73e1eb616
--- /dev/null
+++ b/ext/xmlreader/tests/relaxNG3.rng
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:t="http://www.thaiopensource.com/ns/annotations" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+
+ <define name="TEI.prose" combine="interleave">
+ <ref name="IGNORE"/>
+ </define>
+
+</grammar> \ No newline at end of file