| Conditions | 4 |
| Paths | 4 |
| Total Lines | 34 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | protected function normalizeAttribute(DOMAttr $attribute) |
||
| 25 | { |
||
| 26 | $element = $attribute->parentNode; |
||
| 27 | if (!$this->isXsl($element)) |
||
| 28 | { |
||
| 29 | // Replace XPath expressions in non-XSL elements |
||
| 30 | $this->replaceAVT($attribute); |
||
| 31 | } |
||
| 32 | elseif (in_array($attribute->nodeName, ['match', 'select', 'test'], true)) |
||
| 33 | { |
||
| 34 | // Replace the content of match, select and test attributes of an XSL element |
||
| 35 | $element->setAttribute( |
||
| 36 | $attribute->nodeName, |
||
| 37 | XPathHelper::minify($attribute->nodeValue) |
||
| 38 | ); |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Minify XPath expressions in given attribute |
||
| 44 | * |
||
| 45 | * @param DOMAttr $attribute |
||
| 46 | * @return void |
||
| 47 | */ |
||
| 48 | protected function replaceAVT(DOMAttr $attribute) |
||
| 49 | { |
||
| 50 | AVTHelper::replace( |
||
| 51 | $attribute, |
||
| 52 | function ($token) |
||
| 53 | { |
||
| 54 | if ($token[0] === 'expression') |
||
| 55 | { |
||
| 56 | $token[1] = XPathHelper::minify($token[1]); |
||
| 57 | } |
||
| 58 | |||
| 63 | } |