Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/dyeshurun/gedcomx-php into …
Browse files Browse the repository at this point in the history
…xml-namespace-bug
  • Loading branch information
justincy committed Sep 13, 2016
2 parents 53b5900 + 957f926 commit bad8a53
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/Common/EvidenceReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ protected function setKnownChildElement(\XMLReader $xml)
*/
protected function setKnownAttribute(\XMLReader $xml)
{
if (parent::setKnownAttribute(\XMLReader::$xml)) {
if (parent::setKnownAttribute($xml)) {
return true;
} else {
if (($xml->localName == 'resourceId') && (empty($xml->namespaceURI))) {
Expand Down
39 changes: 19 additions & 20 deletions src/Common/ExtensibleData.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ public function initFromReader(\XMLReader $xml)
else if (!$this->setKnownChildElement($xml)) {
$n = $xml->localName;
$ns = $xml->namespaceURI;
$elementIsEmpty = $xml->isEmptyElement;
$dom = new \DOMDocument();
$nodeFactory = $dom;
$dom->formatOutput = true;
Expand All @@ -273,34 +274,32 @@ public function initFromReader(\XMLReader $xml)
if ($xml->hasAttributes) {
$moreAttributes = $xml->moveToFirstAttribute();
while ($moreAttributes) {
$e->setAttributeNS($xml->namespaceURI, $xml->localName, $xml->value);
$e->setAttributeNS($ns, $xml->localName, $xml->value);
$moreAttributes = $xml->moveToNextAttribute();
}
}
$dom = $e;

//create any child elements...
while ($xml->read() && $xml->nodeType != \XMLReader::END_ELEMENT && $xml->localName != $n && $xml->namespaceURI != $ns) {
if ($xml->nodeType == \XMLReader::ELEMENT) {
$e = $nodeFactory->createElementNS($xml->namespaceURI, $xml->localName);
$dom->appendChild($e);
if ($xml->hasAttributes) {
$moreAttributes = $xml->moveToFirstAttribute();
while ($moreAttributes) {
$e->setAttributeNS($xml->namespaceURI, $xml->localName, $xml->value);
$moreAttributes = $xml->moveToNextAttribute();
if (!$elementIsEmpty) {
//create any child elements...
while ($xml->read() && $xml->nodeType != \XMLReader::END_ELEMENT && $xml->localName != $n) {
if ($xml->nodeType == \XMLReader::ELEMENT) {
$e = $nodeFactory->createElementNS($xml->namespaceURI, $xml->localName);
$dom->appendChild($e);
if ($xml->hasAttributes) {
$moreAttributes = $xml->moveToFirstAttribute();
while ($moreAttributes) {
$e->setAttributeNS($xml->namespaceURI, $xml->localName, $xml->value);
$moreAttributes = $xml->moveToNextAttribute();
}
}
} else if ($xml->nodeType == \XMLReader::TEXT) {
$dom->textContent = $xml->value;
} else if ($xml->nodeType == \XMLReader::END_ELEMENT) {
$dom = $dom->parentNode;
}
$dom = $e;
}
else if ($xml->nodeType == \XMLReader::TEXT) {
$dom->textContent = $xml->value;
}
else if ($xml->nodeType == \XMLReader::END_ELEMENT) {
$dom = $dom->parentNode;
}
}
array_push($this->extensionElements, $nodeFactory);
array_push($this->extensionElements, $dom);
}
$xml->read(); //advance the reader.
}
Expand Down

0 comments on commit bad8a53

Please sign in to comment.