Skip to content

Commit

Permalink
when an element ref is inside a choice then is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Apr 27, 2019
1 parent 25a7855 commit 430b948
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 @@ -393,6 +393,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 430b948

Please sign in to comment.