|
|
@@ -90,6 +90,16 @@ class XML {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static function findComplexTypeNode($docArray, $name) {
|
|
|
+ foreach ($docArray[2] as $child) {
|
|
|
+ if ('complexType' === self::getTagName($child[0])) {
|
|
|
+ if ($name === $child[1]['name']) {
|
|
|
+ return $child;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static function findTargetNamespacePrefix($docArray) {
|
|
|
$tns = self::findTargetNamespace($docArray);
|
|
|
if (!$tns) throw new Exception("targetNamespace not defined");
|
|
|
@@ -390,6 +400,34 @@ class XML {
|
|
|
}
|
|
|
public static function findFieldsFromExtension($docArray, $nodeArray) {
|
|
|
$fields = [];
|
|
|
+
|
|
|
+ if (empty($nodeArray[2])) { // empty extension tag - no childrens
|
|
|
+ // [0] => xs:extension
|
|
|
+ // [1] => Array:
|
|
|
+ // [base] => default_db__x3A__NEURO_MATRIX:Pain2
|
|
|
+ // [2] => Array: <-- empty!
|
|
|
+ if (empty($nodeArray[1]['base'])) throw new Exception("Error Parsing Schema - missing base attribute when empty extension");
|
|
|
+ list($prefix, $name) = explode(':', $nodeArray[1]['base']);
|
|
|
+ if ($prefix !== XML::findTargetNamespacePrefix($docArray)) throw new Exception("Error Parsing Schema - extension base not in local namespace");
|
|
|
+ $foundComplexTypeNode = XML::findComplexTypeNode($docArray, $name);
|
|
|
+ if (!$foundComplexTypeNode) throw new Exception("Error Parsing Schema - cannot find extension base in local namespace");
|
|
|
+ switch ($foundComplexTypeNode[2][0][0]) {
|
|
|
+ case 'xs:sequence':
|
|
|
+ case 'xsd:sequence': return XML::findFieldsFromSequence($docArray, $foundComplexTypeNode[2][0]); break;
|
|
|
+ case 'xs:complexContent':
|
|
|
+ case 'xsd:complexContent': return XML::findFieldsFromComplexContent($docArray, $foundComplexTypeNode[2][0]); break;
|
|
|
+ case 'xs:annotation':
|
|
|
+ case 'xsd:annotation': {
|
|
|
+ switch ($foundComplexTypeNode[2][1][0]) {
|
|
|
+ case 'xs:sequence':
|
|
|
+ case 'xsd:sequence': return XML::findFieldsFromSequence($docArray, $foundComplexTypeNode[2][1]); break;
|
|
|
+ case 'xs:complexContent':
|
|
|
+ case 'xsd:complexContent': return XML::findFieldsFromComplexContent($docArray, $foundComplexTypeNode[2][1]); break;
|
|
|
+ }
|
|
|
+ } break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
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) {
|
|
|
if (!self::isXsdTag($f[0], 'element')) {
|