fix bad default entity attr name for XML attr of a simple sub-element by Map Automatically - Mendix Forum

fix bad default entity attr name for XML attr of a simple sub-element by Map Automatically

0

I'm talking about the "Map Automatically" button in export/import mappings for XML schemas.


An XML element with simple content and max-occurs = 1 is mapped to a primitive attr in the parent entity rather than to a separate entity. That's OK.


When such element has attrs the attrs are mapped to string attrs in the parent entity. That's also OK.


The problem is: when the parent element has 2 or more different sub-elements with simple content and their attrs have identical names, they're mapped to the same string attr in the parent entity and having the same name as the XML attr. This is error-prone.


A better default for the entity attr would be a concatenation of the sub-element name and the attr name.


A real-world example where both sub-elements have the Language attr:

	<xs:element name="ChapterInfo" type="ChapterInfo"/>

	<xs:complexType name="ChapterInfo">
		<xs:sequence>
			<xs:element name="ChapterTitle" type="ChapterTitle" minOccurs="0"/>
			<xs:element name="ChapterSubTitle" type="ChapterSubTitle" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="ChapterTitle">
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="Language" type="xs:string"/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>
	<xs:complexType name="ChapterSubTitle">
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="Language" type="xs:string"/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>


After clicking "Map Automatically" a domain model is generated where the entity ChapterInfo has the Language attr and it's mapped to both XML attrs.



Expected automatic mapping:

_


asked
0 answers