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