Переглянути джерело

fixed parse XML restriction without childrens

Piotr Labudda 8 роки тому
батько
коміт
07c394449e
1 змінених файлів з 2 додано та 2 видалено
  1. 2 2
      SE/se-lib/XML.php

+ 2 - 2
SE/se-lib/XML.php

@@ -126,7 +126,7 @@ class XML {
 					DBG::log($type, 'array', "findElementType \$fieldName='{$fieldName}' type='{$nodeArray[1]['type']}' => type='{$type}'");
 					// check restrictions - if has enumeration then return 'p5:enum'
 					$isEnum = false;
-					foreach ($restrictionNode[2] as $restr) {
+					if (!empty($restrictionNode[2])) foreach ($restrictionNode[2] as $restr) {
 						if ('enumeration' === self::getTagName($restr[0])) {
 							$isEnum = true;
 							break;
@@ -261,7 +261,7 @@ class XML {
 		$restrictions = [];
 		if (empty($restrictionNode[1]['base'])) throw new Exception("Missing 'xsd:restriction/@base' for field '{$fieldName}'");
 		// xsd:simpleType/xsd:restriction/xsd:string
-		foreach ($restrictionNode[2] as $tagRestriction) {
+		if (!empty($restrictionNode[2])) foreach ($restrictionNode[2] as $tagRestriction) {
 			// xsd:string/xsd:maxLength
 			$val = $tagRestriction[1]['value'];
 			if ('enumeration' == XML::getTagName($tagRestriction[0])) {