-
-
Notifications
You must be signed in to change notification settings - Fork 588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use namespace from bottom of object stack #718
Conversation
@@ -454,7 +454,7 @@ private function addNamespaceAttributes(ClassMetadata $metadata, \DOMElement $el | |||
|
|||
private function createElement($tagName, $namespace = null) | |||
{ | |||
if (null === $namespace) { | |||
if (null === $namespace || $this->document->isDefaultNamespace($namespace)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not always true.
elements should be created in their namespace, if they belong to one. then the dom parser will take care of converting it into the correct xml reppresentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what you are trying to solve, i tried it with #644
@@ -295,7 +295,7 @@ public function visitProperty(PropertyMetadata $metadata, $object, Context $cont | |||
if (null !== $metadata->xmlNamespace) { | |||
$element = $this->createElement($elementName, $metadata->xmlNamespace); | |||
} else { | |||
$defaultNamespace = $this->getClassDefaultNamespace($this->objectMetadataStack->top()); | |||
$defaultNamespace = $this->getClassDefaultNamespace($this->objectMetadataStack->bottom()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your tests are not covering this line, running
vendor/bin/phpunit --filter=testObjectWithNamespacesAndListInList
this line is never executed
can you also rebase your PR ? |
I went a bit deeper in the analysis. Just add
|
I encountered problems with unserializing xml lists in xml lists with a default namespace from the root element.
The cause is, that you use the top element of the stack (newest one) not the bottom element (root).
I also added a test which fails with the previous implementation.