|
@@ -2,13 +2,13 @@
|
|
|
|
|
|
/*
|
|
/*
|
|
* Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
|
|
* Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
|
|
- *
|
|
|
|
|
|
+ *
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
* You may obtain a copy of the License at
|
|
- *
|
|
|
|
|
|
+ *
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
- *
|
|
|
|
|
|
+ *
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
@@ -40,6 +40,7 @@ class XmlSerializationVisitor extends AbstractVisitor
|
|
private $currentNode;
|
|
private $currentNode;
|
|
private $currentMetadata;
|
|
private $currentMetadata;
|
|
private $hasValue;
|
|
private $hasValue;
|
|
|
|
+ private $nullWasVisited;
|
|
|
|
|
|
public function setDefaultRootName($name)
|
|
public function setDefaultRootName($name)
|
|
{
|
|
{
|
|
@@ -85,11 +86,14 @@ class XmlSerializationVisitor extends AbstractVisitor
|
|
$node->value = 'true';
|
|
$node->value = 'true';
|
|
$this->currentNode->appendChild($node);
|
|
$this->currentNode->appendChild($node);
|
|
|
|
|
|
|
|
+ $this->attachNullNamespace();
|
|
|
|
+
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
$node = $this->document->createAttribute('xsi:nil');
|
|
$node = $this->document->createAttribute('xsi:nil');
|
|
$node->value = 'true';
|
|
$node->value = 'true';
|
|
|
|
+ $this->attachNullNamespace();
|
|
|
|
|
|
return $node;
|
|
return $node;
|
|
}
|
|
}
|
|
@@ -304,6 +308,13 @@ class XmlSerializationVisitor extends AbstractVisitor
|
|
return $doc;
|
|
return $doc;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function prepare($data)
|
|
|
|
+ {
|
|
|
|
+ $this->nullWasVisited = false;
|
|
|
|
+
|
|
|
|
+ return $data;
|
|
|
|
+ }
|
|
|
|
+
|
|
private function visitNumeric($data, array $type)
|
|
private function visitNumeric($data, array $type)
|
|
{
|
|
{
|
|
if (null === $this->document) {
|
|
if (null === $this->document) {
|
|
@@ -327,4 +338,16 @@ class XmlSerializationVisitor extends AbstractVisitor
|
|
{
|
|
{
|
|
return $name && false === strpos($name, ' ') && preg_match('#^[\pL_][\pL0-9._-]*$#ui', $name);
|
|
return $name && false === strpos($name, ' ') && preg_match('#^[\pL_][\pL0-9._-]*$#ui', $name);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private function attachNullNamespace()
|
|
|
|
+ {
|
|
|
|
+ if (!$this->nullWasVisited) {
|
|
|
|
+ $this->document->documentElement->setAttributeNS(
|
|
|
|
+ 'http://www.w3.org/2000/xmlns/',
|
|
|
|
+ 'xmlns:xsi',
|
|
|
|
+ 'http://www.w3.org/2001/XMLSchema-instance'
|
|
|
|
+ );
|
|
|
|
+ $this->nullWasVisited = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|