protected function ws_trim()
 {
     if ($this->ws_keep()) {
         return;
     }
     switch (self::$_ws_state) {
         case self::WS_SPACE:
             $node = $this->_node;
             if ($node->nodeName === "#text") {
                 $node->data = preg_replace("/[ \t\r\n\f]+/u", " ", $text);
                 if (isset($node->data[0]) && $node->data[0] === " ") {
                     $node->data = ltrim($node->data);
                 }
                 if ($node->data !== "") {
                     self::$_ws_state = self::WS_TEXT;
                     if (preg_match("/[ \t\r\n\f]+\$/u", $node->data)) {
                         $node->data = ltrim($node->data);
                     }
                 }
             }
             break;
         case self::WS_TEXT:
     }
 }
Example #2
0
 protected function ws_trim()
 {
     if ($this->ws_keep()) {
         return;
     }
     switch (self::$_ws_state) {
         case self::WS_SPACE:
             $node = $this->_node;
             if ($node->nodeName === "#text") {
                 $node->data = preg_replace("/[ \t\r\n\f]+/u", " ", $text);
                 // starts with a whitespace
                 if (isset($node->data[0]) && $node->data[0] === " ") {
                     $node->data = ltrim($node->data);
                 }
                 // if not empty
                 if ($node->data !== "") {
                     // change the current state (text)
                     self::$_ws_state = self::WS_TEXT;
                     // ends with a whitespace
                     if (preg_match("/[ \t\r\n\f]+\$/u", $node->data)) {
                         $node->data = ltrim($node->data);
                     }
                 }
             }
             break;
         case self::WS_TEXT:
     }
 }