Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Change package structure; update constants, php5ize

git-svn-id: http://svn.php.net/repository/pear/packages/XML_Util2/trunk@313960 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit a7b25923b835927ca359fcebd07eb402e3233603 1 parent 6fa1369
Daniel O'Connor CloCkWeRX authored
272 Util.php → XML/Util2.php
View
@@ -3,11 +3,11 @@
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
- * XML_Util
+ * XML_Util2
*
* XML Utilities package
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
@@ -39,101 +39,100 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category XML
- * @package XML_Util
+ * @package XML_Util2
* @author Stephan Schmidt <schst@php.net>
* @copyright 2003-2008 Stephan Schmidt <schst@php.net>
* @license http://opensource.org/licenses/bsd-license New BSD License
* @version CVS: $Id$
- * @link http://pear.php.net/package/XML_Util
+ * @link http://pear.php.net/package/XML_Util2
*/
/**
* error code for invalid chars in XML name
*/
-define('XML_UTIL_ERROR_INVALID_CHARS', 51);
+define('XML_UTIL2_ERROR_INVALID_CHARS', 51);
/**
* error code for invalid chars in XML name
*/
-define('XML_UTIL_ERROR_INVALID_START', 52);
+define('XML_UTIL2_ERROR_INVALID_START', 52);
/**
* error code for non-scalar tag content
*/
-define('XML_UTIL_ERROR_NON_SCALAR_CONTENT', 60);
+define('XML_UTIL2_ERROR_NON_SCALAR_CONTENT', 60);
/**
* error code for missing tag name
*/
-define('XML_UTIL_ERROR_NO_TAG_NAME', 61);
+define('XML_UTIL2_ERROR_NO_TAG_NAME', 61);
/**
* replace XML entities
*/
-define('XML_UTIL_REPLACE_ENTITIES', 1);
+define('XML_UTIL2_REPLACE_ENTITIES', 1);
/**
* embedd content in a CData Section
*/
-define('XML_UTIL_CDATA_SECTION', 5);
+define('XML_UTIL2_CDATA_SECTION', 5);
/**
* do not replace entitites
*/
-define('XML_UTIL_ENTITIES_NONE', 0);
+define('XML_UTIL2_ENTITIES_NONE', 0);
/**
* replace all XML entitites
* This setting will replace <, >, ", ' and &
*/
-define('XML_UTIL_ENTITIES_XML', 1);
+define('XML_UTIL2_ENTITIES_XML', 1);
/**
* replace only required XML entitites
* This setting will replace <, " and &
*/
-define('XML_UTIL_ENTITIES_XML_REQUIRED', 2);
+define('XML_UTIL2_ENTITIES_XML_REQUIRED', 2);
/**
* replace HTML entitites
* @link http://www.php.net/htmlentities
*/
-define('XML_UTIL_ENTITIES_HTML', 3);
+define('XML_UTIL2_ENTITIES_HTML', 3);
/**
* Collapse all empty tags.
*/
-define('XML_UTIL_COLLAPSE_ALL', 1);
+define('XML_UTIL2_COLLAPSE_ALL', 1);
/**
* Collapse only empty XHTML tags that have no end tag.
*/
-define('XML_UTIL_COLLAPSE_XHTML_ONLY', 2);
+define('XML_UTIL2_COLLAPSE_XHTML_ONLY', 2);
/**
* utility class for working with XML documents
*
* @category XML
- * @package XML_Util
+ * @package XML_Util2
* @author Stephan Schmidt <schst@php.net>
* @copyright 2003-2008 Stephan Schmidt <schst@php.net>
* @license http://opensource.org/licenses/bsd-license New BSD License
* @version Release: @version@
- * @link http://pear.php.net/package/XML_Util
+ * @link http://pear.php.net/package/XML_Util2
*/
-class XML_Util
+class XML_Util2
{
/**
* return API version
*
* @return string $version API version
* @access public
- * @static
*/
- function apiVersion()
+ public function apiVersion()
{
- return '1.1';
+ return '2.0';
}
/**
@@ -143,20 +142,24 @@ function apiVersion()
* entities should be replaced.
*
* <code>
- * require_once 'XML/Util.php';
+ * require_once 'XML/Util2.php';
+ *
+ * $util = new XML_Util2();
*
* // replace XML entites:
- * $string = XML_Util::replaceEntities('This string contains < & >.');
+ * $string = $util->replaceEntities('This string contains < & >.');
* </code>
*
* With the optional third parameter, you may pass the character encoding
* <code>
- * require_once 'XML/Util.php';
+ * require_once 'XML/Util2.php';
+ *
+ * $util = new XML_Util2();
*
* // replace XML entites in UTF-8:
- * $string = XML_Util::replaceEntities(
+ * $string = $util->replaceEntities(
* 'This string contains < & > as well as ä, ö, ß, à and ê',
- * XML_UTIL_ENTITIES_HTML,
+ * XML_UTIL2_ENTITIES_HTML,
* 'UTF-8'
* );
* </code>
@@ -164,23 +167,22 @@ function apiVersion()
* @param string $string string where XML special chars
* should be replaced
* @param int $replaceEntities setting for entities in attribute values
- * (one of XML_UTIL_ENTITIES_XML,
- * XML_UTIL_ENTITIES_XML_REQUIRED,
- * XML_UTIL_ENTITIES_HTML)
+ * (one of XML_UTIL2_ENTITIES_XML,
+ * XML_UTIL2_ENTITIES_XML_REQUIRED,
+ * XML_UTIL2_ENTITIES_HTML)
* @param string $encoding encoding value (if any)...
* must be a valid encoding as determined
* by the htmlentities() function
*
* @return string string with replaced chars
* @access public
- * @static
* @see reverseEntities()
*/
- function replaceEntities($string, $replaceEntities = XML_UTIL_ENTITIES_XML,
+ public function replaceEntities($string, $replaceEntities = XML_UTIL2_ENTITIES_XML,
$encoding = 'ISO-8859-1')
{
switch ($replaceEntities) {
- case XML_UTIL_ENTITIES_XML:
+ case XML_UTIL2_ENTITIES_XML:
return strtr($string, array(
'&' => '&amp;',
'>' => '&gt;',
@@ -188,13 +190,13 @@ function replaceEntities($string, $replaceEntities = XML_UTIL_ENTITIES_XML,
'"' => '&quot;',
'\'' => '&apos;' ));
break;
- case XML_UTIL_ENTITIES_XML_REQUIRED:
+ case XML_UTIL2_ENTITIES_XML_REQUIRED:
return strtr($string, array(
'&' => '&amp;',
'<' => '&lt;',
'"' => '&quot;' ));
break;
- case XML_UTIL_ENTITIES_HTML:
+ case XML_UTIL2_ENTITIES_HTML:
return htmlentities($string, ENT_COMPAT, $encoding);
break;
}
@@ -208,21 +210,25 @@ function replaceEntities($string, $replaceEntities = XML_UTIL_ENTITIES_XML,
* entities should be reversed.
*
* <code>
- * require_once 'XML/Util.php';
+ * require_once 'XML/Util2.php';
+ *
+ * $util = new XML_Util2();
*
* // reverse XML entites:
- * $string = XML_Util::reverseEntities('This string contains &lt; &amp; &gt;.');
+ * $string = $util->reverseEntities('This string contains &lt; &amp; &gt;.');
* </code>
*
* With the optional third parameter, you may pass the character encoding
* <code>
- * require_once 'XML/Util.php';
+ * require_once 'XML/Util2.php';
+ *
+ * $util = new XML_Util2();
*
* // reverse XML entites in UTF-8:
- * $string = XML_Util::reverseEntities(
+ * $string = $util->reverseEntities(
* 'This string contains &lt; &amp; &gt; as well as'
* . ' &auml;, &ouml;, &szlig;, &agrave; and &ecirc;',
- * XML_UTIL_ENTITIES_HTML,
+ * XML_UTIL2_ENTITIES_HTML,
* 'UTF-8'
* );
* </code>
@@ -230,23 +236,22 @@ function replaceEntities($string, $replaceEntities = XML_UTIL_ENTITIES_XML,
* @param string $string string where XML special chars
* should be replaced
* @param int $replaceEntities setting for entities in attribute values
- * (one of XML_UTIL_ENTITIES_XML,
- * XML_UTIL_ENTITIES_XML_REQUIRED,
- * XML_UTIL_ENTITIES_HTML)
+ * (one of XML_UTIL2_ENTITIES_XML,
+ * XML_UTIL2_ENTITIES_XML_REQUIRED,
+ * XML_UTIL2_ENTITIES_HTML)
* @param string $encoding encoding value (if any)...
* must be a valid encoding as determined
* by the html_entity_decode() function
*
* @return string string with replaced chars
* @access public
- * @static
* @see replaceEntities()
*/
- function reverseEntities($string, $replaceEntities = XML_UTIL_ENTITIES_XML,
+ public function reverseEntities($string, $replaceEntities = XML_UTIL2_ENTITIES_XML,
$encoding = 'ISO-8859-1')
{
switch ($replaceEntities) {
- case XML_UTIL_ENTITIES_XML:
+ case XML_UTIL2_ENTITIES_XML:
return strtr($string, array(
'&amp;' => '&',
'&gt;' => '>',
@@ -254,13 +259,13 @@ function reverseEntities($string, $replaceEntities = XML_UTIL_ENTITIES_XML,
'&quot;' => '"',
'&apos;' => '\'' ));
break;
- case XML_UTIL_ENTITIES_XML_REQUIRED:
+ case XML_UTIL2_ENTITIES_XML_REQUIRED:
return strtr($string, array(
'&amp;' => '&',
'&lt;' => '<',
'&quot;' => '"' ));
break;
- case XML_UTIL_ENTITIES_HTML:
+ case XML_UTIL2_ENTITIES_HTML:
return html_entity_decode($string, ENT_COMPAT, $encoding);
break;
}
@@ -271,10 +276,12 @@ function reverseEntities($string, $replaceEntities = XML_UTIL_ENTITIES_XML,
* build an xml declaration
*
* <code>
- * require_once 'XML/Util.php';
+ * require_once 'XML/Util2.php';
+ *
+ * $util = new XML_Util2();
*
* // get an XML declaration:
- * $xmlDecl = XML_Util::getXMLDeclaration('1.0', 'UTF-8', true);
+ * $xmlDecl = $util->getXMLDeclaration('1.0', 'UTF-8', true);
* </code>
*
* @param string $version xml version
@@ -283,10 +290,9 @@ function reverseEntities($string, $replaceEntities = XML_UTIL_ENTITIES_XML,
*
* @return string xml declaration
* @access public
- * @static
* @uses attributesToString() to serialize the attributes of the XML declaration
*/
- function getXMLDeclaration($version = '1.0', $encoding = null,
+ public function getXMLDeclaration($version = '1.0', $encoding = null,
$standalone = null)
{
$attributes = array(
@@ -302,17 +308,20 @@ function getXMLDeclaration($version = '1.0', $encoding = null,
}
return sprintf('<?xml%s?>',
- XML_Util::attributesToString($attributes, false));
+ $this->attributesToString($attributes, false));
}
/**
* build a document type declaration
*
* <code>
- * require_once 'XML/Util.php';
+ * require_once 'XML/Util2.php';
+ *
+ * $util = new XML_Util2();
*
* // get a doctype declaration:
- * $xmlDecl = XML_Util::getDocTypeDeclaration('rootTag','myDocType.dtd');
+ * $util = new XML_Util2();
+ * $xmlDecl = $util->getDocTypeDeclaration('rootTag','myDocType.dtd');
* </code>
*
* @param string $root name of the root tag
@@ -322,10 +331,9 @@ function getXMLDeclaration($version = '1.0', $encoding = null,
*
* @return string doctype declaration
* @access public
- * @static
* @since 0.2
*/
- function getDocTypeDeclaration($root, $uri = null, $internalDtd = null)
+ public function getDocTypeDeclaration($root, $uri = null, $internalDtd = null)
{
if (is_array($uri)) {
$ref = sprintf(' PUBLIC "%s" "%s"', $uri['id'], $uri['uri']);
@@ -346,7 +354,9 @@ function getDocTypeDeclaration($root, $uri = null, $internalDtd = null)
* create string representation of an attribute list
*
* <code>
- * require_once 'XML/Util.php';
+ * require_once 'XML/Util2.php';
+ *
+ * $util = new XML_Util2();
*
* // build an attribute string
* $att = array(
@@ -354,7 +364,8 @@ function getDocTypeDeclaration($root, $uri = null, $internalDtd = null)
* 'argh' => 'tomato'
* );
*
- * $attList = XML_Util::attributesToString($att);
+ * $util = new XML_Util2();
+ * $attList = $util->attributesToString($att);
* </code>
*
* @param array $attributes attribute array
@@ -369,19 +380,18 @@ function getDocTypeDeclaration($root, $uri = null, $internalDtd = null)
* @param string $linebreak string used for linebreaks of
* multiline attributes
* @param int $entities setting for entities in attribute values
- * (one of XML_UTIL_ENTITIES_NONE,
- * XML_UTIL_ENTITIES_XML,
- * XML_UTIL_ENTITIES_XML_REQUIRED,
- * XML_UTIL_ENTITIES_HTML)
+ * (one of XML_UTIL2_ENTITIES_NONE,
+ * XML_UTIL2_ENTITIES_XML,
+ * XML_UTIL2_ENTITIES_XML_REQUIRED,
+ * XML_UTIL2_ENTITIES_HTML)
*
* @return string string representation of the attributes
* @access public
- * @static
* @uses replaceEntities() to replace XML entities in attribute values
* @todo allow sort also to be an options array
*/
- function attributesToString($attributes, $sort = true, $multiline = false,
- $indent = ' ', $linebreak = "\n", $entities = XML_UTIL_ENTITIES_XML)
+ public function attributesToString($attributes, $sort = true, $multiline = false,
+ $indent = ' ', $linebreak = "\n", $entities = XML_UTIL2_ENTITIES_XML)
{
/*
* second parameter may be an array
@@ -412,19 +422,19 @@ function attributesToString($attributes, $sort = true, $multiline = false,
}
if ( !$multiline || count($attributes) == 1) {
foreach ($attributes as $key => $value) {
- if ($entities != XML_UTIL_ENTITIES_NONE) {
- if ($entities === XML_UTIL_CDATA_SECTION) {
- $entities = XML_UTIL_ENTITIES_XML;
+ if ($entities != XML_UTIL2_ENTITIES_NONE) {
+ if ($entities === XML_UTIL2_CDATA_SECTION) {
+ $entities = XML_UTIL2_ENTITIES_XML;
}
- $value = XML_Util::replaceEntities($value, $entities);
+ $value = $this->replaceEntities($value, $entities);
}
$string .= ' ' . $key . '="' . $value . '"';
}
} else {
$first = true;
foreach ($attributes as $key => $value) {
- if ($entities != XML_UTIL_ENTITIES_NONE) {
- $value = XML_Util::replaceEntities($value, $entities);
+ if ($entities != XML_UTIL2_ENTITIES_NONE) {
+ $value = $this->replaceEntities($value, $entities);
}
if ($first) {
$string .= ' ' . $key . '="' . $value . '"';
@@ -442,18 +452,17 @@ function attributesToString($attributes, $sort = true, $multiline = false,
* Collapses empty tags.
*
* @param string $xml XML
- * @param int $mode Whether to collapse all empty tags (XML_UTIL_COLLAPSE_ALL)
- * or only XHTML (XML_UTIL_COLLAPSE_XHTML_ONLY) ones.
+ * @param int $mode Whether to collapse all empty tags (XML_UTIL2_COLLAPSE_ALL)
+ * or only XHTML (XML_UTIL2_COLLAPSE_XHTML_ONLY) ones.
*
* @return string XML
* @access public
- * @static
* @todo PEAR CS - unable to avoid "space after open parens" error
* in the IF branch
*/
- function collapseEmptyTags($xml, $mode = XML_UTIL_COLLAPSE_ALL)
+ public function collapseEmptyTags($xml, $mode = XML_UTIL2_COLLAPSE_ALL)
{
- if ($mode == XML_UTIL_COLLAPSE_XHTML_ONLY) {
+ if ($mode == XML_UTIL2_COLLAPSE_XHTML_ONLY) {
return preg_replace(
'/<(area|base(?:font)?|br|col|frame|hr|img|input|isindex|link|meta|'
. 'param)([^>]*)><\/\\1>/s',
@@ -467,14 +476,16 @@ function collapseEmptyTags($xml, $mode = XML_UTIL_COLLAPSE_ALL)
/**
* create a tag
*
- * This method will call XML_Util::createTagFromArray(), which
+ * This method will call XML_Util2::createTagFromArray(), which
* is more flexible.
*
* <code>
- * require_once 'XML/Util.php';
+ * require_once 'XML/Util2.php';
+ *
+ * $util = new XML_Util2();
*
* // create an XML tag:
- * $tag = XML_Util::createTag('myNs:myTag',
+ * $tag = $util->createTag('myNs:myTag',
* array('foo' => 'bar'),
* 'This is inside the tag',
* 'http://www.w3c.org/myNs#');
@@ -497,12 +508,11 @@ function collapseEmptyTags($xml, $mode = XML_UTIL_COLLAPSE_ALL)
*
* @return string XML tag
* @access public
- * @static
* @see createTagFromArray()
* @uses createTagFromArray() to create the tag
*/
- function createTag($qname, $attributes = array(), $content = null,
- $namespaceUri = null, $replaceEntities = XML_UTIL_REPLACE_ENTITIES,
+ public function createTag($qname, $attributes = array(), $content = null,
+ $namespaceUri = null, $replaceEntities = XML_UTIL2_REPLACE_ENTITIES,
$multiline = false, $indent = '_auto', $linebreak = "\n",
$sortAttributes = true)
{
@@ -521,7 +531,7 @@ function createTag($qname, $attributes = array(), $content = null,
$tag['namespaceUri'] = $namespaceUri;
}
- return XML_Util::createTagFromArray($tag, $replaceEntities, $multiline,
+ return $this->createTagFromArray($tag, $replaceEntities, $multiline,
$indent, $linebreak, $sortAttributes);
}
@@ -551,7 +561,9 @@ function createTag($qname, $attributes = array(), $content = null,
* </pre>
*
* <code>
- * require_once 'XML/Util.php';
+ * require_once 'XML/Util2.php';
+ *
+ * $util = new XML_Util2();
*
* $tag = array(
* 'qname' => 'foo:bar',
@@ -560,7 +572,7 @@ function createTag($qname, $attributes = array(), $content = null,
* 'content' => 'I\'m inside the tag',
* );
* // creating a tag with qualified name and namespaceUri
- * $string = XML_Util::createTagFromArray($tag);
+ * $string = $util->createTagFromArray($tag);
* </code>
*
* @param array $tag tag definition
@@ -577,26 +589,25 @@ function createTag($qname, $attributes = array(), $content = null,
*
* @return string XML tag
* @access public
- * @static
* @see createTag()
* @uses attributesToString() to serialize the attributes of the tag
* @uses splitQualifiedName() to get local part and namespace of a qualified name
* @uses createCDataSection()
* @uses raiseError()
*/
- function createTagFromArray($tag, $replaceEntities = XML_UTIL_REPLACE_ENTITIES,
+ public function createTagFromArray($tag, $replaceEntities = XML_UTIL2_REPLACE_ENTITIES,
$multiline = false, $indent = '_auto', $linebreak = "\n",
$sortAttributes = true)
{
if (isset($tag['content']) && !is_scalar($tag['content'])) {
- return XML_Util::raiseError('Supplied non-scalar value as tag content',
- XML_UTIL_ERROR_NON_SCALAR_CONTENT);
+ return $this->raiseError('Supplied non-scalar value as tag content',
+ XML_UTIL2_ERROR_NON_SCALAR_CONTENT);
}
if (!isset($tag['qname']) && !isset($tag['localPart'])) {
- return XML_Util::raiseError('You must either supply a qualified name '
+ return $this->raiseError('You must either supply a qualified name '
. '(qname) or local tag name (localPart).',
- XML_UTIL_ERROR_NO_TAG_NAME);
+ XML_UTIL2_ERROR_NO_TAG_NAME);
}
// if no attributes hav been set, use empty attributes
@@ -622,7 +633,7 @@ function createTagFromArray($tag, $replaceEntities = XML_UTIL_REPLACE_ENTITIES,
} elseif (isset($tag['namespaceUri']) && !isset($tag['namespace'])) {
// namespace URI is set, but no namespace
- $parts = XML_Util::splitQualifiedName($tag['qname']);
+ $parts = $this->splitQualifiedName($tag['qname']);
$tag['localPart'] = $parts['localPart'];
if (isset($parts['namespace'])) {
@@ -649,19 +660,19 @@ function createTagFromArray($tag, $replaceEntities = XML_UTIL_REPLACE_ENTITIES,
}
// create attribute list
- $attList = XML_Util::attributesToString($tag['attributes'],
+ $attList = $this->attributesToString($tag['attributes'],
$sortAttributes, $multiline, $indent, $linebreak, $replaceEntities);
if (!isset($tag['content']) || (string)$tag['content'] == '') {
$tag = sprintf('<%s%s />', $tag['qname'], $attList);
} else {
switch ($replaceEntities) {
- case XML_UTIL_ENTITIES_NONE:
+ case XML_UTIL2_ENTITIES_NONE:
break;
- case XML_UTIL_CDATA_SECTION:
- $tag['content'] = XML_Util::createCDataSection($tag['content']);
+ case XML_UTIL2_CDATA_SECTION:
+ $tag['content'] = $this->createCDataSection($tag['content']);
break;
default:
- $tag['content'] = XML_Util::replaceEntities($tag['content'],
+ $tag['content'] = $this->replaceEntities($tag['content'],
$replaceEntities);
break;
}
@@ -675,10 +686,12 @@ function createTagFromArray($tag, $replaceEntities = XML_UTIL_REPLACE_ENTITIES,
* create a start element
*
* <code>
- * require_once 'XML/Util.php';
+ * require_once 'XML/Util2.php';
+ *
+ * $util = new XML_Util2();
*
* // create an XML start element:
- * $tag = XML_Util::createStartElement('myNs:myTag',
+ * $tag = $util->createStartElement('myNs:myTag',
* array('foo' => 'bar') ,'http://www.w3c.org/myNs#');
* </code>
*
@@ -694,10 +707,9 @@ function createTagFromArray($tag, $replaceEntities = XML_UTIL_REPLACE_ENTITIES,
*
* @return string XML start element
* @access public
- * @static
* @see createEndElement(), createTag()
*/
- function createStartElement($qname, $attributes = array(), $namespaceUri = null,
+ public function createStartElement($qname, $attributes = array(), $namespaceUri = null,
$multiline = false, $indent = '_auto', $linebreak = "\n",
$sortAttributes = true)
{
@@ -707,7 +719,7 @@ function createStartElement($qname, $attributes = array(), $namespaceUri = null,
}
if ($namespaceUri != null) {
- $parts = XML_Util::splitQualifiedName($qname);
+ $parts = $this->splitQualifiedName($qname);
}
// check for multiline attributes
@@ -728,7 +740,7 @@ function createStartElement($qname, $attributes = array(), $namespaceUri = null,
}
// create attribute list
- $attList = XML_Util::attributesToString($attributes, $sortAttributes,
+ $attList = $this->attributesToString($attributes, $sortAttributes,
$multiline, $indent, $linebreak);
$element = sprintf('<%s%s>', $qname, $attList);
return $element;
@@ -738,20 +750,21 @@ function createStartElement($qname, $attributes = array(), $namespaceUri = null,
* create an end element
*
* <code>
- * require_once 'XML/Util.php';
+ * require_once 'XML/Util2.php';
+ *
+ * $util = new XML_Util2();
*
* // create an XML start element:
- * $tag = XML_Util::createEndElement('myNs:myTag');
+ * $tag = $util->createEndElement('myNs:myTag');
* </code>
*
* @param string $qname qualified tagname (including namespace)
*
* @return string XML end element
* @access public
- * @static
* @see createStartElement(), createTag()
*/
- function createEndElement($qname)
+ public function createEndElement($qname)
{
$element = sprintf('</%s>', $qname);
return $element;
@@ -761,19 +774,20 @@ function createEndElement($qname)
* create an XML comment
*
* <code>
- * require_once 'XML/Util.php';
+ * require_once 'XML/Util2.php';
+ *
+ * $util = new XML_Util2();
*
* // create an XML start element:
- * $tag = XML_Util::createComment('I am a comment');
+ * $tag = $util->createComment('I am a comment');
* </code>
*
* @param string $content content of the comment
*
* @return string XML comment
* @access public
- * @static
*/
- function createComment($content)
+ public function createComment($content)
{
$comment = sprintf('<!-- %s -->', $content);
return $comment;
@@ -783,17 +797,18 @@ function createComment($content)
* create a CData section
*
* <code>
- * require_once 'XML/Util.php';
+ * require_once 'XML/Util2.php';
+ *
+ * $util = new XML_Util2();
*
* // create a CData section
- * $tag = XML_Util::createCDataSection('I am content.');
+ * $tag = $util->createCDataSection('I am content.');
* </code>
*
* @param string $data data of the CData section
*
* @return string CData section with content
* @access public
- * @static
*/
function createCDataSection($data)
{
@@ -806,10 +821,12 @@ function createCDataSection($data)
* split qualified name and return namespace and local part
*
* <code>
- * require_once 'XML/Util.php';
+ * require_once 'XML/Util2.php';
+ *
+ * $util = new XML_Util2();
*
* // split qualified tag
- * $parts = XML_Util::splitQualifiedName('xslt:stylesheet');
+ * $parts = $util->splitQualifiedName('xslt:stylesheet');
* </code>
* the returned array will contain two elements:
* <pre>
@@ -824,7 +841,6 @@ function createCDataSection($data)
*
* @return array array containing namespace and local part
* @access public
- * @static
*/
function splitQualifiedName($qname, $defaultNs = null)
{
@@ -851,10 +867,12 @@ function splitQualifiedName($qname, $defaultNs = null)
* or an underscore.</p>
*
* <code>
- * require_once 'XML/Util.php';
+ * require_once 'XML/Util2.php';
+ *
+ * $util = new XML_Util2();
*
* // verify tag name
- * $result = XML_Util::isValidName('invalidTag?');
+ * $result = $util->isValidName('invalidTag?');
* if (is_a($result, 'PEAR_Error')) {
* print 'Invalid XML name: ' . $result->getMessage();
* }
@@ -864,7 +882,6 @@ function splitQualifiedName($qname, $defaultNs = null)
*
* @return mixed true, if string is a valid XML name, PEAR error otherwise
* @access public
- * @static
* @todo support for other charsets
* @todo PEAR CS - unable to avoid 85-char limit on second preg_match
*/
@@ -872,24 +889,24 @@ function isValidName($string)
{
// check for invalid chars
if (!preg_match('/^[[:alpha:]_]\\z/', $string{0})) {
- return XML_Util::raiseError('XML names may only start with letter '
- . 'or underscore', XML_UTIL_ERROR_INVALID_START);
+ return $this->raiseError('XML names may only start with letter '
+ . 'or underscore', XML_UTIL2_ERROR_INVALID_START);
}
// check for invalid chars
if (!preg_match('/^([[:alpha:]_]([[:alnum:]\-\.]*)?:)?[[:alpha:]_]([[:alnum:]\_\-\.]+)?\\z/',
$string)
) {
- return XML_Util::raiseError('XML names may only contain alphanumeric '
+ return $this->raiseError('XML names may only contain alphanumeric '
. 'chars, period, hyphen, colon and underscores',
- XML_UTIL_ERROR_INVALID_CHARS);
+ XML_UTIL2_ERROR_INVALID_CHARS);
}
// XML name is valid
return true;
}
/**
- * replacement for XML_Util::raiseError
+ * replacement for $this->raiseError
*
* Avoids the necessity to always require
* PEAR.php
@@ -899,10 +916,9 @@ function isValidName($string)
*
* @return PEAR_Error
* @access public
- * @static
* @todo PEAR CS - should this use include_once instead?
*/
- function raiseError($msg, $code)
+ public function raiseError($msg, $code)
{
require_once 'PEAR.php';
return PEAR::raiseError($msg, $code);
58 examples/example.php
View
@@ -5,9 +5,9 @@
/**
* Examples (file #1)
*
- * several examples for the methods of XML_Util
+ * several examples for the methods of XML_Util2
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
@@ -39,13 +39,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category XML
- * @package XML_Util
+ * @package XML_Util2
* @subpackage Examples
* @author Stephan Schmidt <schst@php.net>
* @copyright 2003-2008 Stephan Schmidt <schst@php.net>
* @license http://opensource.org/licenses/bsd-license New BSD License
* @version CVS: $Id$
- * @link http://pear.php.net/package/XML_Util
+ * @link http://pear.php.net/package/XML_Util2
*/
/**
@@ -53,50 +53,52 @@
*/
error_reporting(E_ALL);
- require_once 'XML/Util.php';
+ require_once 'XML/Util2.php';
+
+ $util = new XML_Util2();
/**
* replacing XML entities
*/
print 'replace XML entities:<br>';
- print XML_Util::replaceEntities('This string contains < & >.');
+ print $util->replaceEntities('This string contains < & >.');
print "\n<br><br>\n";
/**
* reversing XML entities
*/
print 'replace XML entities:<br>';
- print XML_Util::reverseEntities('This string contains &lt; &amp; &gt;.');
+ print $util->everseEntities('This string contains &lt; &amp; &gt;.');
print "\n<br><br>\n";
/**
* building XML declaration
*/
print 'building XML declaration:<br>';
- print htmlspecialchars(XML_Util::getXMLDeclaration());
+ print htmlspecialchars($util->getXMLDeclaration());
print "\n<br><br>\n";
print 'building XML declaration with additional attributes:<br>';
- print htmlspecialchars(XML_Util::getXMLDeclaration('1.0', 'UTF-8', true));
+ print htmlspecialchars($util->getXMLDeclaration('1.0', 'UTF-8', true));
print "\n<br><br>\n";
/**
* building document type declaration
*/
print 'building DocType declaration:<br>';
- print htmlspecialchars(XML_Util::getDocTypeDeclaration('package',
+ print htmlspecialchars($util->getDocTypeDeclaration('package',
'http://pear.php.net/dtd/package-1.0'));
print "\n<br><br>\n";
print 'building DocType declaration with public ID (does not exist):<br>';
- print htmlspecialchars(XML_Util::getDocTypeDeclaration('package',
+ print htmlspecialchars($util->getDocTypeDeclaration('package',
array('uri' => 'http://pear.php.net/dtd/package-1.0',
'id' => '-//PHP//PEAR/DTD PACKAGE 0.1')));
print "\n<br><br>\n";
print 'building DocType declaration with internal DTD:<br>';
print '<pre>';
- print htmlspecialchars(XML_Util::getDocTypeDeclaration('package',
+ print htmlspecialchars($util->getDocTypeDeclaration('package',
'http://pear.php.net/dtd/package-1.0',
'<!ELEMENT additionalInfo (#PCDATA)>'));
print '</pre>';
@@ -111,7 +113,7 @@
);
print 'converting array to string:<br>';
- print XML_Util::attributesToString($att);
+ print $util->attributesToString($att);
print "\n<br><br>\n";
@@ -125,7 +127,7 @@
print 'converting array to string (including line breaks):<br>';
print '<pre>';
- print XML_Util::attributesToString($att, true, true);
+ print $util->attributesToString($att, true, true);
print '</pre>';
print "\n<br><br>\n";
@@ -135,7 +137,7 @@
*/
print 'splitting qualified tag name:<br>';
print '<pre>';
- print_r(XML_Util::splitQualifiedName('xslt:stylesheet'));
+ print_r($util->splitQualifiedName('xslt:stylesheet'));
print '</pre>';
print "\n<br>\n";
@@ -145,7 +147,7 @@
*/
print 'splitting qualified tag name (no namespace):<br>';
print '<pre>';
- print_r(XML_Util::splitQualifiedName('foo'));
+ print_r($util->splitQualifiedName('foo'));
print '</pre>';
print "\n<br>\n";
@@ -155,7 +157,7 @@
print 'splitting qualified tag name '
. '(no namespace, but default namespace specified):<br>';
print '<pre>';
- print_r(XML_Util::splitQualifiedName('foo', 'bar'));
+ print_r($util->splitQualifiedName('foo', 'bar'));
print '</pre>';
print "\n<br>\n";
@@ -164,13 +166,13 @@
*/
print 'verifying \'My private tag\':<br>';
print '<pre>';
- print_r(XML_Util::isValidname('My Private Tag'));
+ print_r($util->isValidname('My Private Tag'));
print '</pre>';
print "\n<br><br>\n";
print 'verifying \'-MyTag\':<br>';
print '<pre>';
- print_r(XML_Util::isValidname('-MyTag'));
+ print_r($util->isValidname('-MyTag'));
print '</pre>';
print "\n<br><br>\n";
@@ -185,7 +187,7 @@
);
print 'creating a tag with namespace and local part:<br>';
- print htmlentities(XML_Util::createTagFromArray($tag));
+ print htmlentities($util->createTagFromArray($tag));
print "\n<br><br>\n";
/**
@@ -199,7 +201,7 @@
);
print 'creating a tag with qualified name and namespaceUri:<br>';
- print htmlentities(XML_Util::createTagFromArray($tag));
+ print htmlentities($util->createTagFromArray($tag));
print "\n<br><br>\n";
/**
@@ -212,7 +214,7 @@
);
print 'creating an empty tag without namespace but namespace Uri:<br>';
- print htmlentities(XML_Util::createTagFromArray($tag));
+ print htmlentities($util->createTagFromArray($tag));
print "\n<br><br>\n";
/**
@@ -230,7 +232,7 @@
);
print 'creating an XML tag with more namespaces:<br />';
- print htmlentities(XML_Util::createTagFromArray($tag));
+ print htmlentities($util->createTagFromArray($tag));
print "\n<br><br>\n";
/**
@@ -243,7 +245,7 @@
);
print 'creating a tag with CData section:<br>';
- print htmlentities(XML_Util::createTagFromArray($tag, XML_UTIL_CDATA_SECTION));
+ print htmlentities($util->createTagFromArray($tag, XML_UTIL_CDATA_SECTION));
print "\n<br><br>\n";
/**
@@ -258,14 +260,14 @@
);
print 'creating a tag with HTML entities:<br>';
- print htmlentities(XML_Util::createTagFromArray($tag, XML_UTIL_ENTITIES_HTML));
+ print htmlentities($util->createTagFromArray($tag, XML_UTIL_ENTITIES_HTML));
print "\n<br><br>\n";
/**
* creating an XML tag with createTag
*/
print 'creating a tag with createTag:<br>';
- print htmlentities(XML_Util::createTag('myNs:myTag',
+ print htmlentities($util->createTag('myNs:myTag',
array('foo' => 'bar'),
'This is inside the tag',
'http://www.w3c.org/myNs#'));
@@ -281,7 +283,7 @@
);
print 'trying to create an XML tag with an array as content:<br>';
print '<pre>';
- print_r(XML_Util::createTagFromArray($tag));
+ print_r($util->createTagFromArray($tag));
print '</pre>';
print "\n<br><br>\n";
@@ -293,7 +295,7 @@
);
print 'trying to create an XML tag without a name:<br>';
print '<pre>';
- print_r(XML_Util::createTagFromArray($tag));
+ print_r($util->createTagFromArray($tag));
print '</pre>';
print "\n<br><br>\n";
?>
36 examples/example2.php
View
@@ -5,9 +5,9 @@
/**
* Examples (file #2)
*
- * several examples for the methods of XML_Util
+ * several examples for the methods of XML_Util2
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
@@ -39,13 +39,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category XML
- * @package XML_Util
+ * @package XML_Util2
* @subpackage Examples
* @author Stephan Schmidt <schst@php.net>
* @copyright 2003-2008 Stephan Schmidt <schst@php.net>
* @license http://opensource.org/licenses/bsd-license New BSD License
* @version CVS: $Id$
- * @link http://pear.php.net/package/XML_Util
+ * @link http://pear.php.net/package/XML_Util2
*/
/**
@@ -53,13 +53,15 @@
*/
error_reporting(E_ALL);
- require_once 'XML/Util.php';
+ require_once 'XML/Util2.php';
+
+ $util = new XML_Util2();
/**
* creating a start element
*/
print 'creating a start element:<br>';
- print htmlentities(XML_Util::createStartElement('myNs:myTag',
+ print htmlentities($util->createStartElement('myNs:myTag',
array('foo' => 'bar'), 'http://www.w3c.org/myNs#'));
print "\n<br><br>\n";
@@ -68,7 +70,7 @@
* creating a start element
*/
print 'creating a start element:<br>';
- print htmlentities(XML_Util::createStartElement('myTag',
+ print htmlentities($util->createStartElement('myTag',
array(), 'http://www.w3c.org/myNs#'));
print "\n<br><br>\n";
@@ -77,7 +79,7 @@
*/
print 'creating a start element:<br>';
print '<pre>';
- print htmlentities(XML_Util::createStartElement('myTag',
+ print htmlentities($util->createStartElement('myTag',
array('foo' => 'bar', 'argh' => 'tomato'),
'http://www.w3c.org/myNs#', true));
print '</pre>';
@@ -88,21 +90,21 @@
* creating an end element
*/
print 'creating an end element:<br>';
- print htmlentities(XML_Util::createEndElement('myNs:myTag'));
+ print htmlentities($util->createEndElement('myNs:myTag'));
print "\n<br><br>\n";
/**
* creating a CData section
*/
print 'creating a CData section:<br>';
- print htmlentities(XML_Util::createCDataSection('I am content.'));
+ print htmlentities($util->createCDataSection('I am content.'));
print "\n<br><br>\n";
/**
* creating a comment
*/
print 'creating a comment:<br>';
- print htmlentities(XML_Util::createComment('I am a comment.'));
+ print htmlentities($util->createComment('I am a comment.'));
print "\n<br><br>\n";
/**
@@ -117,8 +119,8 @@
print 'creating a tag with qualified name and namespaceUri:<br>';
print '<pre>';
- print htmlentities(XML_Util::createTagFromArray($tag,
- XML_UTIL_REPLACE_ENTITIES, true));
+ print htmlentities($util->createTagFromArray($tag,
+ XML_UTIL2_REPLACE_ENTITIES, true));
print '</pre>';
print "\n<br><br>\n";
@@ -128,8 +130,8 @@
$atts = array('series' => 'Starsky &amp; Hutch', 'channel' => 'ABC');
print 'creating a attribute string, '
. 'entities in values already had been replaced:<br>';
- print htmlentities(XML_Util::attributesToString($atts,
- true, false, false, false, XML_UTIL_ENTITIES_NONE));
+ print htmlentities($util->attributesToString($atts,
+ true, false, false, false, XML_UTIL2_ENTITIES_NONE));
print "\n<br><br>\n";
/**
@@ -137,8 +139,8 @@
*/
$atts = array('series' => 'Starsky &amp; Hutch', 'channel' => 'ABC');
print 'using the array-syntax for attributesToString()<br>';
- print htmlentities(XML_Util::attributesToString($atts,
- array('entities' => XML_UTIL_ENTITIES_NONE)));
+ print htmlentities($util->attributesToString($atts,
+ array('entities' => XML_UTIL2_ENTITIES_NONE)));
print "\n<br><br>\n";
23 package.php
View
@@ -9,21 +9,24 @@
. "creation of tags, validation of XML names and more."
;
-$version = '1.2.1';
-$apiver = '1.2.0';
-$state = 'stable';
+$version = '2.0.0alpha1';
+$apiver = '2.0.0';
+$state = 'alpha';
$notes = <<<EOT
-Fixed Bug #14760: Bug in getDocTypeDeclaration() [ashnazg|fpospisil]
+Initial release
+Forked from XML_Util
+Fixed dir layout
+PHP5 E_STRICT compatability
EOT;
$package = PEAR_PackageFileManager2::importOptions(
'package.xml',
array(
- 'filelistgenerator' => 'cvs',
+ 'filelistgenerator' => 'svn',
'changelogoldtonew' => false,
'simpleoutput' => true,
- 'baseinstalldir' => 'XML',
+ 'baseinstalldir' => '/',
'packagefile' => 'package.xml',
'packagedirectory' => '.'));
@@ -34,7 +37,7 @@
$package->clearDeps();
-$package->setPackage('XML_Util');
+$package->setPackage('XML_Util2');
$package->setPackageType('php');
$package->setSummary('XML utility class');
$package->setDescription($desc);
@@ -45,11 +48,11 @@
$package->setReleaseVersion($version);
$package->setReleaseStability($state);
$package->setNotes($notes);
-$package->setPhpDep('4.3.0');
-$package->setPearinstallerDep('1.4.3');
+$package->setPhpDep('5.1.0');
+$package->setPearinstallerDep('1.9.3');
$package->addExtensionDep('required', 'pcre');
$package->addIgnore(array('package.php', 'package.xml'));
-$package->addReplacement('Util.php', 'package-info', '@version@', 'version');
+$package->addReplacement('Util2.php', 'package-info', '@version@', 'version');
$package->generateContents();
if ($_SERVER['argv'][1] == 'make') {
18 tests/AllTests.php
View
@@ -11,12 +11,12 @@
* PHP version 5
*
* @category XML
- * @package XML_Util
+ * @package XML_Util2
* @subpackage UnitTesting
* @author Chuck Burgess <ashnazg@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @version CVS: $Id$
- * @link http://pear.php.net/package/XML_Util
+ * @link http://pear.php.net/package/XML_Util2
* @since 1.2.0a1
*/
@@ -39,7 +39,7 @@
* to make this usage meet the PEAR CS... we cannot rename it here.
*/
if (!defined('PHPUnit_MAIN_METHOD')) {
- define('PHPUnit_MAIN_METHOD', 'XML_Util_AllTests::main');
+ define('PHPUnit_MAIN_METHOD', 'XML_Util2_AllTests::main');
}
@@ -58,7 +58,7 @@
/**
* directory where PHPT tests are located
*/
-define('XML_UTIL_DIR_PHPT', dirname(__FILE__));
+define('XML_UTIL2_DIR_PHPT', dirname(__FILE__));
/**
* Master Unit Test Suite class for XML_Util
@@ -69,15 +69,15 @@
* by PhpUnit or via "pear run-tests -up xml_util".
*
* @category XML
- * @package XML_Util
+ * @package XML_Util2
* @subpackage UnitTesting
* @author Chuck Burgess <ashnazg@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @version Release: @package_version@
- * @link http://pear.php.net/package/XML_Util
+ * @link http://pear.php.net/package/XML_Util2
* @since 1.2.0a1
*/
-class XML_Util_AllTests
+class XML_Util2_AllTests
{
/**
@@ -112,7 +112,7 @@ public static function suite()
/*
* add PHPT tests
*/
- $phpt = new PHPUnit_Extensions_PhptTestSuite(XML_UTIL_DIR_PHPT);
+ $phpt = new PHPUnit_Extensions_PhptTestSuite(XML_UTIL2_DIR_PHPT);
$suite->addTestSuite($phpt);
return $suite;
@@ -125,7 +125,7 @@ public static function suite()
* to make this usage meet the PEAR CS... we cannot rename it here.
*/
if (PHPUnit_MAIN_METHOD == 'XML_Util_AllTests::main') {
- XML_Util_AllTests::main();
+ XML_Util2_AllTests::main();
}
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
13 tests/testBasic_apiVersion.phpt
View
@@ -1,18 +1,19 @@
--TEST--
-XML_Util::apiVersion() basic tests
+XML_Util2::apiVersion() basic tests
--CREDITS--
Chuck Burgess <ashnazg@php.net>
# created for v1.2.0a1 2008-05-04
--FILE--
<?php
-require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
-echo '=====XML_Util::apiVersion() basic tests=====' . PHP_EOL . PHP_EOL;
+require_once 'XML' . DIRECTORY_SEPARATOR . 'Util2.php';
+$util = new XML_Util2();
+echo '=====XML_Util2::apiVersion() basic tests=====' . PHP_EOL . PHP_EOL;
echo "TEST: basic apiVersion() call" . PHP_EOL;
-echo XML_Util::apiVersion() . PHP_EOL;
+echo $util->apiVersion() . PHP_EOL;
?>
--EXPECT--
-=====XML_Util::apiVersion() basic tests=====
+=====XML_Util2::apiVersion() basic tests=====
TEST: basic apiVersion() call
-1.1
+2.0
47 tests/testBasic_attributesToString.phpt
View
@@ -1,77 +1,78 @@
--TEST--
-XML_Util::attributesToString() basic tests
+XML_Util2::attributesToString() basic tests
--CREDITS--
Chuck Burgess <ashnazg@php.net>
# created for v1.2.0a1 2008-05-04
--FILE--
<?php
-require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
-echo '=====XML_Util::attributesToString() basic tests=====' . PHP_EOL . PHP_EOL;
+require_once 'XML' . DIRECTORY_SEPARATOR . 'Util2.php';
+$util = new XML_Util2();
+echo '=====XML_Util2::attributesToString() basic tests=====' . PHP_EOL . PHP_EOL;
$att = array("foo" => "bar", "boo" => "baz");
$sort1 = array(
'multiline' => true,
'indent' => '----',
'linebreak' => "^",
- 'entities' => XML_UTIL_ENTITIES_XML,
+ 'entities' => XML_UTIL2_ENTITIES_XML,
'sort' => true
);
$sort2 = array(
'multiline' => true,
'indent' => '----',
'linebreak' => "^",
- 'entities' => XML_UTIL_ENTITIES_XML,
+ 'entities' => XML_UTIL2_ENTITIES_XML,
);
echo "TEST: basic usage" . PHP_EOL;
-echo XML_Util::attributesToString($att) . PHP_EOL . PHP_EOL;
+echo $util->attributesToString($att) . PHP_EOL . PHP_EOL;
echo "TEST: explicit \$sort = true" . PHP_EOL;
-echo XML_Util::attributesToString($att, true) . PHP_EOL . PHP_EOL;
+echo $util->attributesToString($att, true) . PHP_EOL . PHP_EOL;
echo "TEST: explicit \$sort = false" . PHP_EOL;
-echo XML_Util::attributesToString($att, false) . PHP_EOL . PHP_EOL;
+echo $util->attributesToString($att, false) . PHP_EOL . PHP_EOL;
echo "TEST: explicit \$multiline = false" . PHP_EOL;
-echo XML_Util::attributesToString($att, true, false) . PHP_EOL . PHP_EOL;
+echo $util->attributesToString($att, true, false) . PHP_EOL . PHP_EOL;
echo "TEST: explicit \$multiline = true" . PHP_EOL;
-echo XML_Util::attributesToString($att, true, true) . PHP_EOL . PHP_EOL;
+echo $util->attributesToString($att, true, true) . PHP_EOL . PHP_EOL;
echo "TEST: explicit \$indent = ' ' (8 spaces)" . PHP_EOL;
-echo XML_Util::attributesToString($att, true, true, ' ') . PHP_EOL . PHP_EOL;
+echo $util->attributesToString($att, true, true, ' ') . PHP_EOL . PHP_EOL;
echo "TEST: explicit \$linebreak = '^' (some dummy char)" . PHP_EOL;
-echo XML_Util::attributesToString($att, true, true, '^') . PHP_EOL . PHP_EOL;
+echo $util->attributesToString($att, true, true, '^') . PHP_EOL . PHP_EOL;
echo "TEST: passing \$sort array of options that includes 'sort'" . PHP_EOL;
-echo XML_Util::attributesToString($att, $sort1) . PHP_EOL . PHP_EOL;
+echo $util->attributesToString($att, $sort1) . PHP_EOL . PHP_EOL;
echo "TEST: passing \$sort array of options that doesn't include 'sort'" . PHP_EOL;
-echo XML_Util::attributesToString($att, $sort2) . PHP_EOL . PHP_EOL;
+echo $util->attributesToString($att, $sort2) . PHP_EOL . PHP_EOL;
echo "TEST: do not replace entities" . PHP_EOL;
$arr = array("foo" => "b@&r", "boo" => "b><z");
-echo XML_Util::attributesToString($arr, true, false, ' ', PHP_EOL,
- XML_UTIL_ENTITIES_NONE) . PHP_EOL . PHP_EOL;
+echo $util->attributesToString($arr, true, false, ' ', PHP_EOL,
+ XML_UTIL2_ENTITIES_NONE) . PHP_EOL . PHP_EOL;
echo "TEST: replace all XML entities" . PHP_EOL;
$arr = array("foo" => "b@&r", "boo" => "b><z");
-echo XML_Util::attributesToString($arr, true, false, ' ', PHP_EOL,
- XML_UTIL_ENTITIES_XML) . PHP_EOL . PHP_EOL;
+echo $util->attributesToString($arr, true, false, ' ', PHP_EOL,
+ XML_UTIL2_ENTITIES_XML) . PHP_EOL . PHP_EOL;
echo "TEST: replace only required XML entities" . PHP_EOL;
$arr = array("foo" => "b@&r", "boo" => "b><z");
-echo XML_Util::attributesToString($arr, true, false, ' ', PHP_EOL,
- XML_UTIL_ENTITIES_XML_REQUIRED) . PHP_EOL . PHP_EOL;
+echo $util->attributesToString($arr, true, false, ' ', PHP_EOL,
+ XML_UTIL2_ENTITIES_XML_REQUIRED) . PHP_EOL . PHP_EOL;
echo "TEST: replace HTML entities" . PHP_EOL;
$arr = array("foo" => "b@&r", "boo" => "b><z");
-echo XML_Util::attributesToString($arr, true, false, ' ', PHP_EOL,
- XML_UTIL_ENTITIES_HTML) . PHP_EOL . PHP_EOL;
+echo $util->attributesToString($arr, true, false, ' ', PHP_EOL,
+ XML_UTIL2_ENTITIES_HTML) . PHP_EOL . PHP_EOL;
?>
--EXPECT--
-=====XML_Util::attributesToString() basic tests=====
+=====XML_Util2::attributesToString() basic tests=====
TEST: basic usage
boo="baz" foo="bar"
21 tests/testBasic_collapseEmptyTags.phpt
View
@@ -1,37 +1,38 @@
--TEST--
-XML_Util::collapseEmptyTags() basic tests
+XML_Util2::collapseEmptyTags() basic tests
--CREDITS--
Chuck Burgess <ashnazg@php.net>
# created for v1.2.0a1 2008-05-04
--FILE--
<?php
-require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
-echo '=====XML_Util::collapseEmptyTags() basic tests=====' . PHP_EOL . PHP_EOL;
+require_once 'XML' . DIRECTORY_SEPARATOR . 'Util2.php';
+$util = new XML_Util2();
+echo '=====XML_Util2::collapseEmptyTags() basic tests=====' . PHP_EOL . PHP_EOL;
$emptyTag = "<foo></foo>";
$otherTag = "<bar>baz</bar>";
$xhtmlTag = "<b></b>";
echo "TEST: basic usage" . PHP_EOL;
-echo XML_Util::collapseEmptyTags($emptyTag) . PHP_EOL . PHP_EOL;
+echo $util->collapseEmptyTags($emptyTag) . PHP_EOL . PHP_EOL;
echo "TEST: basic usage alongside non-empty tag" . PHP_EOL;
-echo XML_Util::collapseEmptyTags($emptyTag . $otherTag) . PHP_EOL . PHP_EOL;
+echo $util->collapseEmptyTags($emptyTag . $otherTag) . PHP_EOL . PHP_EOL;
echo "TEST: one empty tag, with COLLAPSE_ALL set" . PHP_EOL;
-echo XML_Util::collapseEmptyTags($emptyTag, XML_UTIL_COLLAPSE_ALL) . PHP_EOL . PHP_EOL;
+echo $util->collapseEmptyTags($emptyTag, XML_UTIL2_COLLAPSE_ALL) . PHP_EOL . PHP_EOL;
echo "TEST: one empty tag alongside non-empty tag, with COLLAPSE_ALL set" . PHP_EOL;
-echo XML_Util::collapseEmptyTags($emptyTag . $otherTag, XML_UTIL_COLLAPSE_ALL) . PHP_EOL . PHP_EOL;
+echo $util->collapseEmptyTags($emptyTag . $otherTag, XML_UTIL2_COLLAPSE_ALL) . PHP_EOL . PHP_EOL;
echo "TEST: one empty tag, with COLLAPSE_XHTML_ONLY set" . PHP_EOL;
-echo XML_Util::collapseEmptyTags($emptyTag, XML_UTIL_COLLAPSE_XHTML_ONLY) . PHP_EOL . PHP_EOL;
+echo $util->collapseEmptyTags($emptyTag, XML_UTIL2_COLLAPSE_XHTML_ONLY) . PHP_EOL . PHP_EOL;
echo "TEST: one empty tag alongside non-empty tag, with COLLAPSE_XHTML_ONLY set" . PHP_EOL;
-echo XML_Util::collapseEmptyTags($emptyTag . $xhtmlTag . $otherTag, XML_UTIL_COLLAPSE_XHTML_ONLY) . PHP_EOL . PHP_EOL;
+echo $util->collapseEmptyTags($emptyTag . $xhtmlTag . $otherTag, XML_UTIL2_COLLAPSE_XHTML_ONLY) . PHP_EOL . PHP_EOL;
?>
--EXPECT--
-=====XML_Util::collapseEmptyTags() basic tests=====
+=====XML_Util2::collapseEmptyTags() basic tests=====
TEST: basic usage
<foo />
11 tests/testBasic_createCDataSection.phpt
View
@@ -1,18 +1,19 @@
--TEST--
-XML_Util::createCDataSection() basic tests
+XML_Util2::createCDataSection() basic tests
--CREDITS--
Chuck Burgess <ashnazg@php.net>
# created for v1.2.0a1 2008-05-04
--FILE--
<?php
-require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
-echo '=====XML_Util::createCDataSection() basic tests=====' . PHP_EOL . PHP_EOL;
+require_once 'XML' . DIRECTORY_SEPARATOR . 'Util2.php';
+$util = new XML_Util2();
+echo '=====XML_Util2::createCDataSection() basic tests=====' . PHP_EOL . PHP_EOL;
echo "TEST: basic usage" . PHP_EOL;
-echo XML_Util::createCDataSection("I am content.") . PHP_EOL;
+echo $util->createCDataSection("I am content.") . PHP_EOL;
?>
--EXPECT--
-=====XML_Util::createCDataSection() basic tests=====
+=====XML_Util2::createCDataSection() basic tests=====
TEST: basic usage
<![CDATA[I am content.]]>
11 tests/testBasic_createComment.phpt
View
@@ -1,18 +1,19 @@
--TEST--
-XML_Util::createComment() basic tests
+XML_Util2::createComment() basic tests
--CREDITS--
Chuck Burgess <ashnazg@php.net>
# created for v1.2.0a1 2008-05-04
--FILE--
<?php
-require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
-echo '=====XML_Util::createComment() basic tests=====' . PHP_EOL . PHP_EOL;
+require_once 'XML' . DIRECTORY_SEPARATOR . 'Util2.php';
+$util = new XML_Util2();
+echo '=====XML_Util2::createComment() basic tests=====' . PHP_EOL . PHP_EOL;
echo "TEST: basic usage" . PHP_EOL;
-echo XML_Util::createComment("I am comment.") . PHP_EOL;
+echo $util->createComment("I am comment.") . PHP_EOL;
?>
--EXPECT--
-=====XML_Util::createComment() basic tests=====
+=====XML_Util2::createComment() basic tests=====
TEST: basic usage
<!-- I am comment. -->
13 tests/testBasic_createEndElement.phpt
View
@@ -1,21 +1,22 @@
--TEST--
-XML_Util::createEndElement() basic tests
+XML_Util2::createEndElement() basic tests
--CREDITS--
Chuck Burgess <ashnazg@php.net>
# created for v1.2.0a1 2008-05-04
--FILE--
<?php
-require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
-echo '=====XML_Util::createEndElement() basic tests=====' . PHP_EOL . PHP_EOL;
+require_once 'XML' . DIRECTORY_SEPARATOR . 'Util2.php';
+$util = new XML_Util2();
+echo '=====XML_Util2::createEndElement() basic tests=====' . PHP_EOL . PHP_EOL;
echo "TEST: basic usage (myTag)" . PHP_EOL;
-echo XML_Util::createEndElement("myTag") . PHP_EOL . PHP_EOL;
+echo $util->createEndElement("myTag") . PHP_EOL . PHP_EOL;
echo "TEST: basic usage with a namespaced tag (myNs:myTag)" . PHP_EOL;
-echo XML_Util::createEndElement("myNs:myTag") . PHP_EOL . PHP_EOL;
+echo $util->createEndElement("myNs:myTag") . PHP_EOL . PHP_EOL;
?>
--EXPECT--
-=====XML_Util::createEndElement() basic tests=====
+=====XML_Util2::createEndElement() basic tests=====
TEST: basic usage (myTag)
</myTag>
29 tests/testBasic_createStartElement.phpt
View
@@ -1,46 +1,47 @@
--TEST--
-XML_Util::createStartElement() basic tests
+XML_Util2::createStartElement() basic tests
--CREDITS--
Chuck Burgess <ashnazg@php.net>
# created for v1.2.0a1 2008-05-04
--FILE--
<?php
-require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
-echo '=====XML_Util::createStartElement() basic tests=====' . PHP_EOL . PHP_EOL;
+require_once 'XML' . DIRECTORY_SEPARATOR . 'Util2.php';
+$util = new XML_Util2();
+echo '=====XML_Util2::createStartElement() basic tests=====' . PHP_EOL . PHP_EOL;
echo "TEST: tag only" . PHP_EOL;
-echo XML_Util::createStartElement(
+echo $util->createStartElement(
"myNs:myTag"
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attributes" . PHP_EOL;
-echo XML_Util::createStartElement(
+echo $util->createStartElement(
"myNs:myTag",
array("foo" => "bar")
) . PHP_EOL . PHP_EOL;
echo "TEST: tag only, passing '' as attribute arg" . PHP_EOL;
-echo XML_Util::createStartElement(
+echo $util->createStartElement(
'myNs:myTag',
''
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attributes and namespace" . PHP_EOL;
-echo XML_Util::createStartElement(
+echo $util->createStartElement(
"myNs:myTag",
array("foo" => "bar"),
"http://www.w3c.org/myNs#"
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with empty attributes, whose namespaceUri is not a full namespace" . PHP_EOL;
-echo XML_Util::createStartElement(
+echo $util->createStartElement(
'myTag',
'',
'foo'
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attributes, namespace, and multiline = true" . PHP_EOL;
-echo XML_Util::createStartElement(
+echo $util->createStartElement(
"myNs:myTag",
array("foo" => "bar"),
"http://www.w3c.org/myNs#",
@@ -48,7 +49,7 @@ echo XML_Util::createStartElement(
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attributes, namespace, multiline = true, and indent = (2 spaces only)" . PHP_EOL;
-echo XML_Util::createStartElement(
+echo $util->createStartElement(
"myNs:myTag",
array("foo" => "bar"),
"http://www.w3c.org/myNs#",
@@ -57,7 +58,7 @@ echo XML_Util::createStartElement(
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), and linebreak = '^'" . PHP_EOL;
-echo XML_Util::createStartElement(
+echo $util->createStartElement(
"myNs:myTag",
array("foo" => "bar"),
"http://www.w3c.org/myNs#",
@@ -67,7 +68,7 @@ echo XML_Util::createStartElement(
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = true" . PHP_EOL;
-echo XML_Util::createStartElement(
+echo $util->createStartElement(
"myNs:myTag",
array("foo" => "bar", "boo" => "baz"),
"http://www.w3c.org/myNs#",
@@ -78,7 +79,7 @@ echo XML_Util::createStartElement(
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = false" . PHP_EOL;
-echo XML_Util::createStartElement(
+echo $util->createStartElement(
"myNs:myTag",
array("foo" => "bar", "boo" => "baz"),
"http://www.w3c.org/myNs#",
@@ -89,7 +90,7 @@ echo XML_Util::createStartElement(
) . PHP_EOL . PHP_EOL;
?>
--EXPECT--
-=====XML_Util::createStartElement() basic tests=====
+=====XML_Util2::createStartElement() basic tests=====
TEST: tag only
<myNs:myTag>
47 tests/testBasic_createTag.phpt
View
@@ -1,28 +1,29 @@
--TEST--
-XML_Util::createTag() basic tests
+XML_Util2::createTag() basic tests
--CREDITS--
Chuck Burgess <ashnazg@php.net>
# created for v1.2.0a1 2008-05-04
--FILE--
<?php
-require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
-echo '=====XML_Util::createTag() basic tests=====' . PHP_EOL . PHP_EOL;
+require_once 'XML' . DIRECTORY_SEPARATOR . 'Util2.php';
+$util = new XML_Util2();
+echo '=====XML_Util2::createTag() basic tests=====' . PHP_EOL . PHP_EOL;
echo "TEST: tag with attribute" . PHP_EOL;
-echo XML_Util::createTag(
+echo $util->createTag(
"myNs:myTag",
array("foo" => "bar")
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attribute and content" . PHP_EOL;
-echo XML_Util::createTag(
+echo $util->createTag(
"myNs:myTag",
array("foo" => "bar"),
"This is inside the tag"
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attribute, content, and namespace" . PHP_EOL;
-echo XML_Util::createTag(
+echo $util->createTag(
"myNs:myTag",
array("foo" => "bar"),
"This is inside the tag",
@@ -30,73 +31,73 @@ echo XML_Util::createTag(
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attribute, content, namespace, and REPLACE_ENTITIES" . PHP_EOL;
-echo XML_Util::createTag(
+echo $util->createTag(
"myNs:myTag",
array("foo" => "bar"),
"This is inside the tag and has < & @ > in it",
"http://www.w3c.org/myNs#",
- XML_UTIL_REPLACE_ENTITIES
+ XML_UTIL2_REPLACE_ENTITIES
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attribute, content, namespace, and CDATA_SECTION" . PHP_EOL;
-echo XML_Util::createTag(
+echo $util->createTag(
"myNs:myTag",
array("foo" => "bar"),
"This is inside the tag and has < & @ > in it",
"http://www.w3c.org/myNs#",
- XML_UTIL_CDATA_SECTION
+ XML_UTIL2_CDATA_SECTION
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, and multiline = false" . PHP_EOL;
-echo XML_Util::createTag(
+echo $util->createTag(
"myNs:myTag",
array("foo" => "bar"),
"This is inside the tag and has < & @ > in it",
"http://www.w3c.org/myNs#",
- XML_UTIL_REPLACE_ENTITIES,
+ XML_UTIL2_REPLACE_ENTITIES,
false
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, and multiline = true" . PHP_EOL;
-echo XML_Util::createTag(
+echo $util->createTag(
"myNs:myTag",
array("foo" => "bar"),
"This is inside the tag and has < & @ > in it",
"http://www.w3c.org/myNs#",
- XML_UTIL_REPLACE_ENTITIES,
+ XML_UTIL2_REPLACE_ENTITIES,
true
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, and indent = (2 spaces)" . PHP_EOL;
-echo XML_Util::createTag(
+echo $util->createTag(
"myNs:myTag",
array("foo" => "bar"),
"This is inside the tag and has < & @ > in it",
"http://www.w3c.org/myNs#",
- XML_UTIL_REPLACE_ENTITIES,
+ XML_UTIL2_REPLACE_ENTITIES,
true,
' '
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, indent = (2 spaces), and linebreak = '^'" . PHP_EOL;
-echo XML_Util::createTag(
+echo $util->createTag(
"myNs:myTag",
array("foo" => "bar"),
"This is inside the tag and has < & @ > in it",
"http://www.w3c.org/myNs#",
- XML_UTIL_REPLACE_ENTITIES,
+ XML_UTIL2_REPLACE_ENTITIES,
true,
' ',
'^'
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = true" . PHP_EOL;
-echo XML_Util::createTag(
+echo $util->createTag(
"myNs:myTag",
array("foo" => "bar", "boo" => "baz"),
"This is inside the tag and has < & @ > in it",
"http://www.w3c.org/myNs#",
- XML_UTIL_REPLACE_ENTITIES,
+ XML_UTIL2_REPLACE_ENTITIES,
true,
' ',
'^',
@@ -104,12 +105,12 @@ echo XML_Util::createTag(
) . PHP_EOL . PHP_EOL;
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = false" . PHP_EOL;
-echo XML_Util::createTag(
+echo $util->createTag(
"myNs:myTag",
array("foo" => "bar", "boo" => "baz"),
"This is inside the tag and has < & @ > in it",
"http://www.w3c.org/myNs#",
- XML_UTIL_REPLACE_ENTITIES,
+ XML_UTIL2_REPLACE_ENTITIES,
true,
' ',
'^',
@@ -117,7 +118,7 @@ echo XML_Util::createTag(
) . PHP_EOL . PHP_EOL;
?>
--EXPECT--
-=====XML_Util::createTag() basic tests=====
+=====XML_Util2::createTag() basic tests=====
TEST: tag with attribute
<myNs:myTag foo="bar" />
51 tests/testBasic_createTagFromArray.phpt
View
@@ -1,12 +1,13 @@
--TEST--
-XML_Util::createTagFromArray() basic tests
+XML_Util2::createTagFromArray() basic tests
--CREDITS--
Chuck Burgess <ashnazg@php.net>
# created for v1.2.0a1 2008-05-04
--FILE--
<?php
-require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
-echo '=====XML_Util::createTagFromArray() basic tests=====' . PHP_EOL . PHP_EOL;
+require_once 'XML' . DIRECTORY_SEPARATOR . 'Util2.php';
+$util = new XML_Util2();
+echo '=====XML_Util2::createTagFromArray() basic tests=====' . PHP_EOL . PHP_EOL;
$bad = array(
"foo" => "bar",
@@ -70,70 +71,70 @@ $tag12 = array(
);
echo "TEST: basic usage with an invalid array" . PHP_EOL;
-echo XML_Util::createTagFromArray($bad) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($bad) . PHP_EOL . PHP_EOL;
echo "TEST: basic usage with a valid array (qname only)" . PHP_EOL;
-echo XML_Util::createTagFromArray($tag1) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag1) . PHP_EOL . PHP_EOL;
echo "TEST: basic usage with a valid array (qname and namespaceUri)" . PHP_EOL;
-echo XML_Util::createTagFromArray($tag2) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag2) . PHP_EOL . PHP_EOL;
echo "TEST: basic usage with a valid array (qname, namespaceUri, and attributes)" . PHP_EOL;
-echo XML_Util::createTagFromArray($tag3) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag3) . PHP_EOL . PHP_EOL;
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content)" . PHP_EOL;
-echo XML_Util::createTagFromArray($tag4) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag4) . PHP_EOL . PHP_EOL;
echo "TEST: basic usage with a valid array (qname, attributes, and content)" . PHP_EOL;
-echo XML_Util::createTagFromArray($tag5) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag5) . PHP_EOL . PHP_EOL;
echo "TEST: basic usage with a valid array (qname, namespaceUri, and content)" . PHP_EOL;
-echo XML_Util::createTagFromArray($tag6) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag6) . PHP_EOL . PHP_EOL;
echo "TEST: basic usage with a valid array (namespaceUri, attributes, and content)" . PHP_EOL;
-echo XML_Util::createTagFromArray($tag7) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag7) . PHP_EOL . PHP_EOL;
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), plus REPLACE_ENTITIES" . PHP_EOL;
-echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag4, XML_UTIL2_REPLACE_ENTITIES) . PHP_EOL . PHP_EOL;
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), plus ENTITIES_NONE" . PHP_EOL;
-echo XML_Util::createTagFromArray($tag4, XML_UTIL_ENTITIES_NONE) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag4, XML_UTIL2_ENTITIES_NONE) . PHP_EOL . PHP_EOL;
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, and multiline = false" . PHP_EOL;
-echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, false) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag4, XML_UTIL2_REPLACE_ENTITIES, false) . PHP_EOL . PHP_EOL;
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, and multiline = true" . PHP_EOL;
-echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, true) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag4, XML_UTIL2_REPLACE_ENTITIES, true) . PHP_EOL . PHP_EOL;
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, and indent = (2 spaces)" . PHP_EOL;
-echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, true, ' ') . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag4, XML_UTIL2_REPLACE_ENTITIES, true, ' ') . PHP_EOL . PHP_EOL;
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, indent = (2 spaces), and linebreak = '^'" . PHP_EOL;
-echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, true, ' ', '^') . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag4, XML_UTIL2_REPLACE_ENTITIES, true, ' ', '^') . PHP_EOL . PHP_EOL;
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = true" . PHP_EOL;
-echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, true, ' ', '^', true) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag4, XML_UTIL2_REPLACE_ENTITIES, true, ' ', '^', true) . PHP_EOL . PHP_EOL;
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = false" . PHP_EOL;
-echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, true, ' ', '^', false) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag4, XML_UTIL2_REPLACE_ENTITIES, true, ' ', '^', false) . PHP_EOL . PHP_EOL;
echo 'TEST: cause a non-scalar error on the content tag' . PHP_EOL;
-echo XML_Util::createTagFromArray($tag8) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag8) . PHP_EOL . PHP_EOL;
echo 'TEST: handle an array of namespaces being passed' . PHP_EOL;
-echo XML_Util::createTagFromArray($tag9) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag9) . PHP_EOL . PHP_EOL;
echo 'TEST: qname is derived from namespace + localPart' . PHP_EOL;
-echo XML_Util::createTagFromArray($tag10) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag10) . PHP_EOL . PHP_EOL;
echo 'TEST: qname is derived from localPart only' . PHP_EOL;
-echo XML_Util::createTagFromArray($tag11) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag11) . PHP_EOL . PHP_EOL;
echo 'TEST: namespaceUri is given, but namespace is not' . PHP_EOL;
-echo XML_Util::createTagFromArray($tag12) . PHP_EOL . PHP_EOL;
+echo $util->createTagFromArray($tag12) . PHP_EOL . PHP_EOL;
?>
--EXPECT--
-=====XML_Util::createTagFromArray() basic tests=====
+=====XML_Util2::createTagFromArray() basic tests=====
TEST: basic usage with an invalid array
You must either supply a qualified name (qname) or local tag name (localPart).
17 tests/testBasic_getDocTypeDeclaration.phpt
View
@@ -1,18 +1,19 @@