|
@@ -117,7 +117,7 @@ class XML {
|
|
|
if (!empty($simpleTypeNode[1]['type'])) {
|
|
if (!empty($simpleTypeNode[1]['type'])) {
|
|
|
throw new Exception("TODO: findElementType node/@type => 'xsd:simpleType/@type' = '{$simpleTypeNode[1]['type']}'");
|
|
throw new Exception("TODO: findElementType node/@type => 'xsd:simpleType/@type' = '{$simpleTypeNode[1]['type']}'");
|
|
|
}
|
|
}
|
|
|
- if (!empty($simpleTypeNode[2][0]) && 'xsd:restriction' == $simpleTypeNode[2][0][0]) {
|
|
|
|
|
|
|
+ if (!empty($simpleTypeNode[2][0]) && self::isXsdTag($simpleTypeNode[2][0][0], 'restriction')) {
|
|
|
$restrictionNode = $simpleTypeNode[2][0];
|
|
$restrictionNode = $simpleTypeNode[2][0];
|
|
|
if (empty($restrictionNode[1]['base'])) throw new Exception("Missing xsd:restriction/@base (node/@type => xsd:simpleType/[@type='{$simpleTypeNode[1]['type']}']/xsd:restriction')");
|
|
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'];
|
|
$type = $restrictionNode[1]['base'];
|
|
@@ -141,7 +141,7 @@ class XML {
|
|
|
if (!empty($simpleTypeNode[1]['type'])) {
|
|
if (!empty($simpleTypeNode[1]['type'])) {
|
|
|
throw new Exception("TODO: findElementType node/@type => 'xsd:simpleType/@type' = '{$simpleTypeNode[1]['type']}'");
|
|
throw new Exception("TODO: findElementType node/@type => 'xsd:simpleType/@type' = '{$simpleTypeNode[1]['type']}'");
|
|
|
}
|
|
}
|
|
|
- if (!empty($simpleTypeNode[2][0]) && 'xsd:restriction' == $simpleTypeNode[2][0][0]) {
|
|
|
|
|
|
|
+ if (!empty($simpleTypeNode[2][0]) && self::isXsdTag($simpleTypeNode[2][0][0], 'restriction')) {
|
|
|
$restrictionNode = $simpleTypeNode[2][0];
|
|
$restrictionNode = $simpleTypeNode[2][0];
|
|
|
if (empty($restrictionNode[1]['base'])) throw new Exception("Missing xsd:restriction/@base (node/@type => xsd:simpleType/[@type='{$simpleTypeNode[1]['type']}']/xsd:restriction')");
|
|
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'];
|
|
$type = $restrictionNode[1]['base'];
|
|
@@ -176,8 +176,8 @@ class XML {
|
|
|
if (!empty($nodeArray[1]['ref'])) return 'ref:' . $nodeArray[1]['ref'];
|
|
if (!empty($nodeArray[1]['ref'])) return 'ref:' . $nodeArray[1]['ref'];
|
|
|
if (empty($nodeArray[2])) throw new Exception("Missing xsd:element childrens - cannot find type");
|
|
if (empty($nodeArray[2])) throw new Exception("Missing xsd:element childrens - cannot find type");
|
|
|
// TODO: find in loop (xsd:annotation may accure)
|
|
// TODO: find in loop (xsd:annotation may accure)
|
|
|
- if (empty($nodeArray[2][0][0]) || 'xsd:simpleType' != $nodeArray[2][0][0]) throw new Exception("Missing 'xsd:simpleType' for field '{$fieldName}'");
|
|
|
|
|
- if (empty($nodeArray[2][0][2][0]) || 'xsd:restriction' != $nodeArray[2][0][2][0][0]) throw new Exception("Missing 'xsd:restriction' for field '{$fieldName}'");
|
|
|
|
|
|
|
+ if (empty($nodeArray[2][0][0]) || !self::isXsdTag($nodeArray[2][0][0], 'simpleType')) throw new Exception("Missing 'xsd:simpleType' for field '{$fieldName}'");
|
|
|
|
|
+ if (empty($nodeArray[2][0][2][0]) || !self::isXsdTag($nodeArray[2][0][2][0][0], 'restriction')) throw new Exception("Missing 'xsd:restriction' for field '{$fieldName}'");
|
|
|
if (empty($nodeArray[2][0][2][0][1]['base'])) throw new Exception("Missing 'xsd:restriction/@base' for field '{$fieldName}'");
|
|
if (empty($nodeArray[2][0][2][0][1]['base'])) throw new Exception("Missing 'xsd:restriction/@base' for field '{$fieldName}'");
|
|
|
return $nodeArray[2][0][2][0][1]['base'];
|
|
return $nodeArray[2][0][2][0][1]['base'];
|
|
|
}
|
|
}
|
|
@@ -276,6 +276,15 @@ class XML {
|
|
|
: $xsdName;
|
|
: $xsdName;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static function isXsdTag($xsdName, $expectedTagName) {
|
|
|
|
|
+ list($xsdPrefix, $tagName) = explode(':', $xsdName);
|
|
|
|
|
+ switch ($xsdPrefix) {
|
|
|
|
|
+ case 'xs':
|
|
|
|
|
+ case 'xsd': return ($tagName === $expectedTagName);
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public static function readAppInfoRecurse($docArray, $nodeArray) {
|
|
public static function readAppInfoRecurse($docArray, $nodeArray) {
|
|
|
$appInfo = [];
|
|
$appInfo = [];
|
|
|
if (!empty($nodeArray[1])) foreach ($nodeArray[1] as $attrName => $attrVal) {
|
|
if (!empty($nodeArray[1])) foreach ($nodeArray[1] as $attrName => $attrVal) {
|
|
@@ -289,10 +298,10 @@ class XML {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static function findFieldsFromSequence($docArray, $nodeArray) {
|
|
public static function findFieldsFromSequence($docArray, $nodeArray) {
|
|
|
- if ($nodeArray[0] != 'xsd:sequence') throw new Exception("Error Parsing Schema - expected 'sequence'");
|
|
|
|
|
|
|
+ if (!self::isXsdTag($nodeArray[0], 'sequence')) throw new Exception("Error Parsing Schema - expected 'sequence'");
|
|
|
$fields = [];
|
|
$fields = [];
|
|
|
foreach ($nodeArray[2] as $f) {
|
|
foreach ($nodeArray[2] as $f) {
|
|
|
- if ($f[0] !== 'xsd:element') {
|
|
|
|
|
|
|
+ if (!self::isXsdTag($f[0], 'element')) {
|
|
|
DBG::log($n, 'array', "Schema xsd parse error - Not implemented node type '{$f[0]}'");
|
|
DBG::log($n, 'array', "Schema xsd parse error - Not implemented node type '{$f[0]}'");
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
@@ -327,9 +336,9 @@ class XML {
|
|
|
}
|
|
}
|
|
|
public static function findFieldsFromExtension($docArray, $nodeArray) {
|
|
public static function findFieldsFromExtension($docArray, $nodeArray) {
|
|
|
$fields = [];
|
|
$fields = [];
|
|
|
- if ($nodeArray[2][0][0] != 'xsd:sequence') throw new Exception("Error Parsing Schema - expected 'complexType/complexContent/extension/sequence'");
|
|
|
|
|
|
|
+ if (!self::isXsdTag($nodeArray[2][0][0], 'sequence')) throw new Exception("Error Parsing Schema - expected 'complexType/complexContent/extension/sequence'");
|
|
|
foreach ($nodeArray[2][0][2] as $f) {
|
|
foreach ($nodeArray[2][0][2] as $f) {
|
|
|
- if ($f[0] !== 'xsd:element') {
|
|
|
|
|
|
|
+ if (!self::isXsdTag($f[0], 'element')) {
|
|
|
DBG::log($n, 'array', "Schema xsd parse error - Not implemented node type '{$f[0]}'");
|
|
DBG::log($n, 'array', "Schema xsd parse error - Not implemented node type '{$f[0]}'");
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
@@ -352,9 +361,9 @@ class XML {
|
|
|
}
|
|
}
|
|
|
public static function findFieldsFromRestriction($docArray, $nodeArray) {
|
|
public static function findFieldsFromRestriction($docArray, $nodeArray) {
|
|
|
$fields = [];
|
|
$fields = [];
|
|
|
- if ($nodeArray[2][0][0] != 'xsd:sequence') throw new Exception("Error Parsing Schema - expected 'complexType/complexContent/restriction/sequence'");
|
|
|
|
|
|
|
+ if (!self::isXsdTag($nodeArray[2][0][0], 'sequence')) throw new Exception("Error Parsing Schema - expected 'complexType/complexContent/restriction/sequence'");
|
|
|
foreach ($nodeArray[2][0][2] as $f) {
|
|
foreach ($nodeArray[2][0][2] as $f) {
|
|
|
- if ($f[0] !== 'xsd:element') {
|
|
|
|
|
|
|
+ if (!self::isXsdTag($f[0], 'element')) {
|
|
|
DBG::log($n, 'array', "Schema xsd parse error - Not implemented node type '{$f[0]}'");
|
|
DBG::log($n, 'array', "Schema xsd parse error - Not implemented node type '{$f[0]}'");
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|