xsd2php icon indicating copy to clipboard operation
xsd2php copied to clipboard

anyType + anySimpleType issue

Open Adraesh opened this issue 6 years ago • 13 comments

Hi!

First of all, thank you very much for this lib!

I am trying to make it work without success bellow my issue:

In SchemaReader.php line 1056:
                                                                                                             
  Can't find type named {http://www.opengis.net/gml/3.2}#anyType, at line 21 in http://schemas.opengis.net/  
  gml/3.2.1/gmlBase.xsd                                                                                      
                                                                                                             

In Schema.php line 100:
                                                                       
  Can't find the Type named {http://www.opengis.net/gml/3.2}#anyType. 

Though anyType and anySimpleType are well set to their alias as following:

aliases: 
        'http://www.opengis.net/gml/3.2':
            anyType: 'Jms\Handler\GmlAnyTypeHandler'
            anySimpleType: 'Jms\Handler\GmlAnySimpleTypeHandler'

The related handler's classes are registered as service and tag to jms_serializer.subscribing_handler as following:

App\Jms\Handler\GmlAnyTypeHandler:
       public: true
       tags:
           - { name: jms_serializer.subscribing_handler }

    App\Jms\Handler\GmlAnySimpleTypeHandler:
       public: true
       tags:
           - { name: jms_serializer.subscribing_handler }

Any idea? Thank you in advance.

Adraesh avatar Jan 13 '20 11:01 Adraesh

as in this example https://github.com/goetas-webservices/xsd2php#dealing-with-xsdanytype-or-xsdanysimpletype, anytype is in te http://www.w3.org/2001/XMLSchema namespace.

goetas avatar Jan 14 '20 06:01 goetas

@goetas Same issue using this configuration:

xsd2php:
    namespaces:
        'http://www.aixm.aero/schema/5.1.1': 'App\AIXM'
        'http://www.opengis.net/gml/3.2': 'App\AIXM'
        'http://www.w3.org/1999/xlink': 'App\AIXM'
        'http://www.isotc211.org/2005/gmd': 'App\AIXM'
        'http://www.isotc211.org/2005/gmx': 'App\AIXM'
        'http://www.isotc211.org/2005/gsr': 'App\AIXM'
        'http://www.isotc211.org/2005/gss': 'App\AIXM'
        'http://www.isotc211.org/2005/gts': 'App\AIXM'

    destinations_php: 
        'App\AIXM': src/AIXM

    destinations_jms:
        'App\AIXM': src/AIXM

    aliases: 
        'http://www.w3.org/2001/XMLSchema':
            anyType: 'Jms\Handler\GmlAnyTypeHandler'
            anySimpleType: 'Jms\Handler\GmlAnySimpleTypeHandler'
    naming_strategy: short
    path_generator: psr4

Adraesh avatar Jan 14 '20 07:01 Adraesh

Basically I am trying to use your lib in order to create the mapped related PHP classes from this XSD schema: http://www.aixm.aero/sites/aixm.aero/files/imce/AIXM511/aixm_5_1_1_xsd_with_local_copies.zip

If you can check it out, I am on it since 2 days without success :)

Thank you in advance.

Adraesh avatar Jan 14 '20 08:01 Adraesh

@goetas Hi! Any news on this topic and/or guideline?

Thank you.

Adraesh avatar Jan 15 '20 09:01 Adraesh

Hi!

I think I got it, basically the lib seems to not cover the case of having anyType or anySimpleType linked to any other namespace than 'http://www.w3.org/2001/XMLSchema' and in my case I have elements of type anyType and anySimpleType linked to the 'http://www.opengis.net/gml/3.2' namespace.

iex:

<element name="AbstractValue" type="anyType" abstract="true" substitutionGroup="gml:AbstractObject">
		<annotation>
			<documentation>gml:AbstractValue is an abstract element which acts as the head of a substitution group which contains gml:AbstractScalarValue, gml:AbstractScalarValueList, gml:CompositeValue and gml:ValueExtent, and (transitively) the elements in their substitution groups.
These elements may be used in an application schema as variables, so that in an XML instance document any member of its substitution group may occur.</documentation>
		</annotation>

Any feedback on this?

Adraesh avatar Jan 15 '20 10:01 Adraesh

Hmm... it could be that the namespaced anyType is not supported yet... :-/

goetas avatar Jan 15 '20 10:01 goetas

@goetas Any tips, starting point in order to implement it?

Adraesh avatar Jan 15 '20 12:01 Adraesh

The any element is probably not supported by the xsd reader. You should add support for it in https://github.com/goetas-webservices/xsd-reader/blob/master/src/SchemaReader.php, after you will be able to assign to it a handler in this library

goetas avatar Jan 17 '20 21:01 goetas

@goetas I took time yesterday to dig more into your lib. I found the reason about anyType basically whenever an element is not declaring a Type is therefore implicitly (according to the rules of W3C XML Schema) an XML Schema anyType. But your lib still try to resolve it using the targetNamespace from the file the element is in my case targetNamespace="http://www.opengis.net/gml/3.2" and not from the http://www.w3.org/2001/XMLSchema namespace. I fix this by simply adding explicitly the type to this element type="anyType". Still could you please handle this case properly?

Then, it seems that the lib does not handle the notion of deprecated types, I have a deprecatedTypes.xsd which declare all the element/types and other that are still part of the schema but deprecated, the lib still try to find the type in the related namespace without checking if it's a deprecated type. Could you also please handle this issue?

Adraesh avatar Jan 18 '20 08:01 Adraesh

i'm happy to see that you solved your issue.

whenever an element is not declaring a Type is therefore implicitly (according to the rules of W3C XML Schema) an XML Schema anyType.

did not know that, thanks for looking into it

Still could you please handle this case properly?

would be happy to accept a PR

Then, it seems that the lib does not handle the notion of deprecated types, I have a deprecatedTypes.xsd which declare all the element/types and other that are still part of the schema but deprecated, the lib still try to find the type in the related namespace without checking if it's a deprecated type. Could you also please handle this issue?

this seems a complete new feature, would be happy to accept a PR

goetas avatar Jan 24 '20 05:01 goetas

@goetas So if I understand clearly you are not maintaining anymore this lib.

Adraesh avatar Jan 24 '20 11:01 Adraesh

This is an open source project licensed under the MIT license (see https://github.com/goetas-webservices/xsd2php/blob/master/LICENSE.txt), with all pros and cons of it. The project is maintained for my needs and its progress depends on my available time to work on it.

Currently I do not have a specific need for the feature you are asking, and nobody is paying me (yet) to implement it. All the projects that I'm working on do not have this usecase. I'm willing to accept a PR with the changes you need. In some cases, the development has been sponsored by companies (see https://github.com/goetas-webservices/xsd2php/issues/71#issuecomment-527842541).

goetas avatar Jan 24 '20 13:01 goetas

@Adraesh how did you fix your problem? Where did you add element type="anyType"? Would you mind sharing it? Perhaps we could join forces to come up with a PR to improve this library?

mussbach avatar Feb 07 '20 15:02 mussbach