|
|
@@ -109,8 +109,9 @@ class XML {
|
|
|
// TODO:TYPE_RECURCE:the same for restrictions
|
|
|
$type = $nodeArray[1]['type'];
|
|
|
DBG::log(['is_xs:' => ('xs:' === substr($type, 0, 3)), 'is_xsd:'=>('xsd:' === substr($type, 0, 4))], 'array', "DBG: findElementType field({$fieldName}) type({$type})");
|
|
|
- if ('xs:' === substr($type, 0, 3)) return "xsd:" . substr($type, 3);
|
|
|
- if ('xsd:' === substr($type, 0, 4)) return $type;
|
|
|
+ if ($fixedType = self::tryConvertXsdTypeToXsdPrefix($type)) {
|
|
|
+ return $fixedType;
|
|
|
+ }
|
|
|
list($prefix, $name) = explode(':', $type);
|
|
|
if ($prefix === self::findTargetNamespacePrefix($docArray)) {
|
|
|
$simpleTypeNode = self::findSimpleTypeNode($docArray, $name);
|
|
|
@@ -182,10 +183,26 @@ class XML {
|
|
|
return self::convertXsdTypeToXsdPrefix($nodeArray[2][0][2][0][1]['base']);
|
|
|
}
|
|
|
|
|
|
+ public static function tryConvertXsdTypeToXsdPrefix($type) {
|
|
|
+ try {
|
|
|
+ $type = self::convertXsdTypeToXsdPrefix($type);
|
|
|
+ return $type;
|
|
|
+ } catch (Exception $e) {
|
|
|
+ DBG::log($e);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
public static function convertXsdTypeToXsdPrefix($type) {
|
|
|
// TODO: validate if type is supported in object engine and gui
|
|
|
- if ('xs:' === substr($type, 0, 3)) return "xsd:" . substr($type, 3);
|
|
|
- if ('xsd:' === substr($type, 0, 4)) return $type;
|
|
|
+ // TODO: prefix p5
|
|
|
+ list($prefix, $name) = explode(':', $type);
|
|
|
+ $prefix = ('xs' === $prefix) ? 'xsd' : $prefix;
|
|
|
+ if ('xsd' === $prefix && 'int' === $name) return 'xsd:integer';
|
|
|
+ if ('xsd' === $prefix && 'NCName' === $name) return 'xsd:string'; // TODO: restriction?
|
|
|
+ if ('xsd' === $prefix && 'NMTOKEN' === $name) return 'xsd:string'; // TODO: restriction?
|
|
|
+ if ('xsd' === $prefix) return implode(":", [ $prefix, $name ]);
|
|
|
+ // if ('xs:' === substr($type, 0, 3)) return "xsd:" . substr($type, 3);
|
|
|
+ // if ('xsd:' === substr($type, 0, 4)) return $type;
|
|
|
throw new Exception("Not implemented type '{$type}'");
|
|
|
}
|
|
|
|