|
|
@@ -122,8 +122,7 @@ class XML {
|
|
|
if (empty($restrictionNode[1]['base'])) throw new Exception("Missing xsd:restriction/@base (node/@type => xsd:simpleType/[@type='{$simpleTypeNode[1]['type']}']/xsd:restriction')");
|
|
|
$type = $restrictionNode[1]['base'];
|
|
|
DBG::log($type, 'array', "findElementType \$fieldName='{$fieldName}' type='{$nodeArray[1]['type']}' => type='{$type}'");
|
|
|
- // TODO: in findElementRestrictions or findSimpleTypeRestrictions - save current restrictions in $restrictionNode[2]
|
|
|
- // TODO: check restrictions - if has enumeration then return 'p5:enum'
|
|
|
+ // check restrictions - if has enumeration then return 'p5:enum'
|
|
|
$isEnum = false;
|
|
|
foreach ($restrictionNode[2] as $restr) {
|
|
|
if ('enumeration' === self::getTagName($restr[0])) {
|
|
|
@@ -186,7 +185,6 @@ class XML {
|
|
|
public static function findElementRestrictions($docArray, $nodeArray) {
|
|
|
$restrictions = [];
|
|
|
$fieldName = self::findElementName($docArray, $nodeArray);
|
|
|
- // TODO:TYPE_RECURCE: if type has local prefix then find retriction recurse?
|
|
|
if (!empty($nodeArray[1]['nillable']) && 'true' === $nodeArray[1]['nillable']) $restrictions['nillable'] = true;
|
|
|
if (!empty($nodeArray[2])) {
|
|
|
foreach ($nodeArray[2] as $c) {
|
|
|
@@ -212,8 +210,33 @@ class XML {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (empty($nodeArray[2]) && !empty($nodeArray[1]['type'])) {
|
|
|
+ list($prefix, $name) = explode(':', $nodeArray[1]['type']);
|
|
|
+ if ($prefix === XML::findTargetNamespacePrefix($docArray)) {
|
|
|
+ $simpleTypeNode = self::findSimpleTypeNode($docArray, $name);
|
|
|
+ return XML::findSimpleTypeRestrictions($docArray, $simpleTypeNode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $restrictions;
|
|
|
+ }
|
|
|
+ public static function findSimpleTypeRestrictions($docArray, $nodeArray) { // $nodeArray must be 'simpleType' === XML::getTagName($nodeArray[0])
|
|
|
+ DBG::log($nodeArray, 'array', "TODO: findElementRestrictions \$nodeArray");
|
|
|
+ $restrictions = [];
|
|
|
+ if (empty($nodeArray[2][0]) || 'restriction' != XML::getTagName($nodeArray[2][0][0])) throw new Exception("Missing 'xsd:restriction' for field '{$fieldName}'");
|
|
|
+ if (empty($nodeArray[2][0][1]['base'])) throw new Exception("Missing 'xsd:restriction/@base' for field '{$fieldName}'");
|
|
|
+ // xsd:element/xsd:simpleType/xsd:restriction/xsd:string
|
|
|
+ foreach ($nodeArray[2][0][2] as $tagRestriction) {
|
|
|
+ // xsd:string/xsd:maxLength
|
|
|
+ $val = $tagRestriction[1]['value'];
|
|
|
+ if ('enumeration' == XML::getTagName($tagRestriction[0])) {
|
|
|
+ $restrictions['enumeration'][$val] = $val;
|
|
|
+ } else {
|
|
|
+ $restrictions[XML::getTagName($tagRestriction[0])] = $val;
|
|
|
+ }
|
|
|
+ }
|
|
|
return $restrictions;
|
|
|
}
|
|
|
+
|
|
|
public static function findElementAppInfo($docArray, $nodeArray) {
|
|
|
$appInfo = [];
|
|
|
$fieldName = self::findElementName($docArray, $nodeArray);
|