Usually, you would do this using XInclude. I am not sure about the underlying code doing the XML parsing and handling. If it uses lxml, then there is a chance that XInclude could be supported...you need to try that out.
I would put all fields (if that is what you mean) in a behaviour, and then enable it on all content types you want to use.
That said: It is also possible to import an xml in your content types py file.
If you make a content type with plone-cli there will be a comment about how to do that
@zopyx: The XML file is loaded by Products.GenericSetup and it uses xml.dom.minidom.parseString.
It seems that parseString ignores the functionality of <xi:include ...>.
@espenmn: I've searched for the comment you mentioned. But cannot find any. Could you please give me another clue how to import an xml file in my content types py file? Or maybe a link to an example?
@espenmn: As far as I understand it, your proposal is intended for loading the model (fields, widgets etc.). This of course could be done with a behaviour.
Nonetheles this is not what I am searching for. I'm searchig for a way to define the fti properties and include or import them. I'll describe the issue in detail:
Having content_types TypeA, TypeB, TypeC ... which share e.g. the properties filter_content_types and allowed_content_types the "normal" way is to define those properties in every XML-file. So the following
xml-code would be duplicated in TypeA.xml, TypeB.xml, TypeC.xml etc. and wenn we need to change it, we must change it in every fille TypeA.xml, TypeB.xml, TypeC.xml etc.
@zopyx pointed to the possibility of xi:include the properties. This is not working due to the way GenericSetup loads the xml-file (minidom). This would - if it had worked - look like the following.
# code in TypeA.xml, TypeB.xml, TypeC.xml etc.
<object meta_type="Dexterity FTI" ... >
...
<xi:include href="shared_properties.xml" />
...
</object>
# code in "shared_properties.xml"
<property name="filter_content_types">True</property>
<property name="allowed_content_types">
<element value="SomeType"/>
</property>
Are maybe there some ways to define the FTI other than the xml-file? Is the FTI accessible from some part in the addon? Can this maybe be done via Behavior?