The trick you need is using a named complex type definition, and/or a named
group definition.
E.g.,
<xs:element name="AP_Input" type="registerType"/>
<xs:complexType name="registerType">
<xs:sequence>
<xs:element name="App_Slot" type="xs:unsignedByte"/>
<xs:element name="App_Array" type="xs:unsignedByte"/>
<xs:element name="App_Index" type="xs:unsignedShort"/>
</xs:sequence>
</xs:complexType>
If you want to reuse groups of fields within various types, you can use named
groups for that. E.g.,
<xs:group name="registerGroup">
<xs:sequence>
<xs:element name="App_Slot" type="xs:unsignedByte"/>
<xs:element name="App_Array" type="xs:unsignedByte"/>
<xs:element name="App_Index" type="xs:unsignedShort"/>
</xs:sequence>
</xs:group>
Then you use this with a group reference from within as many named complex
types as you want.
<xs:complexType name="registerType">
<xs:group ref="registerGroup"/>
</xs:complexType>
<xs:complexType name="someOtherType">
<xs:sequence>
<xs:group ref="registerGroup" />
... reference other reusable groups of fields here too, or define
directly here.
</xs:sequence>
</xs:complexType>
In general anywhere you can put a xs:sequence or xs:element you can put a
xs:group reference.
So I think one can avoid the troublesome repetition of definitions you were
trying to avoid.
-Mike Beckerle
Tresys
________________________________
From: [email protected] <[email protected]>
Sent: Thursday, July 12, 2018 9:48:01 AM
To: [email protected]
Subject: Is there a way to reuse a structure but with a different name?
It seems DFDL is very verbose. I have to copy and paste a lot of lines to reuse
a structure definition.
Or am I missing a trick? I can do this with simple types.
<!-- Register instance - Current usage --->
<xs:element name="AP_Input" >
<xs:complexType>
<xs:sequence>
<xs:element ref="register" >
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- WISH: Register instance - compact form-->
<xs:element name="AP_Input" type="register" >
<!-- register structure definition -->
<xs:element name="register" >
<xs:complexType>
<xs:sequence>
<xs:element name="App_Slot" type="xs:unsignedByte"/>
<xs:element name="App_Array" type="xs:unsignedByte"/>
<xs:element name="App_Index" type="xs:unsignedShort"/>
</xs:sequence>
</xs:complexType>
</xs:element>
****************** Expected output:
<AP_Input>
<register>
<App_Slot>0</App_Slot>
<App_Array>0</App_Array>
<App_Index>0</App_Index>
</register>
</AP_Input>