phpDocumentor SAFOX
SAFOX_P
[ class tree: SAFOX ] [ index: SAFOX ] [ all elements ]

Procedural File: safox_p.cls.php

Source Location: /safox_p.cls.php

Page Details

The SAFOX package is a collection of light-weight API for object-oriented PHP to handle XML files.

As of version 0.5 the SAFOX wrapper is the starting point for all SAFOX operations. It is an extreme light weight class that allows to create any of the SAFOX objects (XMLDoc, XMLParser, RSSDoc, RSSParser) without further include or require commands. All necessary libraries of the SAFOX API will be loaded only when/if the file is required, thus making scripts lighter and faster.

Providing three base classes, XMLDoc, XMLNode, XMLParser, and extended RSSDoc and RSSParser Classes for RSS 2.0 Handling, the SAFOX package allows an easy and clean way to handle all kind of XML files. The SAFOX package is currently developed in PHP4.X and copyright by Christian Hansel, cpi service, Leipzig. The code is provided under the GNU Public License Version 2 and may freely be used, modified, and distributed with original copyright notices to be maintained.

If no copy of the license is provided check http://www.gnu.org/licenses/gpl2.txt

The SAFOX Package consists of five files:

  • safox.cls.php -- A OOP wrapper for all SAFOX objects which loads one or more of the following files only when required
  • safox_g.cls.php -- Provides the XMLDOc & XMLNODE Classes
  • safox_p.cls.php -- Provides a simple, light-weight, but strong Parser for XML Documents that returns a XMLDOC Object
The SAFOX_RSS sub package consists of two files but requires the SAFOX Base classes:
  • safox_g_rss.cls.php -- Provides the RSSDOc & RSSNODE Classes
  • safox_p_rss.cls.php -- Provides a simple, light-weight, but strong Parser for XML Documents that returns a XMLDOC Object

This is the Parsing Base Library for OOP-parsing of xml files to retrieve OOP object (XMLDoc)

Events fired during Parsing are:

 XPE_ON_PARSE_DEF -  Event On Parsing 
 XPE_ON_PARSE_DTD -  On Parsing DTD 
 XPE_ON_PARSE_TAG -  On Parsing TagName/Type of Node
 XPE_ON_PARSE_ATT -  On Parsing Attribute String
 XPE_ON_PARSE_CDT -  On Parsing CDATA/content of node
 XPE_ON_PARSE_NOD -  On Node Parsing Completed Object
 XPE_ON_PARSE_CMT -  On Parsing a Comment
 XPE_ON_PARSE_XSP -  On Parsing XML Specific Tags  *
see the documented onParseCDATA function that is by default registered as eventhandler for XPE_ON_PARSE_CDT for further information and an explanatory example full api documentation and examples available at http://www.cpi-service.com/safox/

Changes History : version 0.5

  • The SAFOX library has been reorganised and now requires only one wrapper file (safox.cls.php)
  • added subpackage SAFOX_RSS provides two classes RSSDoc and RSSParser for the generation and parsing of RSS 2.0
  • added Feature: setEntityConversion is a function that specifies whether or not special characters in CDATA should be converted into HT/XML-Entities (e.g. & into &, ' into ' ...) (true) or enclosed into CDATA tags (false)
version 0.42
  • BUGFIX 20051130-2 fixes a problem where comments containing tags caused the the parser to break
version 0.41 of SAFOX package includes changes
  • BUGFIX 20051130 Code Cleanup provided by Cristiano Degiorgis [cri@webprofessor.it]
Changes History : version 0.4 of SAFOX package includes changes
  • BUGFIX 20051128 that fixes problems with removing nodes from the document
  • remove, and delete methods added as aliases to destroy in XMLNode class
  • method cleanUP added to XMLDoc class
  • method cleanUP added to XMLNode class - see destription
Changes History : version 0.3 of SAFOX package includes changes
  • BUGFIX 20051123 corrects a problem that was caused when a repeated call to setId of child Nodes was made
  • addNodeAfter Method added to XMLDoc Class
  • addNodeAfter Method added to XMLNode Class
  • addNodeBefore Method added to XMLDoc Class
  • addNodeBefore Method added to XMLNode Class
