XML_Transformer
[ class tree: XML_Transformer ] [ index: XML_Transformer ] [ all elements ]

Source for file Transformer.php

Documentation is available at Transformer.php

  1. <?php
  2. //
  3. // +---------------------------------------------------------------------------+
  4. // | PEAR :: XML :: Transformer                                                |
  5. // +---------------------------------------------------------------------------+
  6. // | Copyright (c) 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> and |
  7. // +---------------------------------------------------------------------------+
  8. // | This source file is subject to version 3.00 of the PHP License,           |
  9. // | that is available at http://www.php.net/license/3_0.txt.                  |
  10. // | If you did not receive a copy of the PHP license and are unable to        |
  11. // | obtain it through the world-wide-web, please send a note to               |
  12. // | license@php.net so we can mail you a copy immediately.                    |
  13. // +---------------------------------------------------------------------------+
  14. //
  15. // $Id$
  16. //
  17.  
  18. require_once 'XML/Transformer/CallbackRegistry.php';
  19. require_once 'XML/Util.php';
  20.  
  21. /**
  22.  * XML Transformations in PHP.
  23.  *
  24.  * With this class one can easily bind PHP functionality to XML tags,
  25.  * thus transforming an XML input tree into another XML tree without
  26.  * the need for XSLT.
  27.  *
  28.  * @author      Sebastian Bergmann <sb@sebastian-bergmann.de>
  29.  * @author
  30.  * @copyright
  31.  * @license     http://www.php.net/license/3_0.txt The PHP License, Version 3.0
  32.  * @category    XML
  33.  * @package     XML_Transformer
  34.  */
  35. class XML_Transformer {
  36.     // {{{ Members
  37.  
  38.     /**
  39.     * @var    object 
  40.     * @access private
  41.     */
  42.     var $_callbackRegistry = NULL;
  43.  
  44.     /**
  45.     * If TRUE, XML attribute and element names will be
  46.     * case-folded.
  47.     * 
  48.     * @var    boolean 
  49.     * @access private
  50.     * @see    $_caseFoldingTo
  51.     */
  52.     var $_caseFolding = FALSE;
  53.  
  54.     /**
  55.     * Can be set to either CASE_UPPER or CASE_LOWER
  56.     * and sets the target case for the case-folding.
  57.     *
  58.     * @var    integer 
  59.     * @access private
  60.     * @see    $_caseFolding
  61.     */
  62.     var $_caseFoldingTo = CASE_UPPER;
  63.  
  64.     /**
  65.     * When set to TRUE empty XML tags (<foo></foo>) are
  66.     * collapsed to their short-tag (<foo/>) equivalent.
  67.     *
  68.     * @var    boolean 
  69.     * @access private
  70.     */
  71.     var $_collapseEmptyTags = FALSE;
  72.  
  73.     /**
  74.     * Collapse mode
  75.     *
  76.     * @var    int 
  77.     * @access private
  78.     */
  79.     var $_collapseEmptyTagsMode = XML_UTIL_COLLAPSE_ALL;
  80.  
  81.     /**
  82.     * If TRUE, debugging information will be sent to
  83.     * the error.log.
  84.     *
  85.     * @var    boolean 
  86.     * @access private
  87.     * @see    $_debugFilter
  88.     */
  89.     var $_debug = FALSE;
  90.  
  91.     /**
  92.     * If not empty, debugging information will only be generated
  93.     * for XML elements whose names are in this array.
  94.     *
  95.     * @var    array 
  96.     * @access private
  97.     * @see    $_debug
  98.     */
  99.     var $_debugFilter = array();
  100.  
  101.     /**
  102.     * Specifies the target to which error messages and
  103.     * debugging messages are sent.
  104.     *
  105.     * @var    string 
  106.     * @access private
  107.     * @see    $_debug
  108.     */
  109.     var $_logTarget 'error_log';
  110.  
  111.     /**
  112.     * @var    array 
  113.     * @access private
  114.     */
  115.     var $_attributesStack = array();
  116.  
  117.     /**
  118.     * @var    array 
  119.     * @access private
  120.     */
  121.     var $_cdataStack = array('');
  122.  
  123.     /**
  124.     * @var    array 
  125.     * @access private
  126.     */
  127.     var $_elementStack = array();
  128.  
  129.     /**
  130.     * @var    integer 
  131.     * @access private
  132.     */
  133.     var $_level = 0;
  134.  
  135.     /**
  136.     * @var    string 
  137.     * @access private
  138.     */
  139.     var $_lastProcessed '';
  140.  
  141.     /**
  142.     * @var    boolean 
  143.     * @access public
  144.     */
  145.     var $_secondPassRequired = FALSE;
  146.  
  147.     /**
  148.     * @var    integer 
  149.     * @access private
  150.     */
  151.     var $_depth = 0;
  152.  
  153.     // }}}
  154.     // {{{ function XML_Transformer($parameters = array())
  155.  
  156.     /**
  157.     * Constructor.
  158.     *
  159.     * @param  array 
  160.     * @access public
  161.     */
  162.     function XML_Transformer($parameters = array()) {
  163.         // Parse parameters array.
  164.  
  165.         if (isset($parameters['debug'])) {
  166.             $this->setDebug($parameters['debug']);
  167.         }
  168.  
  169.         $this->_caseFolding           = isset($parameters['caseFolding'])           $parameters['caseFolding']           : FALSE;
  170.         $this->_collapseEmptyTags     = isset($parameters['collapseEmptyTags'])     $parameters['collapseEmptyTags']     : FALSE;
  171.         $this->_collapseEmptyTagsMode = isset($parameters['collapseEmptyTagsMode']$parameters['collapseEmptyTagsMode': XML_UTIL_COLLAPSE_ALL;
  172.         $this->_caseFoldingTo         = isset($parameters['caseFoldingTo'])         $parameters['caseFoldingTo']         : CASE_UPPER;
  173.         $this->_lastProcessed         = isset($parameters['lastProcessed'])         $parameters['lastProcessed']         '';
  174.         $this->_logTarget             = isset($parameters['logTarget'])             $parameters['logTarget']             'error_log';
  175.  
  176.         $autoload                     = isset($parameters['autoload'])              $parameters['autoload']              : FALSE;
  177.         $overloadedNamespaces         = isset($parameters['overloadedNamespaces'])  $parameters['overloadedNamespaces']  : array();
  178.         $recursiveOperation           = isset($parameters['recursiveOperation'])    $parameters['recursiveOperation']    : TRUE;
  179.  
  180.         // Initialize callback registry.
  181.  
  182.         if (!isset($parameters['callbackRegistry'])) {
  183.             $this->_callbackRegistry = new XML_Transformer_CallbackRegistry($recursiveOperation);
  184.         else {
  185.             $this->_callbackRegistry &$parameters['callbackRegistry'];
  186.         }
  187.  
  188.         foreach ($overloadedNamespaces as $namespacePrefix => $object{
  189.             $this->overloadNamespace(
  190.               $namespacePrefix,
  191.               $object
  192.             );
  193.         }
  194.  
  195.         if ($autoload !== FALSE{
  196.             $this->_autoload($autoload);
  197.         }
  198.     }
  199.  
  200.     // }}}
  201.     // {{{ function canonicalize($target)
  202.  
  203.     /**
  204.     * Canonicalizes a given attributes array or element name.
  205.     *
  206.     * @param  mixed 
  207.     * @return mixed 
  208.     * @access public
  209.     */
  210.     function canonicalize($target{
  211.         if ($this->_caseFolding{
  212.             if (is_string($target)) {
  213.                 return ($this->_caseFoldingTo == CASE_UPPERstrtoupper($targetstrtolower($target);
  214.             else {
  215.                 return array_change_key_case(
  216.                   $target,
  217.                   $this->_caseFoldingTo
  218.                 );
  219.             }
  220.         }
  221.  
  222.         return $target;
  223.     }
  224.  
  225.     // }}}
  226.     // {{{ function overloadNamespace($namespacePrefix, &$object, $recursiveOperation = '')
  227.  
  228.     /**
  229.     * Overloads an XML Namespace.
  230.     *
  231.     * @param  string 
  232.     * @param  object 
  233.     * @param  boolean 
  234.     * @access public
  235.     */
  236.     function overloadNamespace($namespacePrefix&$object$recursiveOperation ''{
  237.         if (empty($namespacePrefix||
  238.             $namespacePrefix == '&MAIN'{
  239.             $namespacePrefix '&MAIN';
  240.         else {
  241.             $namespacePrefix $this->canonicalize($namespacePrefix);
  242.         }
  243.  
  244.         $result $this->_callbackRegistry->overloadNamespace(
  245.           $namespacePrefix,
  246.           $object,
  247.           $recursiveOperation
  248.         );
  249.  
  250.         if ($result === TRUE{
  251.             if ($object->secondPassRequired{
  252.                 $this->_secondPassRequired = TRUE;
  253.             }
  254.  
  255.             // Call initObserver() on the object, if it exists.
  256.  
  257.             if (method_exists($object'initObserver')) {
  258.                 $object->initObserver(
  259.                   $namespacePrefix,
  260.                   $this
  261.                 );
  262.             }
  263.         else {
  264.             $this->sendMessage(
  265.               $result,
  266.               $this->_logTarget
  267.             );
  268.         }
  269.     }
  270.  
  271.     // }}}
  272.     // {{{ function unOverloadNamespace($namespacePrefix)
  273.  
  274.     /**
  275.     * Reverts overloading of a given XML Namespace.
  276.     *
  277.     * @param  string 
  278.     * @access public
  279.     */
  280.     function unOverloadNamespace($namespacePrefix{
  281.         $this->_callbackRegistry->unOverloadNamespace($namespacePrefix);
  282.     }
  283.  
  284.     // }}}
  285.     // {{{ function isOverloadedNamespace($namespacePrefix)
  286.  
  287.     /**
  288.     * Returns TRUE if a given namespace is overloaded,
  289.     * FALSE otherwise.
  290.     *
  291.     * @param  string 
  292.     * @return boolean 
  293.     * @access public
  294.     */
  295.     function isOverloadedNamespace($namespacePrefix{
  296.         return $this->_callbackRegistry->isOverloadedNamespace(
  297.           $this->canonicalize($namespacePrefix)
  298.         );
  299.     }
  300.  
  301.     // }}}
  302.     // {{{ function sendMessage($message, $target = 'error_log')
  303.  
  304.     /**
  305.     * Sends a message to a given target.
  306.     *
  307.     * @param  string 
  308.     * @param  string 
  309.     * @access public
  310.     */
  311.     function sendMessage($message$target 'error_log'{
  312.         switch ($target{
  313.             case 'echo':
  314.             case 'print'{
  315.                 print $message;
  316.             }
  317.             break;
  318.  
  319.             default: {
  320.                 error_log($message);
  321.             }
  322.         }
  323.     }
  324.  
  325.     // }}}
  326.     // {{{ function setCaseFolding($caseFolding)
  327.  
  328.     /**
  329.     * Sets the XML parser's case-folding option.
  330.     *
  331.     * @param  boolean 
  332.     * @param  integer 
  333.     * @access public
  334.     */
  335.     function setCaseFolding($caseFolding$caseFoldingTo = CASE_UPPER{
  336.         if (is_bool($caseFolding&&
  337.             ($caseFoldingTo == CASE_LOWER || $caseFoldingTo == CASE_UPPER)) {
  338.             $this->_caseFolding   $caseFolding;
  339.             $this->_caseFoldingTo $caseFoldingTo;
  340.         }
  341.     }
  342.  
  343.     // }}}
  344.     // {{{ function setCollapsingOfEmptyTags($collapseEmptyTags, $mode = XML_UTIL_COLLAPSE_ALL)
  345.  
  346.     /**
  347.     * Sets the collapsing of empty tags.
  348.     *
  349.     * @param  boolean 
  350.     * @param  integer 
  351.     * @access public
  352.     */
  353.     function setCollapsingOfEmptyTags($collapseEmptyTags$mode = XML_UTIL_COLLAPSE_ALL{
  354.         if (is_bool($collapseEmptyTags&&
  355.             ($mode == XML_UTIL_COLLAPSE_ALL || $mode == XML_UTIL_COLLAPSE_XHTML_ONLY)) {
  356.             $this->_collapseEmptyTags     $collapseEmptyTags;
  357.             $this->_collapseEmptyTagsMode $mode;
  358.         }
  359.     }
  360.  
  361.     // }}}
  362.     // {{{ function setDebug($debug)
  363.  
  364.     /**
  365.     * Enables or disables debugging information.
  366.     *
  367.     * @param  mixed 
  368.     * @access public
  369.     */
  370.     function setDebug($debug{
  371.         if (is_array($debug)) {
  372.             $this->_debug       = TRUE;
  373.             $this->_debugFilter array_flip($debug);
  374.         }
  375.  
  376.         else if (is_bool($debug)) {
  377.             $this->_debug $debug;
  378.         }
  379.     }
  380.  
  381.     // }}}
  382.     // {{{ function setLogTarget($logTarget)
  383.  
  384.     /**
  385.     * Sets the target to which error messages and
  386.     * debugging messages are sent.
  387.     *
  388.     * @param  string 
  389.     * @access public
  390.     */
  391.     function setLogTarget($logTarget{
  392.         $this->_logTarget $logTarget;
  393.     }
  394.  
  395.     // }}}
  396.     // {{{ function setRecursiveOperation($recursiveOperation)
  397.  
  398.     /**
  399.     * Enables or disables the recursive operation.
  400.     *
  401.     * @param  boolean 
  402.     * @access public
  403.     */
  404.     function setRecursiveOperation($recursiveOperation{
  405.         $this->_callbackRegistry->setRecursiveOperation($recursiveOperation);
  406.     }
  407.  
  408.     // }}}
  409.     // {{{ function stackdump()
  410.  
  411.     /**
  412.     * Returns a stack dump as a debugging aid.
  413.     *
  414.     * @return string 
  415.     * @access public
  416.     */
  417.     function stackdump({
  418.         $stackdump sprintf(
  419.           "Stackdump (level: %s) follows:\n",
  420.           $this->_level
  421.         );
  422.  
  423.         for ($i $this->_level$i >= 0; $i--{
  424.           $stackdump .= sprintf(
  425.             "level=%d\nelement=%s:%s\ncdata=%s\n\n",
  426.             $i,
  427.             isset($this->_elementStack[$i])    $this->_elementStack[$i]                                  '',
  428.             isset($this->_attributesStack[$i]? XML_Util::attributesToString($this->_attributesStack[$i]'',
  429.             isset($this->_cdataStack[$i])      $this->_cdataStack[$i]                                    ''
  430.           );
  431.         }
  432.  
  433.         return $stackdump;
  434.     }
  435.  
  436.     // }}}
  437.     // {{{ function transform($xml)
  438.  
  439.     /**
  440.     * Transforms a given XML string using the registered
  441.     * PHP callbacks for overloaded tags.
  442.     *
  443.     * @param  string 
  444.     * @return string 
  445.     * @access public
  446.     */
  447.     function transform($xml{
  448.         // Do not process input when it contains no XML elements.
  449.  
  450.         if (strpos($xml'<'=== FALSE{
  451.             return $xml;
  452.         }
  453.  
  454.         // Replace all occurrences of the '&' character that are not directly
  455.         // followed by 'amp;' with the '&amp;' entity.
  456.  
  457.         $xml preg_replace('/&(?!amp;)/i''&amp;'$xml);
  458.  
  459.         // Create XML parser, set parser options.
  460.  
  461.         $parser xml_parser_create();
  462.  
  463.         xml_set_object($parser$this);
  464.         xml_parser_set_option($parserXML_OPTION_CASE_FOLDING$this->_caseFolding);
  465.  
  466.         // Register SAX callbacks.
  467.  
  468.         xml_set_element_handler($parser'_startElement''_endElement');
  469.         xml_set_character_data_handler($parser'_characterData');
  470.         xml_set_default_handler($parser'_characterData');
  471.  
  472.         // Parse input.
  473.  
  474.         if (!xml_parse($parser$xmlTRUE)) {
  475.             $line xml_get_current_line_number($parser);
  476.  
  477.             $errorMessage sprintf(
  478.               "Transformer: XML Error: %s at line %d:%d\n",
  479.               xml_error_string(xml_get_error_code($parser)),
  480.               $line,
  481.               xml_get_current_column_number($parser)
  482.             );
  483.  
  484.             $exml preg_split('/\n/'$xml);
  485.  
  486.             $start ($line - 3 > 0)             $line - 3 : 0;
  487.             $end   ($line + 3 < sizeof($exml)) $line + 3 : sizeof($exml);
  488.  
  489.             for ($i $start$i $end$i++{
  490.                 $errorMessage .= sprintf(
  491.                   "line %d: %s\n",
  492.                   $i+1,
  493.                   $exml[$i]
  494.                 );
  495.             }
  496.  
  497.             $this->sendMessage(
  498.               $errorMessage "\n" $this->stackdump(),
  499.               $this->_logTarget
  500.             );
  501.  
  502.             return '';
  503.         }
  504.  
  505.         $result $this->_cdataStack[0];
  506.  
  507.         // Clean up.
  508.  
  509.         xml_parser_free($parser);
  510.  
  511.         $this->_attributesStack = array();
  512.         $this->_cdataStack      = array('');
  513.         $this->_elementStack    = array();
  514.         $this->_level           = 0;
  515.         $this->_lastProcessed   '';
  516.  
  517.         // Perform second transformation pass, if required.
  518.  
  519.         $secondPassRequired $this->_secondPassRequired;
  520.  
  521.         if ($secondPassRequired{
  522.             $this->_depth++;
  523.             $this->_secondPassRequired = FALSE;
  524.             $result $this->transform($result);
  525.             $this->_depth--;
  526.         }
  527.  
  528.         if ($this->_collapseEmptyTags &&
  529.             $this->_depth == 0{
  530.             $result = XML_Util::collapseEmptyTags(
  531.               $result,
  532.               $this->_collapseEmptyTagsMode
  533.             );
  534.         }
  535.  
  536.         $this->_secondPassRequired = $secondPassRequired;
  537.  
  538.         // Return result of the transformation.
  539.  
  540.         return $result;
  541.     }
  542.  
  543.     // }}}
  544.     // {{{ function _startElement($parser, $element, $attributes)
  545.  
  546.     /**
  547.     * SAX callback for 'startElement' event.
  548.     *
  549.     * @param  resource 
  550.     * @param  string 
  551.     * @param  array 
  552.     * @access private
  553.     */
  554.     function _startElement($parser$element$attributes{
  555.         $attributes $this->canonicalize($attributes);
  556.         $element    $this->canonicalize($element);
  557.         $qElement   = XML_Util::splitQualifiedName($element'&MAIN');
  558.         $process    $this->_lastProcessed != $element;
  559.  
  560.         // Push element's name and attributes onto the stack.
  561.  
  562.         $this->_level++;
  563.         $this->_elementStack[$this->_level]    $element;
  564.         $this->_attributesStack[$this->_level$attributes;
  565.  
  566.         if ($this->_checkDebug($element)) {
  567.             $this->sendMessage(
  568.               sprintf(
  569.                 'startElement[%d]: %s %s',
  570.                 $this->_level,
  571.                 $element,
  572.                 XML_Util::attributesToString($attributes)
  573.               )
  574.             );
  575.         }
  576.  
  577.         if ($process &&
  578.             isset($this->_callbackRegistry->overloadedNamespaces[$qElement['namespace']]['active'])) {
  579.             // The event is handled by a callback
  580.             // that is registered for this namespace.
  581.  
  582.             $cdata $this->_callbackRegistry->overloadedNamespaces[$qElement['namespace']]['object']->startElement(
  583.               $qElement['localPart'],
  584.               $attributes
  585.             );
  586.         else {
  587.             // No callback was registered for this element's
  588.             // opening tag, copy it.
  589.  
  590.             $cdata sprintf(
  591.               '<%s%s>',
  592.               $element,
  593.               XML_Util::attributesToString($attributes)
  594.             );
  595.         }
  596.  
  597.         $this->_cdataStack[$this->_level$cdata;
  598.     }
  599.  
  600.     // }}}
  601.     // {{{ function _endElement($parser, $element)
  602.  
  603.     /**
  604.     * SAX callback for 'endElement' event.
  605.     *
  606.     * @param  resource 
  607.     * @param  string 
  608.     * @access private
  609.     */
  610.     function _endElement($parser$element{
  611.         $cdata     $this->_cdataStack[$this->_level];
  612.         $element   $this->canonicalize($element);
  613.         $qElement  = XML_Util::splitQualifiedName($element'&MAIN');
  614.         $process   $this->_lastProcessed != $element;
  615.         $recursion = FALSE;
  616.  
  617.         if ($process &&
  618.             isset($this->_callbackRegistry->overloadedNamespaces[$qElement['namespace']]['active'])) {
  619.             // The event is handled by a callback
  620.             // that is registered for this namespace.
  621.  
  622.             $result $this->_callbackRegistry->overloadedNamespaces[$qElement['namespace']]['object']->endElement(
  623.               $qElement['localPart'],
  624.               $cdata
  625.             );
  626.  
  627.             if (is_array($result)) {
  628.                 $cdata   &$result[0];
  629.                 $reparse $result[1];
  630.             else {
  631.                 $cdata   &$result;
  632.                 $reparse = TRUE;
  633.             }
  634.  
  635.             $recursion $reparse &&
  636.                          isset($this->_elementStack[$this->_level-1]&&
  637.                          $this->_callbackRegistry->overloadedNamespaces[$qElement['namespace']]['recursiveOperation'];
  638.         else {
  639.             // No callback was registered for this element's
  640.             // closing tag, copy it.
  641.  
  642.             $cdata .= '</' $element '>';
  643.         }
  644.  
  645.         if ($recursion{
  646.             // Recursively process this transformation's result.
  647.  
  648.             if ($this->_checkDebug('&RECURSE')) {
  649.                 $this->sendMessage(
  650.                   sprintf(
  651.                     'start recursion[%d]: %s',
  652.                     $this->_level,
  653.                     $cdata
  654.                   )
  655.                 );
  656.             }
  657.  
  658.             $transformer = new XML_Transformer(
  659.               array(
  660.                 'callbackRegistry' => &$this->_callbackRegistry,
  661.                 'caseFolding'      => $this->_caseFolding,
  662.                 'caseFoldingTo'    => $this->_caseFoldingTo,
  663.                 'lastProcessed'    => $element
  664.               )
  665.             );
  666.  
  667.             $cdata substr($transformer->transform("<_>$cdata</_>")3-4);
  668.  
  669.             if ($this->_checkDebug('&RECURSE')) {
  670.                 $this->sendMessage(
  671.                   sprintf(
  672.                     'end recursion[%d]: %s',
  673.                     $this->_level,
  674.                     $cdata
  675.                   )
  676.                 );
  677.             }
  678.         }
  679.  
  680.         if ($this->_checkDebug($element)) {
  681.             $this->sendMessage(
  682.               sprintf(
  683.                 'endElement[%d]: %s (with cdata=%s)',
  684.                 $this->_level,
  685.                 $element,
  686.                 $this->_cdataStack[$this->_level]
  687.               )
  688.             );
  689.         }
  690.  
  691.         // Move result of this transformation step to
  692.         // the parent's CDATA section.
  693.  
  694.         $this->_cdataStack[--$this->_level.= $cdata;
  695.     }
  696.  
  697.     // }}}
  698.     // {{{ function _characterData($parser, $cdata)
  699.  
  700.     /**
  701.     * SAX callback for 'characterData' event.
  702.     *
  703.     * @param  resource 
  704.     * @param  string 
  705.     * @access private
  706.     */
  707.     function _characterData($parser$cdata{
  708.       if ($this->_checkDebug('&CDATA')) {
  709.           $this->sendMessage(
  710.             sprintf(
  711.               'cdata [%d]: %s + %s',
  712.               $this->_level,
  713.               $this->_cdataStack[$this->_level],
  714.               $cdata
  715.             )
  716.           );
  717.       }
  718.  
  719.       $this->_cdataStack[$this->_level.= $cdata;
  720.     }
  721.  
  722.     // }}}
  723.     // {{{ function _autoload($namespaces)
  724.  
  725.     /**
  726.     * Loads either all (TRUE) or a selection of namespace
  727.     * handlers from XML/Transformer/Namespace/.
  728.     *
  729.     * @param  mixed 
  730.     * @access private
  731.     */
  732.     function _autoload($namespaces{
  733.         $path dirname(__FILE__'/Transformer/Namespace/';
  734.  
  735.         if ($namespaces === TRUE{
  736.             $namespaces = array();
  737.  
  738.             if ($dir @opendir($path)) {
  739.                 while (($file @readdir($dir)) !== FALSE{
  740.                     if (strstr($file'.php')) {
  741.                         $namespaces[$this->canonicalize(
  742.                           strtolower(
  743.                             substr($file0-4)
  744.                           )
  745.                         );
  746.                     }
  747.                 }
  748.             }
  749.         }
  750.  
  751.         else if (is_string($namespaces)) {
  752.             $namespaces = array($namespaces);
  753.         }
  754.  
  755.         foreach ($namespaces as $namespace{
  756.             if (@include_once($path $namespace '.php')) {
  757.                 $className 'XML_Transformer_Namespace_' $namespace;
  758.                 $object    = new $className;
  759.  
  760.                 $this->overloadNamespace(
  761.                   !empty($object->defaultNamespacePrefix$object->defaultNamespacePrefix : $namespace,
  762.                   $object
  763.                 );
  764.             }
  765.         }
  766.     }
  767.  
  768.     // }}}
  769.     // {{{ function _checkDebug($currentElement = '')
  770.  
  771.     /**
  772.     * Checks whether a debug message should be printed
  773.     * for the current event.
  774.     *
  775.     * @param  string 
  776.     * @return boolean 
  777.     * @access private
  778.     */
  779.     function _checkDebug($currentElement ''{
  780.         if ($this->_debug &&
  781.             (empty($this->_debugFilter||
  782.              isset($this->_debugFilter[$currentElement]))) {
  783.             return TRUE;
  784.         else {
  785.             return FALSE;
  786.         }
  787.     }
  788.  
  789.     // }}}
  790. }
  791.  
  792. /*
  793.  * vim600:  et sw=2 ts=2 fdm=marker
  794.  * vim<600: et sw=2 ts=2
  795.  */
  796. ?>

Documentation generated on Mon, 11 Mar 2019 15:48:10 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.