Permalink
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...
1 parent 6fa1369 commit a7b25923b835927ca359fcebd07eb402e3233603 @CloCkWeRX CloCkWeRX committed Jul 30, 2011
Oops, something went wrong.
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,64 +39,66 @@
* 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
*/
/**
* set error level
*/
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";
?>
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,27 +39,29 @@
* 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
*/
/**
* set error level
*/
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,17 +130,17 @@
$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";
/**
* using the array-syntax for attributesToString()
*/
$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";
Oops, something went wrong.

0 comments on commit a7b2592

Please sign in to comment.