diff --git a/src/SchemaReader.php b/src/SchemaReader.php index c0520470..1de5e98b 100644 --- a/src/SchemaReader.php +++ b/src/SchemaReader.php @@ -264,6 +264,14 @@ private function loadElementRef(ElementDef $referenced, DOMElement $node) if ($node->hasAttribute("minOccurs")) { $ref->setMin((int)$node->getAttribute("minOccurs")); } + + $xp = new \DOMXPath($node->ownerDocument); + $xp->registerNamespace('xs', 'http://www.w3.org/2001/XMLSchema'); + + if ($xp->query('ancestor::xs:choice', $node)->length) { + $ref->setMin(0); + } + if ($node->hasAttribute("nillable")) { $ref->setNil($node->getAttribute("nillable") == "true"); }