cvs: pear /XML_Statistics Statistics.php package.xml /XML_Statistics/examples example.xml example1.php example2.php example3.php

From: Date: Wed, 17 Sep 2003 11:59:19 +0000
Subject: cvs: pear /XML_Statistics Statistics.php package.xml /XML_Statistics/examples example.xml example1.php example2.php example3.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-12799@lists.php.net to get a copy of this message
schst Wed Sep 17 07:59:19 2003 EDT Added files: /pear/XML_Statistics Statistics.php package.xml /pear/XML_Statistics/examples example.xml example1.php example2.php example3.php Log: initial commit

Index: pear/XML_Statistics/Statistics.php +++ pear/XML_Statistics/Statistics.php <?PHP /* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2002 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.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. | // +----------------------------------------------------------------------+ // | Authors: Stephan Schmidt <schst@php.net> | // | Basic idea adapted from Luis Argerich <lrargerich@yahoo.com>| // | and his class xml_check | // | (http://phpxmlclasses.sourceforge.net/) | // +----------------------------------------------------------------------+ /** * XML/Statistics.php * * Package to statistically analy XML documents, i.e. * counting tags, CData sections, Processing instructions and more. * * @category XML * @package XML_Statistics * @author Stephan Schmidt <schst@php.net> */ /** * XML_Parser is needed to parse the docuemnt */ require_once 'XML/Parser.php'; /** * Tagname was not found */ define( "XML_STATISTICS_ERROR_TAG_NOT_FOUND", 51 ); /** * Attribute was not found */ define( "XML_STATISTICS_ERROR_ATTRIBUTE_NOT_FOUND", 52 ); /** * Invalid depth */ define( "XML_STATISTICS_ERROR_INVALID_DEPTH", 53 ); /** * Unknown processing instruction */ define( "XML_STATISTICS_ERROR_PI_NOT_FOUND", 54 ); /** * Unknown external entity */ define( "XML_STATISTICS_ERROR_EXTERNAL_ENTITY_NOT_FOUND", 55 ); /** * XML statistics class * * This class can be used to get statistic information about an XML document. * It is able to extract to total number of tags, occurences of a specific tag, * number of attributes, attributes in a specific tag, processing instruction, * maximum nesting level and many more. * * The class is able to analyze a file, URL or string. * * <code> * require_once 'XML/Statistics.php'; * $stat = new XML_Statistics(); * $result = $stat->analyzeFile('http://pear.php.net/rss.php'); * if ($stat->isError($result)) { * die("Error: " . $result->getMessage()); * } * * echo "maximum nesting level: " . $stat->getMaxDepth() . "<br />"; * echo "occurences of item : " . $stat->countTag('item') . "<br />"; * echo "total tags : " . $stat->countTag() . "<br />"; * </code> * * @category XML * @package XML_Statistics * @version 0.1 * @author Stephan Schmidt <schst@php.net> */ class XML_Statistics extends XML_Parser { /** * options for the analyses * @var array * @access private */ var $_options = array( "ignoreWhitespace" => true ); /** * current depth * @var integer * @access private */ var $_depth = 0; /** * count the tags * @var array * @access private */ var $_tags = array(); /** * count the tags in each depth * @var array * @access private */ var $_tagsInDepth = array(); /** * count attributes * @var array * @access private */ var $_attribs = array(); /** * count attributes per tag * @var array * @access private */ var $_attribsPerTag = array(); /** * count processing instructions * @var array * @access private */ var $_pis = array(); /** * count external entities * @var array * @access private */ var $_extEntities = array(); /** * all data blocks * @var array * @access private */ var $_dataChunks = array(); /** * length of the data * @var integer * @access private */ var $_dataLength = 0; /** * constructor * * When instantiating a new object, you may specify an array * containing options for the analysis. Currently only one * option is possible: * * - ignoreWhitespace => true|false * * @access public */ function XML_Statistics($options = array()) { $this->_options = array_merge($this->_options, $options); $this->folding = false; } /** * analyze a file or URL * * After analyzing a file, use the count*() and get*() * methods to retrieve the result of the analysis. * * @access public * @param string $filename * @return boolean true on success * @throws PEAR_Error * @see analyzeString() */ function analyzeFile($file) { $this->XML_Parser(); $this->_resetVars(); $this->setInputFile($file); $result = $this->parse(); if ($this->isError($result)) { return $result; } return true; } /** * analyze an XML string * * After analyzing a file, use the count*() and get*() * methods to retrieve the result of the analysis. * * @access public * @param string $xml the XML string to analyze * @return boolean true on success * @throws PEAR_Error * @see analyzeFile() */ function analyzeString( $xml ) { $this->XML_Parser(); $this->_resetVars(); $result = $this->parseString($xml); if ($this->isError($result)) { return $result; } return true; } /** * return API version * * @access public * @static * @return string $version API version */ function apiVersion() { return "0.1"; } /** * get a list of tag occurences * * This will count the occurences of each tag in the document. * It returns an associative array with the tag names in the keys * and the number of occurences in the corresponding values. * * @access public * @return array array with tag names in the index and occurences as the value * @see getAttributeOccurences() */ function getTagOccurences() { $list = $this->_tags; unset($list["__total"]); return $list; } /** * get a list of attribute occurences * * This will count the occurences of each attribute (by its unique name) in the document. * It returns an associative array with the tag names in the keys * and the number of occurences in the corresponding values. * * If you specify a tagname this method will only count the occurences * of attributes in this tag. * * @access public * @param string $tag restrict to a tag * @return array array with attribute names in the index and occurences as the value * @see getTagOccurences() */ function getAttributeOccurences($tagname = null) { if ($tagname != null) { if (!isset($this->_attribsPerTag[$tagname])) { return $this->raiseError('Tag not found.', XML_STATISTICS_ERROR_TAG_NOT_FOUND); } $list = $this->_attribsPerTag[$tagname]; } else { $list = $this->_attribs; } unset($list["__total"]); return $list; } /** * count the occurences of a tag * * Counts how often a certain tag is used in the document. * If no tagname is specified ot will count the total * number of tags. * * @access public * @param string $tagname if no tag name is supplied, all tags are counted * @return integer occurences of the tag * @see countTagsInDepth() */ function countTag($tagname = null) { if ($tagname == null) { $tagname = "__total"; } if (isset($this->_tags[$tagname])) { return $this->_tags[$tagname]; } return $this->raiseError('Tag not found.', XML_STATISTICS_ERROR_TAG_NOT_FOUND); } /** * count the tags in a certain depth * * Thru nesting a tag can be at a certain depth. The root * tag is at depth zero. By counting the amount of tags in a * depth you can count the number of recordsets in an XML * document. * * @access public * @param integer $depth tag depth (0 is root) * @return integer number of tags in this depth * @see countTag() */ function countTagsInDepth($depth) { if (isset($this->_tagsInDepth[$depth])) { return $this->_tagsInDepth[$depth]; } return $this->raiseError('Inavid depth.', XML_STATISTICS_ERROR_INVALID_DEPTH); } /** * count the occurences of an attribute * * Counts how often a certain attribute is used in the document. * If no attribute is specified ot will count the total * number of tags. * * With the second parameter you may limit the search to * a special tag. * * @access public * @param string $attribute if no attribute name is supplied, all attributes are counted * @param string $tagname this allows you to limit your search to a tag * @return integer occurences of the attribute */ function countAttribute($attribute = null, $tagname = null) { if ($attribute == null) { $attribute = "__total"; } if ($tagname == null) { if (isset($this->_attribs[$attribute])) { return $this->_attribs[$attribute]; } return $this->raiseError('Attribute not found.', XML_STATISTICS_ERROR_TAG_NOT_FOUND); } if (!isset($this->_attribsPerTag[$tagname])) { return $this->raiseError('Tag not found.', XML_STATISTICS_ERROR_TAG_NOT_FOUND); } if (isset($this->_attribsPerTag[$tagname][$attribute])) { return $this->_attribsPerTag[$tagname][$attribute]; } return $this->raiseError('Attribute not found.', XML_STATISTICS_ERROR_TAG_NOT_FOUND); } /** * count the occurences of a processing instruction * * Counts how often a certain processing instruction (e.g. <?PHP) is used in the document. * The target is the 'language' of the processing instruction. You only * need to specify the name, without the leading question mark. * If no target is specified ot will count the total * number of processing instructions. * * @access public * @param string $target if no tag name is supplied, all PIs are counted * @return integer occurences of the processing instruction */ function countPI($target = null) { if ($target == null) { $target = "__total"; } if (isset($this->_pis[$target])) { return $this->_pis[$target]; } return $this->raiseError('Processing Instruction with specified target not found.', XML_STATISTICS_ERROR_PI_NOT_FOUND); } /** * count the occurences of a external entitity * * Counts how often a certain external is used in the document. * If no name is specified ot will count the total * number of external entities. * * External entities have to be declared in your DTD: * <pre> * &lt;!DOCTYPE page [ * &lt;!ENTITY foo SYSTEM "foo.xml"&gt; * &lt;!ENTITY bar SYSTEM "bar.xml"&gt; * ]&gt; * </pre> * * @access public * @param string $name the name of the entity * @return integer occurences of the entity */ function countExternalEntity($name = null) { if ($name == null) { $name = "__total"; } if (isset($this->_extEntities[$name])) { return $this->_extEntities[$name]; } return $this->raiseError('External entity target not found.', XML_STATISTICS_ERROR_EXTERNAL_ENTITY_NOT_FOUND); } /** * count the occurences of a data blocks * * This is influenced by the 'ignoreWhitespace' option. * Furthermore a new chunk is counted when the parser find a linebreak or * internal entity. * * @access public * @return integer number of data chunks * @see getCDataLength() */ function countDataChunks() { return count($this->_dataChunks); } /** * get the combined length of all CData sections * * If you need to know how many chars you have between * your tags, this is the method that gets it. * * @access public * @return integer number of data chunks * @see countDataChunks() */ function getCDataLength() { return $this->_dataLength; } /** * get the maximum nesting level * * This method will count how deep your document * is nested. * * <pre> * &lt;root&gt; * &lt;foo&gt; * &lt;bar/&gt; * &lt;/foo&gt; * &lt;root&gt; * </pre> * * The nesting level of this document is 3. * * @access public * @return integer maximum nesting level */ function getMaxDepth() { return max(array_keys($this->_tagsInDepth)); } /** * Start element handler for XML parser * * @access protected * @param object $parser XML parser object * @param string $element XML element * @param array $attribs attributes of XML tag * @return void */ function startHandler($parser, $element, $attribs) { // count the total number of tags $this->_tags["__total"]++; // count occurences of this tag if (!isset($this->_tags[$element])) { $this->_tags[$element] = 0; } $this->_tags[$element]++; // count tags in the current depth if (!isset($this->_tagsInDepth[$this->depth])) { $this->_tagsInDepth[$this->depth] = 0; } $this->_tagsInDepth[$this->depth]++; // count the number of attributes $attribCount = count($attribs); $this->_attribs["__total"] = $this->_attribs["__total"] + $attribCount; // count the number of attributes for this tag if (!isset($this->_attribsPerTag[$element])) { $this->_attribsPerTag[$element] = array( "__total" => 0 ); } $this->_attribsPerTag[$element]["__total"] = $this->_attribsPerTag[$element]["__total"] + $attribCount; // count occurences of each attribute foreach (array_keys($attribs) as $attribName) { if (!isset($this->_attribs[$attribName])) { $this->_attribs[$attribName] = 0; } $this->_attribs[$attribName]++; // count the occurences of an attribute per tag if (!isset($this->_attribsPerTag[$element][$attribName])) { $this->_attribsPerTag[$element][$attribName] = 0; } $this->_attribsPerTag[$element][$attribName]++; } $this->depth++; } /** * End element handler for XML parser * * @access protected * @param object XML parser object * @param string * @return void */ function endHandler($parser, $element) { $this->depth--; } /** * Handler for character data * * @access protected * @param object XML parser object * @param string CDATA * @return void */ function cdataHandler($parser, $cdata) { if ($this->_options["ignoreWhitespace"]) { $cdata = trim($cdata); if (empty($cdata)) { return true; } } // store the data array_push($this->_dataChunks, $cdata); // update the total length $this->_dataLength = $this->_dataLength + strlen($cdata); } /** * Handler for processing instructions * * @access protected * @param object XML parser object * @param string target * @param string data * @return void */ function piHandler($parser, $target, $data) { // count total amount of processing instructions $this->_pis["__total"]++; // count PIs per target if (!isset($this->_pis[$target])) { $this->_pis[$target] = 0; } $this->_pis[$target]++; } /** * Handler for external entities * * @access protected * @param object XML parser object * @param string target * @param string data * @return void */ function entityrefHandler($parser, $open_entity_names, $base, $system_id, $public_id) { // count total amount of external entities $this->_extEntities["__total"]++; // count external entities per entity name if (!isset($this->_extEntities[$open_entity_names])) { $this->_extEntities[$open_entity_names] = 0; } $this->_extEntities[$open_entity_names]++; return true; } /** * reset all used object properties * * This method is called before parsing a new document * * @access private */ function _resetVars() { $this->depth = 1; $this->_tags = array( "__total" => 0 ); $this->_attribs = array( "__total" => 0 ); $this->_tagsInDepth = array(); $this->_attribsPerTag = array(); $this->_dataChunks = array(); $this->_dataLength = 0; $this->_pis = array( "__total" => 0 ); $this->_extEntities = array( "__total" => 0 ); } } ?> Index: pear/XML_Statistics/package.xml +++ pear/XML_Statistics/package.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0"> <package version="1.0"> <name>XML_Statistics</name> <summary>Class to obtain statistical information from an XML documents.</summary> <description>XML_Statistics is able to retrieve statistics about tags, attributes, entities, processing instructions and CDaata chunks in any XML document.</description> <maintainers> <maintainer> <user>schst</user> <name>Stephan Schmidt</name> <email>schst@php.net</email> <role>lead</role> </maintainer> </maintainers> <release> <version>0.1</version> <date>2003-09-12</date> <license>PHP License</license> <state>beta</state> <notes>package proposal</notes> <deps> <dep type="pkg" rel="has">XML_Parser</dep> </deps> <provides type="class" name="XML_Statistics" extends="XML_Parser" /> <provides type="function" name="XML_Statistics::analyzeFile" /> <provides type="function" name="XML_Statistics::analyzeString" /> <provides type="function" name="XML_Statistics::apiVersion" /> <provides type="function" name="XML_Statistics::getTagOccurences" /> <provides type="function" name="XML_Statistics::getAttributeOccurences" /> <provides type="function" name="XML_Statistics::countTag" /> <provides type="function" name="XML_Statistics::countTagsInDepth" /> <provides type="function" name="XML_Statistics::countAttribute" /> <provides type="function" name="XML_Statistics::countPI" /> <provides type="function" name="XML_Statistics::countExternalEntity" /> <provides type="function" name="XML_Statistics::countDataChunks" /> <provides type="function" name="XML_Statistics::getCDataLength" /> <provides type="function" name="XML_Statistics::getMaxDepth" /> <provides type="function" name="XML_Statistics::startHandler" /> <provides type="function" name="XML_Statistics::endHandler" /> <provides type="function" name="XML_Statistics::cdataHandler" /> <provides type="function" name="XML_Statistics::piHandler" /> <provides type="function" name="XML_Statistics::entityrefHandler" /> <filelist> <file role="doc" baseinstalldir="XML" md5sum="34c745d50f14f3e0a1dec4884b25ed8f" name="examples/example.xml"/> <file role="doc" baseinstalldir="XML" md5sum="adb71f232ac5a3372ebf12f78b73faf7" name="examples/example1.php"/> <file role="doc" baseinstalldir="XML" md5sum="03686ed74f5aca031168f9f0978e3374" name="examples/example2.php"/> <file role="doc" baseinstalldir="XML" md5sum="4aedb26ccfc15b802fe0c8d88d3ad979" name="examples/example3.php"/> <file role="php" baseinstalldir="XML" md5sum="ea1562af5c791b7ba32b8642068055aa" name="Statistics.php"/> </filelist> </release> <changelog> <release> <version>0.1</version> <date>2003-09-12</date> <license>PHP License</license> <state>beta</state> <notes>package proposal </notes> </release> </changelog> </package> Index: pear/XML_Statistics/examples/example.xml +++ pear/XML_Statistics/examples/example.xml <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE page [ <!ENTITY foo SYSTEM "foo.xml"> <!ENTITY bar SYSTEM "bar.xml"> ]> <document title="Current News"> <!-- This is just a dummy XML document, taken from www.php-tools.net. The external entities have been added so the feature can be shown. --> <meta project="none"> <keywords/> <description/> <author>Stephan Schmidt</author> <!-- Meta Navigation --> <getMetaNav/> <!-- Navigation --> <include parse="xml" href="/nav/headernav.xml"/> <include parse="xml" href="/nav/projectnav.xml"/> <addTemplateFile file="news.tmpl"/> <addTemplateFile file="rss_sidebar.tmpl"/> <addTemplateFile file="scroller.tmpl"/> </meta> <?PHP I am a PHP processing instruction. ?> <?ASP I am an ASP processing instruction. ?> &foo; <page label="PHP Application Tools" sublabel="Current News"> <intro> <introtitle>Welcome to PHP Application Tools!</introtitle> <para> If you're new to pat, and would like to know what we do here, take a look at <link url="/about/project.xml">"About Pat"</link> or check out the <link url="/about/projectsOverview.xml">"projects overview"</link>. Otherwise, you probably know your way around the site already <smiley type="smile"/> </para> </intro> &bar; &bar; <body> <main> <section title="Current breaking news"> <news type="newversion" title="patUser v2.2.3" date="19.08.2003" author="By gERD Schaufelberger"> <para> Again, patUser has improved. Download the new package for additional support of authentication handler and some minor fixes. </para> <ref type="internal" url="/patUser/download.xml">patUser v2.2.3 download</ref> <ref type="internal" url="/patUser/changelog.xml">Changelog</ref> </news> <news type="release" title="PEAR::Stream_Var" date="16.08.2003" author="By Stephan Schmidt"> <para> Stream_Var is a wrapper for PHP's filesystem functions that allows access to PHP variables. It allows you to read and write from variables as if the were files. </para> <ref type="external" url="http%3A%2F%2Fpear.php.net%2Fpackage-info.php%3Fpackage%3DStream_Var">Go to PEAR::Stream_Var</ref> </news> <news type="community" title="PHP Architect August issue released" date="10.08.2003" author="By Stephan Schmidt"> <para> Today the new issue of PHP Architect has been released. This issue features an article by Stephan Schmidt (with a little help from gERD) that focusses on the generation of PDF documents with XML as a source. </para> <para> This is the first of our articles that has been published in PHP Architect. The magazine is available in a print edition as well as a digital PDF version. </para> <ref type="internal" url="/about/publications.xml">All our publications</ref> <ref type="external" url="http://www.phparch.com">Visit PHP Architect website</ref> </news> <news type="newversion" title="patUser v2.2.2" date="08.08.2003" author="By gERD Schaufelberger"> <para> Yet another patUser release. Besides some minor bugfixes the class now includes some changes send to us by Paul Baraonowski. </para> <ref type="internal" url="/patUser/download.xml">patUser v2.2.2 download</ref> <ref type="internal" url="/patUser/changelog.xml">Changelog</ref> </news> <news type="release" title="PEAR::XML_Serializer released" date="03.08.2003" author="By Stephan Schmidt"> <para> XML_Serializer serializes complex data structures like arrays or object as XML documents. This class helps you generating any XML document you require without the need for DOM. </para> <para> That means it can be used to create an RDF document from an PHP array and does not require you to know anything about XML or PHP's string functions. </para> <ref type="external" url="http%3A%2F%2Fpear.php.net%2Fpackage-info.php%3Fpackage%3DXML_Serializer">Go to PEAR::XML_Serializer</ref> </news> <news type="release" title="PEAR::XML_Util released" date="01.08.2003" author="By Stephan Schmidt"> <para> Today, we released a new PEAR package, called XML_Util. The class provides several often needed methods for the creation of XML documents. </para> <para> Functionality includes creating of attribute lists from arrays, creation of tags, validation of XML names and more. </para> <ref type="external" url="http%3A%2F%2Fpear.php.net%2Fpackage-info.php%3Fpackage%3DXML_Util">Go to PEAR::XML_Util</ref> </news> <news type="newversion" title="patSpiderizer v2.0.8 released" date="30.07.2003" author="By Sebastian 'The Argh' Mordziol"> <para> This new version fixes all the little bugs that were reported since the release of v2.0.7, as well as the "Altavista" bug in the statistics - if you already use patSpiderizer, I strongly recommend you install the update package. </para> <para> Also in this release, one (small) new feature: add several links or text blocks at once to a spider page in a breeze with the new link/block lists on the spider page overview page in the administration interface. </para> <ref type="internal" url="/patSpiderizer/changelog.xml">What's changed?</ref> <ref type="internal" url="/patSpiderizer/download.xml">Download patSpiderizer v2.0.8</ref> </news> <news type="newversion" title="patUser v2.1.3 and patUser v2.2.1" date="26.07.2003" author="By gERD Schaufelberger"> <para> Once again, there is a new (minor) version of patUser. Even if versions 2.1.2 and 2.2.0 are only four days old, the new versions include some important improves. Some bugs were fixed, the download-package was enhanced and some more notices were removed. Also the new versions passed some more tests <smiley type="smile"/> </para> <para> BTW, thank you for your help testing and improving patUser! </para> <ref type="internal" url="/patUser/download.xml">patUser v2.1.3 / v2.2.1 download</ref> <ref type="internal" url="/patUser/changelog.xml">Changelog</ref> </news> <news type="newversion" title="patUser v2.1.2 and patUser v2.2.0 BETA" date="22.07.2003" author="By Sebastian Mordziol"> <para> New in this version: bugs, notices and warnings removed (see the changelog for full details). Warning: this is the last version of patUser supporting patDbc, as we are switching to PEAR::DB. Version 2.2.0 is the new branch supporting PEAR:DB - but keep in mind that it is still BETA! If you are willing to test it, feel free to send your bug reports to gERD directly. </para> <ref type="internal" url="/patUser/download.xml">patUser v2.1.2 / v2.2.0 BETA download</ref> <ref type="internal" url="/patUser/changelog.xml">Changelog</ref> </news> <news type="release" title="PEAR::HTTP_Server released" date="22.07.2003" author="By Stephan Schmidt"> <para> Today the first beta version of HTTP_Server has been released through PEAR. This class allows you to create your own HTTP servers without worrying about HTTP itself. The class is based on my other PEAR class, Net_Server, but it can be easily ported to patServer if you do not want to use PEAR. </para> <ref type="external" url="http%3A%2F%2Fpear.php.net%2Fpackage-info.php%3Fpackage%3DHTTP_Server">Go to PEAR::HTTP_Server</ref> </news> <news type="community" title="pat meets PEAR" date="21.07.2003" author="By Stephan Schmidt"> <para> One of our projects, patServer, is now also available through PEAR. The pearified version of patServer is called Net_Server and can easily be installed using the PEAR installer. </para> <para> In the future, I'll maintain both versions, so that you may either use the original class or the pearified one. </para> <ref type="external" url="http%3A%2F%2Fpear.php.net%2Fpackage-info.php%3Fpackage%3DNet_Server">Go to PEAR::Net_Server</ref> <ref type="internal" url="/patServer/overview.xml">Learn more about patServer</ref> </news> <news type="internal" title="Two new publications" date="15.07.2003" author="By Stephan Schmidt"> <para> The book "PHP im Einsatz 2.0" has been finally released. It features 25 articles on sessions at the International PHP Conference 2002. We have contributed two articles to the book, one on IPC and one on ext/sockets. </para> <ref type="internal" url="/about/publications.xml">Go to publications (scroll down)</ref> </news> <news type="newversion" title="patTemplate v2.5 beta released" date="13.07.2003" author="By Stephan Schmidt"> <para> Today, we released the beta version of patTemplate 2.5. This marks the last minor version change, before we work on the release process of patTemplate 3. Please help us by testing patTemplate 2.5 beta. </para> <ref type="internal" url="/patTemplate/download.xml">Download new version</ref> <ref type="internal" url="/patTemplate/changelog.xml">Read the changelog</ref> </news> <news type="newversion" title="patConfiguration v1.6 released" date="06.07.2003" author="By Stephan Schmidt"> <para> Today a new version of patConfiguration has been released. Its new features include defining custom tags, xinc, xml:space support and PHP 5 compatibilty as well as extensive documentation and examples. </para> <ref type="internal" url="/patConfiguration/download.xml">Download new version</ref> <ref type="internal" url="/patConfiguration/changelog.xml">Read the changelog</ref> </news> <news type="internal" title="patSite revamped!" date="30.06.2003" author="By the pat Team"> <para> Maybe you are the first to set foot (mouse?) in the new generation PHP Application Tools. And right on time for pat's second birthday <smiley type="smile"/> We have been working on the new, improved version of our site for quite some time now, and we are quite proud to give you the following new features and enhancements: </para> <para> <ul> <uli>Sidebar with site navigation features (for easier documentation navigation, for ex.)</uli> <uli>We have enabled Mozilla Site navigation bar functionality (enable via "View - Show/Hide - Site Navigation Bar")</uli> <uli>Lightweight HTML code and lighter DHTML code (rip, Netscape 4...)</uli> <uli>RSS Newsfeed on the news page</uli> <uli>New, highly improved PHP and XML syntax highlighting with code output, and function insight</uli> <uli>Overall improved page design for easier readability</uli> <uli>Completely overhauled file structure</uli> <uli>New member listed on the authors page</uli> <uli>Yet lighter background for better readability</uli> <uli>New, Beta patXMLRenderer version engine for the site (for testing purposes for the next release)</uli> </ul> </para> <para> And we cannot be stopped - following right in the tracks of perpetual change, we are planning the following new features: </para> <ul> <uli>Generate Microsoft Word from any page of our site</uli> <uli>Generate PDF documentation with complete chapters of our site for easy documentation download</uli> </ul> </news> <news type="internal" title="Submit your patTemplate wishes!" date="25.05.2003" author="By Stephan Schmidt"> <para> We are currently planning the next major version of patTemplate, which will be completely recoded from scratch. So now's the perfect time to send in your wishes for patTemplate 3.0. </para> <ref type="external" url="http://www.php-tools.de/xena/apps/forum/app/index.php?fid=1&amp;xenaaction=displayArticle&amp;xenaboard=1&amp;xenathread=165&amp;xenaarticleid=----">Submit your wishes in the forum</ref> <ref type="internal" url="contact/contact.xml">contact us by mail</ref> </news> <news type="download" title="Slides from International PHP Conference 2003 Spring Edition available" date="11.05.2003" author="By Stephan Schmidt"> <para> The slides from our presentations at the International PHP Conference 2003 - Spring Edition in Amsterdam are now available for download. Gerd Schaufelberger did a presentation about the use of Design Patterns to ease your life as a PHP programmer and Stephan Schmidt introcuced LaTeX as a possibilty to transform XML to PDF Documents. Click on the links below to get to the session material. </para> <ref type="internal" url="/about/presentations.xml#phpconf2003spring_patterns">Design Patterns and the Real World</ref> <ref type="internal" url="/about/presentations.xml#phpconf2003spring_xml2pdf">Dynamic transformations from XML to PDF Documents with the use of LaTeX</ref> </news> <news type="download" title="Slides from PHPCon 2003 East available" date="04.05.2003" author="By Stephan Schmidt"> <para> The slides and handout from my presentation "XML transformations with PHP" are available for download. The session covered XSLT basics as well as an in-depth look at patXMLRenderer and a comparison with PEAR's XML_Transformer. </para> <ref type="internal" url="/about/presentations.xml#phpcon2003east_xml">Go to session material</ref> </news> <news type="internal" title="patSpiderizer call to feature requests" date="29.04.2003" author="By Sebastian Mordziol"> <para> Long awaited, the next patSpiderizer version is in the works, and now is the time to make your wishes be heard! I have started a thread in the patSpiderizer forum where you can contribute all your feature requests: </para> <ref type="external" url="http://www.php-tools.de/forum/index.php?board=patSpiderizer">Make your feature request in the forum</ref> </news> <news type="community" title="PHP Con East" date="18.02.2003" author="By Sebastian Mordziol"> <para> <img src="graphics/phpconeast2003.gif" width="136" height="70" vspace="0" hspace="10" border="0" align="right"/> Stephan Schmidt will hold a session at this spring's PHP Con East, which will take place from april 23rd to 25th in New York. Stephan's talk is about "XML-based web applications" and will present our XML transformer class patXMLRenderer. </para> <ref type="external" url="http://www.php-con.com">PHP Con East</ref> <ref type="internal" url="/patXMLRenderer/overview.xml">More about patXMLRenderer</ref> </news> <news type="community" title="PHP conference spring edition" date="18.02.2003" author="By Sebastian Mordziol"> <para> Stephan Schmidt and gERD Schaufelberger will hold two sessions together at this springs's International PHP conference in Amsterdam which will take place on may 8 and 9. Our two sessions are called "Design patterns and the real world" and "Dynamical transformations from XML to PDF-Documents with use of LaTeX". We will be happy to see you there! </para> <ref type="external" url="http://www.phpconference.com">International PHP Conference website</ref> </news> <news type="misc" title="patConfiguration Tutorial on devshed.com" date="18.02.2003" author="By Sebastian Mordziol"> <para> Vikram Vaswani, author of the book <link type="external" url="http://www.amazon.de/exec/obidos/ASIN/0735712271/qid=1023874729/sr=1-3/phptoolsde-21">"PHP and XML"</link> has published a tutorial on patConfiguration, our XML configuration reader class. The tutorial will give you in-depth knowledge of patConfiguration's features in 11 steps. </para> <ref type="external" url="http://www.devshed.com/Server_Side/PHP/patConfiguration/page1.html">Read the tutorial on devshed</ref> <ref type="internal" url="/patConfiguration/overview.xml">More about patConfiguration</ref> </news> <news type="internal" title="new pat publications" date="29.01.2003" author="By Sebastian Mordziol"> <para> The new issue of the german magazine "PHP Magazin" is now out in stores, with two articles from the pat team. Make sure to grab yours now! Here's a short overview of the articles: </para> <ul> <uli> "Integration": case study of the german portal 1und1.com by Stephan Schmidt and Sebastian Mordziol. </uli> <uli> "Auf Gutenbergs Spuren": generate PDF files from XML with LaTeX and PHP by gERD Schaufelberger. </uli> </ul> <ref type="internal" url="/about/publications.xml">More in our publications page...</ref> </news> </section> <section title="Archived news"> <para> If you are interested in reading the news of times past, you should take a look at our news archive. </para> <ul> <uli><link type="internal" url="news/archive2002.xml">News from 2002</link></uli> <uli><link type="internal" url="news/archive2001.xml">News from 2001</link></uli> </ul> </section> </main> <sidebar> <include href="/misc/inc_partnersites.xml"/> </sidebar> </body> </page> </document> Index: pear/XML_Statistics/examples/example1.php +++ pear/XML_Statistics/examples/example1.php <?PHP require_once 'XML/Statistics.php'; $stat = new XML_Statistics(array("ignoreWhitespace" => true)); $result = $stat->analyzeFile("example.xml"); if ($stat->isError($result)) { die("Error: " . $result->getMessage()); } // total amount of tags: echo "Total tags: " . $stat->countTag()."<br>"; // count amount of 'title' attribute, in all tags echo "Occurences of attribute title: " . $stat->countAttribute("title")."<br>"; // count amount of 'title' attribute, only in <section> tags echo "Occurences of attribute title in tag section: " . $stat->countAttribute("title", "section")."<br>"; // count total number of tags in depth 4 echo "Amount of Tags in depth 4: " . $stat->countTagsInDepth(4)."<br>"; echo "Occurences of PHP Blocks: " . $stat->countPI("PHP")."<br>"; echo "Occurences of external entity 'bar': " . $stat->countExternalEntity("bar")."<br>"; echo "Data chunks: " . $stat->countDataChunks()."<br>"; echo "Length of all data chunks: " . $stat->getCDataLength()."<br>"; ?> Index: pear/XML_Statistics/examples/example2.php +++ pear/XML_Statistics/examples/example2.php <?PHP require_once 'XML/Statistics.php'; $stat = new XML_Statistics(); $xml = implode("",file("http://pear.php.net/rss.php")); // analyze a string instead of a file $result = $stat->analyzeString($xml); if ($stat->isError($result)) { die("Error: " . $result->getMessage()); } echo "Total tags: " . $stat->countTag()."<br>"; echo "Occurences of item: " . $stat->countTag('item')."<br>"; echo "Maximum nesting level: " . $stat->getMaxDepth()."<br>"; // these are the <item> tags => amount of news entries echo "Amount of Tags in depth 3: " . $stat->countTagsInDepth(3)."<br>"; ?> Index: pear/XML_Statistics/examples/example3.php +++ pear/XML_Statistics/examples/example3.php <?PHP /** * This example makes use of * XML_Statistics in conjunction with * Math_Stats to calculate average occurences * and other mathematical statistics * of all tags in the documents */ require_once 'XML/Statistics.php'; require_once 'Math/Stats.php'; $stat = new XML_Statistics(); $result = $stat->analyzeFile("example.xml"); if ($stat->isError($result)) { die("Error: " . $result->getMessage()); } // get number of tags per tagname $tags = $stat->getTagOccurences(); // use Math_Stats $s = new Math_Stats(); $s->setData($tags); $stats = $s->calcBasic(); echo "<pre>"; print_r($stats); echo "</pre>"; ?>
« previous php.pear.cvs (#12799) next »