Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request schmittjoh#1 from mattwells/xsd2php-ns-fix
Browse files Browse the repository at this point in the history
Removed unnecessary namespace duplication
  • Loading branch information
goetas committed Apr 4, 2015
2 parents 24598ef + 87c438b commit eed410e
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/JMS/Serializer/XmlSerializationVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,21 +443,20 @@ private function addNamespaceAttributes(ClassMetadata $metadata, \DOMElement $el

private function createElement($tagName, $namespace = null)
{
if (null !== $namespace) {

if ($this->currentNode->isDefaultNamespace($namespace)) {
return $this->document->createElementNS($namespace, $tagName);
} else {
if (!$prefix = $this->currentNode->lookupPrefix($namespace)) {
$prefix = 'ns-'. substr(sha1($namespace), 0, 8);
}
return $this->document->createElementNS($namespace, $prefix . ':' . $tagName);
}
if (null === $namespace) {
return $this->document->createElement($tagName);
}

if ($this->currentNode->isDefaultNamespace($namespace)) {
return $this->document->createElementNS($namespace, $tagName);
}

} else {
return $this->document->createElement($tagName);
if (!$prefix = $this->document->lookupPrefix($namespace)) {
$prefix = 'ns-'. substr(sha1($namespace), 0, 8);
return $this->document->createElementNS($namespace, $prefix . ':' . $tagName);
}

return $this->document->createElement($prefix . ':' . $tagName);
}

private function setAttributeOnNode(\DOMElement $node, $name, $value, $namespace = null)
Expand Down

0 comments on commit eed410e

Please sign in to comment.