| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
class MathExtension implements Extension |
|---|
| 15 |
{ |
|---|
| 16 |
|
|---|
| 17 |
* the namespace |
|---|
| 18 |
* |
|---|
| 19 |
* @var string |
|---|
| 20 |
*/ |
|---|
| 21 |
private $namespace = 'http://www.schst.net/XJConf/Math'; |
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
* Get the namespace URI used by the extension |
|---|
| 25 |
* |
|---|
| 26 |
* @return string |
|---|
| 27 |
*/ |
|---|
| 28 |
public function getNamespace() |
|---|
| 29 |
{ |
|---|
| 30 |
return $this->namespace; |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
* Process a start element |
|---|
| 35 |
* |
|---|
| 36 |
* @param XmlParser $parser |
|---|
| 37 |
* @param Tag $tag |
|---|
| 38 |
* @throws XJConfException |
|---|
| 39 |
*/ |
|---|
| 40 |
public function startElement(XmlParser $parser, Tag $tag) |
|---|
| 41 |
{ |
|---|
| 42 |
|
|---|
| 43 |
} |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
* Process the end element |
|---|
| 47 |
* |
|---|
| 48 |
* @param XmlParser $parser |
|---|
| 49 |
* @param Tag $tag |
|---|
| 50 |
* @throws XJConfException |
|---|
| 51 |
*/ |
|---|
| 52 |
public function endElement(XmlParser $parser, Tag $tag) |
|---|
| 53 |
{ |
|---|
| 54 |
|
|---|
| 55 |
if ($tag->getName() == 'add') { |
|---|
| 56 |
$result = 0; |
|---|
| 57 |
|
|---|
| 58 |
$children = $tag->getChildren(); |
|---|
| 59 |
foreach ($children as $child) { |
|---|
| 60 |
$result = $result + $child->getConvertedValue(); |
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
$resultTag = new GenericTag($tag->getName()); |
|---|
| 64 |
$resultTag->setValue((double)$result); |
|---|
| 65 |
return $resultTag; |
|---|
| 66 |
} |
|---|
| 67 |
|
|---|
| 68 |
return null; |
|---|
| 69 |
} |
|---|
| 70 |
} |
|---|
| 71 |
?> |
|---|