From cc8819ac7b334a3965ea99c1ca144fe74a831f46 Mon Sep 17 00:00:00 2001 From: Anisimov Vasiliy Date: Thu, 29 Dec 2016 00:36:02 +0300 Subject: [PATCH] search ref in simple types (Daij-Djan/xsd2cocoa#14) --- framework/XSDschema.m | 5 +++-- framework/XSType.h | 1 + framework/objects/XSSimpleType.h | 3 ++- framework/objects/XSSimpleType.m | 12 +++++++++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/framework/XSDschema.m b/framework/XSDschema.m index 1a4072e..5c17063 100755 --- a/framework/XSDschema.m +++ b/framework/XSDschema.m @@ -150,6 +150,7 @@ - (id) initWithNode:(NSXMLElement*)node targetNamespacePrefix:(NSString*)prefix /* Add basic simple types known in the built-in types */ for(XSSimpleType *aSimpleType in [XSSimpleType knownSimpleTypesForSchema:self]) { [_knownSimpleTypeDict setValue: aSimpleType forKey: aSimpleType.name]; + [((NSMutableArray*)self.simpleTypes) addObject:aSimpleType]; } /* Add custom simple types */ @@ -184,9 +185,9 @@ - (id) initWithNode:(NSXMLElement*)node targetNamespacePrefix:(NSString*)prefix for (XSDelement* anElement in globalElements) { id aType = [anElement schemaType]; /* For the type check if it is in our found complex types */ - if( [aType isMemberOfClass: [XSDcomplexType class]]) { +// if( [aType isMemberOfClass: [XSDcomplexType class]]) { ((XSDcomplexType*)aType).globalElements = [((XSDcomplexType*)aType).globalElements arrayByAddingObject: anElement]; - } +// } } } diff --git a/framework/XSType.h b/framework/XSType.h index 337a63b..37ae7bd 100644 --- a/framework/XSType.h +++ b/framework/XSType.h @@ -16,6 +16,7 @@ - (NSString*) name; - (NSString*) baseType; - (NSArray*) attributes; +- (NSArray*) globalElements; //parsing diff --git a/framework/objects/XSSimpleType.h b/framework/objects/XSSimpleType.h index c4ba05e..7f0425f 100644 --- a/framework/objects/XSSimpleType.h +++ b/framework/objects/XSSimpleType.h @@ -24,6 +24,7 @@ @property (readonly, nonatomic) NSString* readPrefixCode; @property (readonly, nonatomic) NSArray* includes; @property (strong, nonatomic) NSArray* enumerations; +@property (readonly, nonatomic) NSArray* globalElements; - (BOOL)supplyTemplates:(NSXMLElement *)element enumTypeNode:(NSXMLNode*)enumTypeNode error:(NSError *__autoreleasing *)error; - (NSDictionary*) substitutionDict; @@ -46,4 +47,4 @@ @end -extern BOOL gUnitTestingSwiftCode; //swift 2 workaround \ No newline at end of file +extern BOOL gUnitTestingSwiftCode; //swift 2 workaround diff --git a/framework/objects/XSSimpleType.m b/framework/objects/XSSimpleType.m index 5847583..2d14bf2 100644 --- a/framework/objects/XSSimpleType.m +++ b/framework/objects/XSSimpleType.m @@ -33,12 +33,22 @@ @interface XSSimpleType () @property (strong, nonatomic) NSString* enumReadValueCode; @property (strong, nonatomic) NSString* enumReadPrefixCode; +@property (strong, nonatomic) NSArray* globalElements; + @end @implementation XSSimpleType { MGTemplateEngine *engine; } +- (instancetype)init { + self = [super init]; + if (self) { + _globalElements = [NSMutableArray array]; + } + return self; +} + - (id) initWithNode:(NSXMLElement*)node schema:(XSDschema*)schema { self = [super initWithNode:node schema:schema]; /* Continute to add items to the extended XSSchemaNode class */ @@ -381,4 +391,4 @@ + (NSArray *)knownSimpleTypesForSchema:(XSDschema*)schema { @end -BOOL gUnitTestingSwiftCode = NO; //swift 2 workaround \ No newline at end of file +BOOL gUnitTestingSwiftCode = NO; //swift 2 workaround