version 0.2 of SAFOX package includes changes
  • getchildNodeByTagName() Method added to XMLDOC
  • writeToFile Method added to XMLDOC
  • BUGFIX 20051117 in xmlParser - corrects a mishandling of <![CDATA[ .. ]]> enclosed tag content that caused the parser to break when dealing with tags within the CDATA

Copyright:  (c) 2003-2005 CVH, cpi-service
File:  safox_p.cls.php
Date:  2005-11-28
Version:  0.5
Link:  http://www.cpi-service.com
License:  GPL2
Author:  CVH, cpi-service ; cvh@cpi-service.com
Includes
require_once (dirname(__FILE__)."/"."safox_g.cls.php") [line 102]
[ Top ]


Constants
SAFOX_P  [line 100]

SAFOX_P = true

Event identifiers & constants

Constants defining types of events fired duriung parsing


[ Top ]

XML_MAX_LINE_SIZE  [line 105]

XML_MAX_LINE_SIZE = 4096

[ Top ]

XPE_ON_PARSE_ATT  [line 109]

XPE_ON_PARSE_ATT = 3

[ Top ]

XPE_ON_PARSE_CDT  [line 110]

XPE_ON_PARSE_CDT = 4

[ Top ]

XPE_ON_PARSE_CMT  [line 112]

XPE_ON_PARSE_CMT = 6

[ Top ]

XPE_ON_PARSE_DEF  [line 106]

XPE_ON_PARSE_DEF = 0

[ Top ]

XPE_ON_PARSE_DTD  [line 107]

XPE_ON_PARSE_DTD = 1

[ Top ]

XPE_ON_PARSE_NOD  [line 111]

XPE_ON_PARSE_NOD = 5

[ Top ]

XPE_ON_PARSE_TAG  [line 108]

XPE_ON_PARSE_TAG = 2

[ Top ]

XPE_ON_PARSE_XSP  [line 113]

XPE_ON_PARSE_XSP = 7

[ Top ]


Functions
onParseCDATA  [line 148]

void onParseCDATA( $cdata &$cdata, [$node $node = null], [$parser $parser = null]  )

OnParseCDATA - is registered in Class XMLPARSER as a PreProcessing EventHandler for CDATA-Strings called when the XPE_ON_PARSE_CDT event is fired

Listed here to demonstrate how events should be handled

  
function onParseCDATA(&$cdata,$node = null,$parser = null) {
		if ($cdata) { 
			$search = array ( "'\!\[CDATA\['i","'\]([\r\n\s]*)\]'",
							  "'&(quot|#34);'i","'&(amp|#38);'i",
							  "'&(lt|#60);'i","'&(gt|#62);'i","'&(apos|#39);'i" );	
			$replace = array( "","","","\"","&","<",">","'" );
			$cdata = preg_replace ($search, $replace, $cdata);
	  }}
Events fired during Parsing are:
 XPE_ON_PARSE_DEF -  Event On Parsing 
 XPE_ON_PARSE_DTD -  On Parsing DTD 
 XPE_ON_PARSE_TAG -  On Parsing TagName/Type of Node
 XPE_ON_PARSE_ATT -  On Parsing Attribute String
 XPE_ON_PARSE_CDT -  On Parsing CDATA/content of node
 XPE_ON_PARSE_NOD -  On Node Parsing Completed Object
 XPE_ON_PARSE_CMT -  On Parsing a Comment
 XPE_ON_PARSE_XSP -  On Parsing XML Specific Tags  *

Parameters:
$cdata   &$cdata: 
  • referenced variable containing the content /CDATA that was detected during parsing
$node   $node: 
  • referenced node object to which the content will be added during parsing
$parser   $parser: 
  • reference to parser object


[ Top ]


Documentation generated on Thu, 9 Feb 2006 13:55:15 +0100 by phpDocumentor 1.3.0RC3