Skip to content

Commit

Permalink
Merge pull request #49 from goetas-webservices/ref-optional
Browse files Browse the repository at this point in the history
When an element ref is inside a choice, then is optional
  • Loading branch information
goetas authored Apr 27, 2019
2 parents 6783dc5 + 430b948 commit 0b3ddc4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/SchemaReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,14 @@ private function loadSequenceChildNodeLoadElement(

self::maybeSetMax($element, $childNode);
self::maybeSetMin($element, $childNode);

$xp = new \DOMXPath($node->ownerDocument);
$xp->registerNamespace('xs', 'http://www.w3.org/2001/XMLSchema');

if ($xp->query('ancestor::xs:choice', $childNode)->length) {
$element->setMin(0);
}

if ($childNode->hasAttribute('nillable')) {
$element->setNil($childNode->getAttribute('nillable') == 'true');
}
Expand Down

0 comments on commit 0b3ddc4

Please sign in to comment.