Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
1 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Document Title Model Persistence Rules for XML
Document Owner AUTOSAR
Document Responsibility AUTOSAR
Document Identification No 122
Document Classification Standard
Document Version 2.7.0
Document Status Final
Part of Release 4.1
Revision 3
Document Change History Date Version Changed by Change Description
31.03.2014 2.7.0 AUTOSAR Release Management
Minor corrections concerning XML namespace
31.10.2013 2.6.0 AUTOSAR Release Management
Added tabular overview of default configuration of schema generator (Table 4-2)
22.01.2013 2.5.0 AUTOSAR Administration
Removed references to “Template UML Profile and Modeling Guide”
Changed chapter 4.2.4.1
02.11.2011 2.4.0 AUTOSAR Administration
Formal adaptations concernign traceability
Harmonized naming proposal for arxml files with AUTOSAR_TR_InteroperabilityOfAutosarTools
Updated XML Persistence mechanism regarding primitive types with attributes
22.10.2010 2.3.0 AUTOSAR Administration
Added description of tag default configuration for association without stereotpe (chapter 4.2.3.1)
Enhanced description of tag 'xml.xsd.customType'
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
2 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Document Change History Date Version Changed by Change Description
07.12.2009 2.2.0 AUTOSAR Administration
Modeling and handling of primitive types has been revised
Inheritance information is visible in schema now for all superclasses, also for empty abstract classes
Variant Handling is handled in Generic Structure Template
Legal disclaimer revised
23.06.2008 2.1.3 AUTOSAR Administration
Legal disclaimer revised
31.10.2007 2.1.2 AUTOSAR Administration
Document meta information extended
Small layout adaptations made
24.01.2007 2.1.1 AUTOSAR Administration
“Advice for users” revised
“Revision Information” added
05.12.2006 2.1.0 AUTOSAR Administration
Updated instanceRef references
Only absolute paths allowed
Naming of instanceRef
Destination type of references
Version info in namespace
Legal disclaimer revised
17.05.2006 2.0.0 AUTOSAR Administration
Initial Release
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
3 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Disclaimer This specification and the material contained in it, as released by AUTOSAR is for the purpose of information only. AUTOSAR and the companies that have contributed to it shall not be liable for any use of the specification. The material contained in this specification is protected by copyright and other types of Intellectual Property Rights. The commercial exploitation of the material contained in this specification requires a license to such Intellectual Property Rights. This specification may be utilized or reproduced without any modification, in any form or by any means, for informational purposes only. For any other purpose, no part of the specification may be utilized or reproduced, in any form or by any means, without permission in writing from the publisher. The AUTOSAR specifications have been developed for automotive applications only. They have neither been developed, nor tested for non-automotive applications. The word AUTOSAR and the AUTOSAR logo are registered trademarks. Advice for users AUTOSAR Specification Documents may contain exemplary items (exemplary reference models, "use cases", and/or references to exemplary technical solutions, devices, processes or software). Any such exemplary items are contained in the Specification Documents for illustration purposes only, and they themselves are not part of the AUTOSAR Standard. Neither their presence in such Specification Documents, nor any later documentation of AUTOSAR conformance of products actually implementing such exemplary items, imply that intellectual property rights covering such exemplary items are licensed under the same rules as applicable to the AUTOSAR Standard.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
4 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Table of Contents
1 Introduction .......................................................................................................... 7
2 Requirements tracing .......................................................................................... 9
3 XML Schema design principles [Tc0003] .......................................................... 10
3.1 Notes on UML2.0 semantics of the AUTOSAR meta-model ...................... 10 3.1.1 Representation of association (aggregation = composite) [Tc0003Sc1] 10 3.1.2 Representation of attribute (aggregation = composite) [Tc0003Sc2] .. 11
3.1.3 Representation of associations (aggregation = none) [Tc0003Sc3] .... 11 3.1.4 Representation of attributes (aggregation = none) [Tc0003Sc4] ......... 12
3.2 Notes on use of W3C XML schema ........................................................... 13 3.3 Handling inheritance ................................................................................... 14
3.4 Generic approach ....................................................................................... 14 3.5 XML element versus attribute ..................................................................... 14 3.6 XML names [Tc0001] ................................................................................. 14 3.7 Order of XML-elements [Tc0002] ............................................................... 16
3.7.1 Order of xml elements ......................................................................... 16 3.7.2 Order of xml elements of derived uml:properties................................. 16
3.8 Linking [Tc0004] ......................................................................................... 18 3.9 Transmitting incomplete Data ..................................................................... 18
3.10 Identification of XML schema version in XML descriptions ......................... 19
4 Configuration of XML schema production [Tc0005] ........................................... 20
4.1 Tailoring schema production ...................................................................... 20 4.1.1 Overview ............................................................................................. 20 4.1.2 Constraints on tags ............................................................................. 23
4.2 Default configuration of XML schema production [Tc0006] ........................ 26 4.2.1 Configuration of multiplicities............................................................... 27
4.2.2 Mapping configuration for properties ................................................... 27 4.2.3 Mapping configuration for references .................................................. 30
4.2.4 Stereotypes applied to classes [Tc0011] ............................................. 33
5 XML Schema production rules .......................................................................... 35
5.1 Create model representation [Tc0007] ....................................................... 35
5.1.1 [TR_APRXML_00000] ⌈Create xsd:schema⌋() ................................... 36
5.2 Create class representation [Tc0008] ......................................................... 37
5.2.1 [TR_APRXML_00001] ⌈Create xsd:group ⌋() [Tc0008Sc3] ................. 38
5.2.2 [TR_APRXML_00002] ⌈[Create xsd:attributeGroup⌋() [Tc0008Sc4] ... 39
5.2.3 [TR_APRXML_00003] ⌈Create xsd:complexType⌋() [Tc0008Sc1]...... 40
5.2.4 [TR_APRXML_00024] ⌈Create xsd:complexType with simple content⌋()
42
5.2.5 [TR_APRXML_00005] ⌈Create global xsd:element⌋() [Tc0008Sc2] .... 43
5.2.6 [TR_APRXML_00025] ⌈Create enumeration of subtypes⌋() ............... 44
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
5 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
5.2.7 [TR_APRXML_00006] ⌈Create reference to XML predefined data
type⌋() [Tc0005Sc8] [Tc0008Sc6] ..................................................................... 44
5.2.8 [TR_APRXML_00026] ⌈Create a custom simple type⌋() ..................... 45
5.2.9 [TR_APRXML_00007] ⌈Create xsd:simpleType for enumeration⌋()
[Tc0008Sc5] ...................................................................................................... 46 5.3 Create composite property representation (mapping to XML attributes) [Tc0009] ................................................................................................................ 47
5.3.1 [TR_APRXML_00019] ⌈Create xsd:attribute⌋() ................................... 47
5.4 Create composite property representation (mapping to XML elements) [Tc0010] ................................................................................................................ 47
5.4.1 [TR_APRXML_00008] ⌈Create composite property representation⌋()
(1111) [Tc0010Sc1111] ..................................................................................... 49
5.4.2 [TR_APRXML_00009] ⌈Create composite property representation⌋()
(1101) [Tc0010Sc1101] ..................................................................................... 52
5.4.3 [TR_APRXML_00023] ⌈Create composite property representation⌋()
(1100) [Tc0010Sc1100] ..................................................................................... 53
5.4.4 [TR_APRXML_00022] ⌈Create composite property representation⌋()
(1011) [Tc0010Sc1011] .................................................................................... 55
5.4.5 [TR_APRXML_00010] ⌈Create composite property representation⌋()
(1001) [Tc0010Sc1001] ..................................................................................... 57
5.4.6 [TR_APRXML_00011] ⌈Create composite property representation⌋()
(0111) [Tc0010Sc0111] ..................................................................................... 59
5.4.7 [TR_APRXML_00012] ⌈Create composite property representation⌋()
(0101) [Tc0010Sc0101] ..................................................................................... 60
5.4.8 [TR_APRXML_00013] ⌈Create composite property representation⌋()
(0100) [Tc0010Sc0100] ..................................................................................... 62
5.4.9 [TR_APRXML_00014] ⌈Create composite property representation⌋()
(0011) [Tc0010Sc0011] ..................................................................................... 63
5.4.10 [TR_APRXML_00015] ⌈Create composite property representation⌋()
(0001) [Tc0010Sc0001] ..................................................................................... 64
5.4.11 [TR_APRXML_00016] ⌈Create composite property representation⌋()
(0000) [Tc0010Sc0000] ..................................................................................... 65 5.5 Create reference representation [Tc0012] .................................................. 66
5.5.1 [TR_APRXML_00017] ⌈Create reference property representation (1)
⌋()[Tc0012Sc1] .................................................................................................. 67
5.5.2 [TR_APRXML_00018] ⌈Create reference property representation (0)
⌋()[Tc0012Sc2] .................................................................................................. 68
5.5.3 [TR_APRXML_00027] ⌈Create a reference to attributes in foreign
namespaces⌋() .................................................................................................. 69
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
6 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
6 XML description production ............................................................................... 71
6.1 Introduction ................................................................................................ 71 6.2 Overall document structure ........................................................................ 71 6.3 Linking ........................................................................................................ 72
7 Compliance ....................................................................................................... 73
7.1 AUTOSAR XML schema compliance ......................................................... 73
7.2 AUTOSAR XML document compliance ...................................................... 73
8 References ........................................................................................................ 74
8.1 Normative references to AUTOSAR documents ........................................ 74
8.2 Normative references to external documents ............................................. 74 8.3 Other references ........................................................................................ 75
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
7 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
1 Introduction
The AUTOSAR meta-model describes all information entities which can be used to describe an AUTOSAR system. XML is chosen as a basis for the exchange of formal descriptions of AUTOSAR systems. This document describes how a W3C XML schema specification[8] compliant XML schema can be compiled out of the AUTOSAR meta-model [3]. Using the persistence rules a new XML schema can be generated automatically whenever the meta-model is updated. The model persistence rules defined in this document exceed the configuration possibilities of comparable approaches like XMI [5][6] and enables the generic reproduction of a wide range of existing XML schemas out of well-structured UML models. The numbers in brackets you can find in this specification identify specification items. Figure 1-1 describes the model persistence rules for XML in the overall context. The meta-levels of the AUTOSAR modeling approach are described on the left side of the image:
The syntax and semantics of the language UML2.0 is described on the meta-meta-level (M3). The AUTOSAR template profile [3] defines, which parts of UML2.0 are allowed to be used in the AUTOSAR meta-model.
The AUTOSAR meta-model[3] is a UML2.0[14] model that defines the language for describing AUTOSAR systems. The AUTOSAR meta-model is a graphical representation of a template. UML2.0 class diagrams are used to describe the attributes and their interrelationships. Stereotypes and OCL[16] (object constraint language) are used for defining specific semantics and constraints.
An AUTOSAR model is an instance of the AUTOSAR meta-model. The information contained in the AUTOSAR model can be anything that is representable according to the AUTOSAR meta-model.
The meta-levels of the XML language are described on the right side of Figure 1-1:
The W3C XML schema specification [8] defines how a W3C XML schema can be defined.
The AUTOSAR XML schema is a W3C XML schema that defines the language for exchanging AUTOSAR models. This XML schema is derived from the AUTOSAR meta-model by means of the rules defined in this document. The AUTOSAR XML schema defines the AUTOSAR data exchange format.
An AUTOSAR XML description describes the XML representation of an AUTOSAR model. The AUTOSAR XML description can consist of several fragments (e.g. files). Each individual fragment must validate successfully against the AUTOSAR XML schema.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
8 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
This document describes how the AUTOSAR meta-model is mapped to the AUTOSAR XML schema by means of the model persistence rules for XML.
Figure 1-1: Context of Model Persistence Rules for XML
This document is structured as follows:
Chapter 1 (this chapter) describes the model persistence rules for XML in the overall context of the AUTOSAR meta-model and the XML language.
Chapter 2 traces the requirements on the model persistence rules for XML to specification items and chapter in this document.
Chapter 3 describes the XML schema design principles. Some notes on the UML2.0 semantics of associations, attributes, references and properties are given first, followed by a discussion on the basic principles including aspects such as names of XML elements, transmitting incomplete data, linking, etc.
Chapter 4 describes how the model persistence rules for XML can be parameterized by means of tagged values. Additionally a default configuration for mapping the AUTOSAR meta-model to the AUTOSAR XML schema is given.
Chapter 5 describes the model persistence rules in more detail. The relationship between the rules is illustrated graphically.
Note: This document contains examples for illustration of the model persistence rules for XML. Some examples are taken out of the AUTOSAR meta-model and simplified for better readability. Therefore these examples might not be in sync with the latest version of the AUTOSAR meta-model.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
9 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
2 Requirements tracing
The following table lists the requirements on the AUTOSAR XML schema and the AUTOSAR meta-model which are relevant for the AUTOSAR data exchange format as defined in [2]. The column “Satisfied by” depicts where a given requirement is covered in this document.
Requirement Satisfied by [ATI0019] AUTOSAR XML schema SHALL support description of incomplete models and model fragments
3.9 and 4, 5
[ATI0020] AUTOSAR XML schema SHALL be based on proven XML design concepts
3, 4
[ATI0021] AUTOSAR SHOULD provide for upward compatibility detection
Not yet covered, planned for AUTOSAR phase 2
[ATI0023] AUTOSAR XML schema SHALL allow for flexible distribution of XML descriptions over several XML files and referencing between them
3.8, 5.5
[ATI0025] AUTOSAR XML schema SHALL be consistent with the AUTOSAR meta-model
3.2, 4.2
[ATI0027] AUTOSAR XML schema MAY use XML namespace 3, 4, 5
[ATI0028] AUTOSAR XML schema SHALL support strict XML validation
4, 5
[ATI0029] AUTOSAR XML schema SHALL contain the version information of the meta-model it was generated from
3.10
[ATI0030] AUTOSAR XML schema SHALL ensure upwards compatibility of existing XML descriptions in case on minor changes in the meta-model
4.2
[ATI0031] AUTOSAR XML schema SHOULD provide extension mechanism
Not yet covered.
[ATI0032] AUTOSAR XML schema SHALL support unambiguous mapping to meta-model instances
3.2, 4, 5
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
10 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
3 XML Schema design principles [Tc0003]
This chapter first describes some notes on XML schema and on UML2.0 semantics of the AUTOSAR meta-model and then gives a brief description on some basic principles, which include a short description of XML names, order of XML elements and linking.
3.1 Notes on UML2.0 semantics of the AUTOSAR meta-model
In UML2.0 [14] attributes and navigable association ends are represented as properties. Since the AUTOSAR Template Profile only supports associations with two association ends, attributes and associations can be considered as equivalent for the persistence rules for XML. Therefore the persistence rules for XML can concentrate on classes and properties. The following four sections give more information on the UML2.0 semantics of these concepts. Each chapter contains a diagram which shows the concept in the UML graphical notation (upper half of the diagram) and how it is represented as an instance of the UML2.0 meta-model (lower part of the diagram). Please note that in UML2.0 compositions and references are both described by means of associations. The only difference is the value of the attribute “aggregation” of the association ends. For a more detailed description of the UML2.0 semantics please refer to the UML2.0 superstructure specification [14]. In the following sections the value of the attribute “aggregation” of the navigable association end is shown in brackets behind the association.
3.1.1 Representation of association (aggregation = composite) [Tc0003Sc1]
Figure 3-1 depicts how a composite association is represented by means of instances of the UML2.0 meta-model. The association end ‘theC’ is navigable from class A and is represented as a property that is owned by class ‘A’. The association end that is not navigable is owned by the association. The information represented by the anonymous association and the not navigable property is not relevant for the model persistence rules: From the point of view of persistence rules there is not difference between composite association and an attribute (see also next section).
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
11 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Figure 3-1: Representation of association (aggregation = composite)
3.1.2 Representation of attribute (aggregation = composite) [Tc0003Sc2]
Figure 3-2 depicts how an attribute is represented by means of instances of the UML2.0 meta-model. The attribute ‘theC’ is represented as a property that is owned by class ‘A’.
A
+ theC: C [0..*]
C
«metaclass»
:Class
name = C
«metaclass»
:Class
name = A
«metaclass»
:Property
aggregation = composite
upper = unbounded
lower = 0
name = theC
+ownedAttribute
+type
Figure 3-2: Representation of attribute (aggregation = composite)
3.1.3 Representation of associations (aggregation = none) [Tc0003Sc3]
Figure 3-3 depicts how a reference (association with aggregation = none) is represented by means of instances of the UML2.0 meta-model. The association end ‘theB’ is navigable from class D and is represented as a property that is owned by class ‘D’.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
12 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
The information represented by the anonymous association and the not navigable property is not relevant for the model persistence rules. From the point of view of the persistence rules there is no difference between a reference and an attribute with aggregation=none (see also next section). However, the AUTOSAR meta-model allows stereotypes for references. The special semantics are handled separately as described in section 4.2.3.
D B
«metaclass»
:Class
name = D
«metaclass»
:Class
name = B
«metaclass»
:Property
name = theB
lower = 0
upper = unbounded
aggregation = none
«metaclass»
:Association
name =
«metaclass»
:Property
aggregation = none
lower = 0
upper = 1
name =
+ownedEnd
+type
+memberEnd
+memberEnd
+type
+ownedAttribute
0..*
+theB
Figure 3-3: Representation of association (aggregation = none)
3.1.4 Representation of attributes (aggregation = none) [Tc0003Sc4]
Figure 3-4 depicts how an attribute with aggregation = none is represented by means of instances of the UML2.0 meta-model. The attribute ‘theB’ is represented as a property that is owned by class ‘D’. Notes:
A property with ‘aggregation = none’ is represented by a “*” in the UML2.0 graphical representation (attribute: theB: B*[0..*]).
According to the AUTOSAR Template Profile only attributes with aggregation=composite are allowed. However, the persistence rules for XML cover those attributes since they do not add complexity: For the persistence rules for XML attributes with aggregation=none (described in this section) are equivalent to associations with aggregation=none (described in section 3.1.3).
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
13 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Figure 3-4: Representation of attribute (aggregation = none)
3.2 Notes on use of W3C XML schema
A W3C XML schema provides means by which a validating XML parser can validate the syntax and some of the semantics of an XML description. XML validation can determine e.g.
whether required XML elements are available,
whether additional XML attributes or XML elements that are not allowed are used,
or whether some values fit to a given regular expression. Although some checking can be done, it is impossible to rely solely on XML validation to verify that the represented model satisfies all of a model’s semantic constraints. The persistence rules described in this document make sure that for each class, attribute and association represented in the AUTOSAR meta-model a representation in the AUTOSAR XML schema exists. Additionally, they make sure that the mapping between the AUTOSAR meta-model and the AUTOSAR schema is unambiguous. In other words:
An instance of the AUTOSAR meta-model maps unambiguously to an AUTOSAR XML description and
An AUTOSAR XML description that is valid with respect to the AUTOSAR XML schema maps unambiguously to an instance of the AUTOSAR meta-model.
This also holds for incomplete XML descriptions.
E.g.: The XML element ATOMIC-SOFTWARE-COMPONENT-TYPE always represents
content that is described by the class AtomicSoftwareComponentType.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
14 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
3.3 Handling inheritance
Inheritance in the AUTOSAR meta-model is mapped to XML schema by the following mechanisms:
For each class in the AUTOSAR meta-model groups are created which contain the XML-elements and XML-attributes that represent the properties that are directly defined by the class. Classes without properties with xml.attribute=false will result in empty groups.
Additionally an xsd:complexType representing the full content of the concrete class is created. The structure of this xsd:complexType is defined by referencing the group that defines the properties of the class itself and the xsd:groups that define the properties of the super-classes. The group representing the most general class (root of inheritance tree) is referenced first. The group representing the class itself is referenced last.
This concept allows for using polymorphism on XML level: The most general properties can always be found at the beginning of an XML-element. The more specific properties are appended at the end of a description. Additionally properties that are directly defined by a class are grouped together. (See section 3.7 for more details on the order of XML-elements and groups).
3.4 Generic approach
The AUTOSAR model persistence rules exceed the configuration possibilities of comparable approaches like XMI. This enables the generic reproduction of a wide range of existing XML formats such as MSR-SW [12] and XHTML [13].
3.5 XML element versus attribute
In accordance to the MSR-TR-CAP the persistence rules map all content related information to XML elements. This default rule can be overwritten by assigning the tagged value ‘xml.attribute=true’ to the respective property. If ‘xml.attribute=true’ then the property is translated to an XML-attribute. (See 4.1.2.1 for more details on this tagged value).
3.6 XML names [Tc0001]
All XML-elements, XML-attributes, XML-groups and XML-types used in the AUTOSAR XML schema are written in upper-case letters. In order to increase the readability of the XML names, hyphens are inserted in the XML names which separate parts of the names. This document refers to a name that is translated as described in this section as a XML-name. Non-alphanumeric characters SHALL not be used in UML names. Formally, the following algorithm describes the translation of the UML names to XML names:
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
15 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
1. Remove all non-alphanumeric characters from the UML name. If such characters exist, raise an error.
2. Split up the UML name from left to right into tokens. A new token starts whenever an uppercase letter or digit is found. E.g.: TestECUClass12ADC -> [Test, E, C, U, Class, 1, 2, A, D, C]
3. Iterate through the list, beginning from the last element and join adjacent single uppercase letters and join adjacent digits. E.g.: [Test, E, C, U, Class, 1, 2, A, D, C] -> [Test, E, C, U, Class, 1, 2, A, DC] -> [Test, E, C, U, Class, 1, 2, ADC] -> [Test, E, C, U, Class, 12, ADC] -> [Test, E, CU, Class, 12, ADC] -> [Test, ECU, Class, 12, ADC]
4. Convert all tokens to uppercase: E.g.: [TEST, ECU, CLASS, 12, ADC]
5. Concatenate the tokens using a hyphen: E.g.: TEST-ECU-CLASS-12-ADC
If the default mapping is not suitable, the XML name can be explicitly defined by specifying the tagged value ‘xml.name’ for the corresponding UML model element. In this case, the value of xml.name SHALL NOT be empty, only alphanumeric characters and hyphens SHALL be used as the value of xml.name, and the first and the last character of the value SHALL be alphanumeric. A plural XML-name is created by appending an “S” to the singular XML-name. If this rule is not suitable, then the plural XML-name can be explicitly defined by specifying the tagged value ‘xml.namePlural’ for the corresponding UML model element.
Examples: XML names of elements, types, groups and attributes
The following table shows some examples of translations from meta-model names to names used in the XML schema: Name in AUTOSAR meta-model XML name
SystemConstraintTemplate SYSTEM-CONSTRAINT-TEMPLATE
ECUResourceTemplate ECU-RESOURCE-TEMPLATE
HardwarePowerMode HARDWARE-POWER-MODE
Min MIN
TestECUClass12ADC TEST-ECU-CLASS-12-ADC
Uuid UUID
testECU TEST-ECU
MlData1 ML-DATA-1
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
16 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
3.7 Order of XML-elements [Tc0002]
In order to decrease the complexity and to improve the performance of tools that read AUTOSAR XML descriptions a predictable order of XML-elements is defined. Additionally the order of XML-elements improves the human readability of XML descriptions.
3.7.1 Order of xml elements
Properties owned by classes in the AUTOSAR meta-model are mapped to XML-elements. By default, the AUTOSAR XML schema defines a certain sequence on XML elements which follows an alphabetical ordering1. This default rule can be overwritten by using the tagged value ‘xml.sequenceOffset’. The value can be all integers between -999 to 999. The default value of xml.sequenceOffset is 0.
If offsetA is the offset of elementA and offsetB is the offset of elementB then:
offsetA < offsetB => elementA is listed before elementB
Elements with the same offset are ordered alphabetically.
3.7.2 Order of xml elements of derived uml:properties
Chapter 3.7.1 described the order of the XML elements without considering inheritance. In case of inheritance not only the XML elements that are generated out of the properties that are directly defined by a class need to be considered. Additionally the XML-elements defined by the super-classes are relevant. The XML elements that represent XML elements directly owned by a class are grouped together and ordered as described in section 3.7.1. The groups of XML elements are ordered as described by the pseudo code below: // global variables int index = 1;
Hashtable sequenceIndexTable = new Hashtable();
// method setSequenceIndex is invoked recursively void setSequenceIndex(Class class) {
List directBaseClasses = getDirectBaseClasses(class);
// if class has baseclasses If ( !directBaseClasses.isEmpty() ) {
// split up set of baseclasses into two groups List classesWithSupertypeIdentifiable =
getClassesWithSupertypeIdentifiable(directBaseClasses);
List classesWithoutSupertypeIdentifiable =
getClassesWithoutSupertypeIdentifiable(directBaseClasses);
// sort each group as defined above sort(classesWithSupertypeIdentifiable);
sort(classesWithoutSupertypeIdentifiable);
// for all classes with supertype identifiable do for (int i=0; i<classesWithSupertypeIdentifiable ; i++) {
setSequenceIndex(classesWithSupertypeIdentifiable[i]);
}
1 The alphabetical ordering applies to the XML-names.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
17 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
// for all classes without supertype identifiable do for (int i=0; i<classesWithSupertypeIdentifiable ; i++) {
setSequenceIndex(classesWithoutSupertypeIdentifiable[i]);
}
} // end if
// if sequence index is not already set, assign a new one. If (sequenceIndexTable.contains(class)) {
// the sequence is already set. This can result from diamond // inheritance return;
} else {
// the sequence index is not yet set sequenceIndexTable.put(class, index);
index++;
}
}
Figure 3-5 shows an example of the ordering of XML elements within the XML
schema. The numbers next to class Identifiable indicate the sequenceOffset of directly owned properties. The comments indicate the sequence of the groups of XML elements.
«atpIdentifiable»
Identifiable
{abstract}
+ shortName: Identifier
+ longName: String [0..1]
+ category: String [0..1]
+ uuid: String [0..1]
+ checksum: String [0..1]
+ timestamp: DateTime [0..1]
«atpIdentifiable»
ARElement
{abstract}
PropertyContainer
{abstract}
PropertyEvaluator
{abstract}
AtomicSoftwareComponentType
ComponentType
{abstract}PortPrototype
{abstract}
-100
-120
0
0
0
0
1
23
4
5
6
sequenceOffset
PropertyPrototype
+ type: Enumeration{Int, Float, Boolean }
+ defaultValue: String [0..1]
0..*
+ports+component
0..*
+properties
Figure 3-5: Order of XML elements
First the attributes from Identifiable are mapped to the XML schema. After that
the properties from PropertyContainer, PropertyEvaluator, ARElement,
ComponentType and AtomicSoftwareComponentType are mapped.
An xsd:group is created for all classes. The XML elements in each xsd:group are ordered as defined in section 3.7.1 (in this example all properties are mapped to XML elements):
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
18 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
xsd:group for Identifiable: <xsd:group name="IDENTIFIABLE">
<xsd:sequence>
<xsd:element name="LONG-NAME" type="xsd:string" minOccurs="0"/>
<xsd:element name="SHORT-NAME" type="AR:IDENTIFIER"/>
<xsd:element name="CATEGORY" type="xsd:string" minOccurs="0"/>
<xsd:element name="CHECKSUM" type=" xsd:string " minOccurs="0"/>
<xsd:element name="TIMESTAMP " type=" xsd:string " minOccurs="0"/>
<xsd:element name="UUID" type=" xsd:string " minOccurs="0"/>
</xsd:sequence>
</xsd:group>
LONG-NAME is listed first because it has the smallest sequenceOffset (-120). It is followed by SHORT-NAME (sequenceOffset=-100). All other properties have a sequenceOffset=0 and are sorted in alphabetical order.
xsd:group for PropertyContainer: <xsd:group name="PROPERTY-CONTAINER">
<xsd:sequence>
<xsd:element name="PROPERTIES" minOccurs="0" maxOccurs="unbounded" >
…
</xsd:element>
</xsd:sequence>
</xsd:group>
xsd:group for ComponentType: <xsd:group name="COMPONENT-TYPE">
<xsd:sequence>
<xsd:element name="PORTS" minOccurs="0" maxOccurs="unbounded" >
…
</xsd:element>
</xsd:sequence>
</xsd:group>
According to the rules for order of elements in case of inheritance these xsd:groups are composed together in the following order:
<xsd:complexType name="ATOMIC-SOFTWARE-COMPONENT-TYPE" abstract="false"
mixed="false">
<xsd:sequence>
<xsd:group ref="AR:IDENTIFIABLE"/>
<xsd:group ref="AR:PROPERTY-CONTAINER"/>
<xsd:group ref="AR:PROPERTY-EVALUATOR"/>
<xsd:group ref="AR:AR-ELEMENT"/>
<xsd:group ref="AR:COMPONENT-TYPE"/>
<xsd:group ref="AR:ATOMIC-SOFTWARE-COMPONENT-TYPE"/>
</xsd:sequence>
</xsd:complexType>
3.8 Linking [Tc0004]
References between meta-classes are represented by XML-elements suffixed with <….-REF> or <…-TREF>. For more details about the representation of associations in XML descriptions, please refer to Generic Structure Template [19].
3.9 Transmitting incomplete Data
[TR_APRXML_00028]⌈In order to allow the exchange of incomplete AUTOSAR
descriptions, by default all XML elements are optional.⌋(ATI_0035)
This default rule can be overwritten by marking a meta-model element with the tagged value ‘xml.enforceMinimumMultiplicity=true’. In this case the lower value of
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
19 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
the multiplicity will be used as minimum occurrence of an XML element in the AUTOSAR XML schema.
3.10 Identification of XML schema version in XML descriptions
The version of the AUTOSAR release is encoded into the namespace of the AUTOSAR XML schema. The format of the namespace is defined by http://autosar.org/schema/r<major>.<minor>. This allows for parallel use of different versions of AUTOSAR XML schema and AUTOSAR XML descriptions. E.g. the namespace of the AUTOSAR XML schema published with AUTOSAR release 4.0 is http://autosar.org/schema/r4.0.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
20 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
4 Configuration of XML schema production [Tc0005]
In order to reduce the complexity of the mapping rules and to increase the transparency of the mapping between meta-model classes with their attributes and associations on the one side, and XML-elements on the other side, the mapping rules do not directly operate on the AUTOSAR meta-model. Instead it is translated in two steps:
Step1: Configuration of XML schema production. In a first step the AUTOSAR meta-model is translated to a simplified intermediate model2. Content relevant information of the AUTOSAR meta-model is mapped to classes, properties, enumerations, primitive data types and tagged values. If not otherwise mentioned missing tagged values are set to their default value as described in section 4.1.1ff. Some more complex mappings are described in chapter 4.2.
Step 2: Schema production. The schema production rules use the intermediate model as input. The rules are parameterized by the tagged values defined in Step 1. See chapter 5 for more details on the schema production rules.
4.1 Tailoring schema production
4.1.1 Overview
The tagged values that can be used for tailoring the mapping rules are described in the following table. The effect of the different tagged values is shown in the detailed description of the mapping rules in chapter 5.
Tag Name Value Type
Default Value
Applicable to
Description
extensionPoint
[Tc0006Sc5]
[Tc0006Sc6]
Boolean False Class If set to true, then the class is mapped as it would have subclasses. This allows for later adding subclasses without loosing compatibility to older XML descriptions.
xml.attribute
[Tc0005Sc3]
Boolean False Property If true, serializes the property as an XML attribute. By default all properties are mapped to XML elements.
xml .attributeRef
Boolean False Property If true, serializes the property as an XML attribute reference (e.g. <xsd:attribute ref="xml:space" >). The namespace is taken from the value of xml.nsPrefix, the value of xml.name must be a valid name in that namespace.
xml.enforceMaxMultiplicity
[Tc0005Sc4]
Boolean True Property If true, enforce maximum multiplicity; otherwise, it is “unbounded”. By default xml.enforceMaxMultiplicity is true.
2The intermediate model only uses concepts which are available in EMOF [17].
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
21 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
xml.enforceMinMultiplicity
[Tc0005Sc4]
Boolean False Property If true, enforce minimum multiplicity; otherwise, it is “0.” In order to allow for transmitting partial information, the minimum multiplicity is not enforced by default.
xml.globalElement
[Tc0005Sc7]
Boolean False Class If true, a global xsd:element is created for the tagged class. This xsd:element can be used as the root element of an instance of the schema. This tag needs to be explicitly defined in the AUTOSAR meta-model. Usually only the meta-class AUTOSAR is represented by a globally defined XML element.
xml.mds.type
[Tc0005Sc8]
String Empty Class with
stereotype <<primitive>>
This tag identifies the xsd:simpleType or xsd:complexType which represents the primitive data type in the meta-model. In contrast to the ‘xml.xsd.customType’ tag, this tagged value indicates a schema fragment that is predefined within the schema generator. Therefore types tagged by ‘xml.mds.type’ are not generated into the schema based on the tagged class within the model.
Hence using this tag requires knowledge of the schema generation process it has to be ensured that only types created within the generation process are referenced by this tag.
xml.name
[Tc0005Sc1]
String See chapter 3.6
Property, Class
Provides the name of a schema fragment (element, attribute, group, etc.) that represents the role or class. If not explicitly defined in the AUTOSAR meta-model, then this value is calculated as explained in chapter 3.6.
xml .namePlural
[Tc0005Sc2]
String See chapter 3.6
Property, Class
Provides the plural name of a schema fragment (element, attribute, group, etc.) that represents the role or class. If not explicitly defined in the AUTOSAR meta-model, then this value is calculated as explained in chapter 3.6.
xml.nsPrefix
[Tc0005Sc9]
String AR Package, Class
By default all XML-elements are assigned to the namespace prefix “AR”.
If this namespace prefix is applied to a package then it is implicitly applied to all owned classes and packages not defining their own namespace.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
22 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
xml.nsURI
[Tc0005Sc9]
String http://autosar.org/schema/r<major>.<minor>
Package, Class
By default all XML-elements are assigned to the namespace http://autosar.org/schema/r<major>.<minor>
If the namespace is applied to a package then it is implicitly applied to all owned classes and packages not defining their own namespace.
xml.ordered
[Tc0005Sc5]
Boolean True Class If true, the order of XML elements representing the properties of a class is defined in a fixed order.
If false, the order of XML elements representing the properties of a class is defined in arbitrary order. Additionally all XML-elements may occur several times.
Please note that the tagged value ‘xml.ordered’ applies to the full XML representation of the class: All XML-elements are ordered regardless if they are inherited or not.
xml.roleElement
[Tc0010]
Boolean See chapter 4.2.2
Property If set to true, the xml.name of the role shows up as an XML-element. If not explicitly defined in the AUTOSAR meta-model, then the default rules as described in chapter 4.2 are applied.
xml.roleWrapperElement
[Tc0010]
Boolean See chapter 4.2.2
Property If set to true, the xml.namePlural of the role shows up as an XML-element. This XML element is usually used to group several role elements or type elements. If not explicitly defined in the AUTOSAR meta-model, then the default rules as described in chapter 4.2 are applied.
xml.sequenceOffset
[Tc0002]
Integer 0 Property, Generalization
The sequenceOffset is used to define the order of XML elements representing owned and derived properties. The range of sequenceOffset varies from -999 to 999. The elements with the smallest sequenceOffset are created first. Elements which have the same sequenceOffset are ordered alphabetically. If not explicitly defined in the AUTOSAR meta-model, then the xml.sequenceOffset is set to 0.
xml.text
[Tc0005Sc6]
Boolean False Class If true, text is allowed between the XML elements representing the properties. By default no text is allowed between the properties.
Please note that the tagged value ‘xml.text’ applies to the full XML representation of the class: Text may be written between all XML-elements, regardless if they are inherited or not.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
23 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
xml .typeElement
[Tc0010]
Boolean See chapter 4.2.2
Property If set to true, the xml.name of the type shows up as an XML-element. If not explicitly defined in the AUTOSAR meta-model, then the default rules as described in chapter 4.2 are applied.
xml.typeWrapperElement
[Tc0010]
Boolean false, see also chapter 4.2.2
Property If set to true, the xml.namePlural of the type shows up as an XML-element. The type wrapper wraps several occurrences of the same type. If not explicitly defined in the AUTOSAR, then the default rules as described in chapter 4.2 are applied.
xml.xsd .customType
String Empty Class with
stereotype <<primitive>>
This tag is applicable to a <<primitive>>. It specifies the name of the xsd:simpleType which represents the primitive type.
xml.xsd .maxLength
Integer Empty Class with
stereotype <<primitive>>
Length restriction for defining a custom primitive type based on a string type. xml.xsd.type must be string.
xml.xsd .pattern
String Empty Class with
stereotype <<primitive>>
Regular expression, used as restriction for defining a custom primitive type based on a string type. xml.xsd.type must be string.
xml.xsd.type
[Tc0005Sc8]
String Empty Class with
stereotype <<primitive>>
This tag identifies the xsd:simpleType which represents the primitive data type in the meta-model. The value refers to a W3C XML schema data type. The value of the tagged value shall not contain the namespace of the W3C schema. E.g.: Instead of ‘xsd:string’ please use ‘string’.
xml.xsd .whitespace
String Empty Property Flag, whether whitespace in the value of the property needs to be preserved. Valid values are {preserve, default}.
4.1.2 Constraints on tags
Some tags are not allowed to be used in combination with other tags. These constraints are listed in the next two subchapters.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
24 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
4.1.2.1 Constraints on tags applied to properties
Constraints on tags applied to properties
xm
l.na
me
xm
l.na
me
Plu
ral
xm
l.ro
leE
lem
ent
xm
l.ro
leW
rapp
erE
lem
en
t
xm
l.ty
pe
Ele
ment
xm
l.ty
pe
Wra
pperE
lem
en
t
xm
l.attri
bu
te
xm
l.en
forc
eM
axM
ultip
licity
xm
l.en
forc
eM
inM
ultip
licity
xm
l.sequ
enceO
ffse
t
xml.name /
xml.namePlural /
xml.roleElement / o
xml.roleWrapperElement / o
xml.typeElement / o
xml.typeWrapperElement / o
xml.attribute o o o o / o o
xml.enforceMaxMultiplicity o /
xml.enforceMinMultiplicity /
xml.sequenceOffset o /
If the tagged value ‘xml.attribute’ is set to true, then an XML attribute is created for the respective property. The name of the XML attribute is defined by the tagged value ‘xml.name’. If the lower value of the multiplicity of the property is bigger than 0 and ‘xml.enforceMinMultiplicity’ is set to true, then the ‘use’ of the XML attribute is set to ‘required’. The tagged values ‘xml.roleElement’, ‘xml.roleWrapperElement’, ‘xml.typeElement’, ‘xml.typeWrapperElement’, ‘xml.enforceMaxMultiplicity’ and ‘xml.sequenceOffset’ are ignored if the tagged value ‘xml.attribute’ is set to ‘true’. Please note, that the tagged value ‘xml.attribute’ is only allowed if the upper multiplicity of the property is 1 and the type of the property is an enumeration or a primitive data type.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
25 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
4.1.2.2 Constraints on tags applied to classes
Constraint on tags applied to classes
xm
l.na
me
xm
l.na
me
Plu
ral
xm
l.ord
ere
d
xm
l.te
xt
xm
l.g
lob
alE
lem
ent
xm
l.xsd.type
xm
l.m
ds.type
xml.name / o o
xml.namePlural / o o
xml.ordered / o o
xml.text / o o
xml.globalElement / o o
xml.xsd.type o o o o o / o
xml.mds.type o o o o o o /
The tagged values ‘xml.xsd.type’ and ‘xml.mds.type’ are used to specify a predefined data type which is defined in the W3C XML schema specification or in the Generic Structure Template []. If these tagged values are applied, then all other tagged values are ignored.
4.1.2.3 Constraints on values of xml.*Element tagged values
The following table depicts which combinations of values of the xml.*Element tags are allowed. The column usage defines that a combination is either preferred, alternative, “handle with care” or not allowed. The first two categories always lead to consistent, unambiguous XML schema. The “handle with care” category describes mapping rules which might lead to invalid XML schema. Those mapping rules are allowed in order to be able to support some MSR-TR-CAP concepts.
xm
l.ro
leW
rap
pe
rEle
men
t
xm
l.ro
leE
lem
en
t
xm
l.ty
pe
Wra
pp
erE
lem
en
t
xm
l.ty
pe
Ele
men
t
description Usag
e (
P=
pre
ferr
ed
,
A=
alt
ern
ati
ve, H
=h
an
dle
wit
h c
are
, N
=n
ot
allo
wed
)
used
in
sta
nd
ard
0 0 0 0 Handle with care: The resulting pattern will result in ambiguous XML schema H MSR
0 0 0 1 Handle with care: Role Information is missing - might lead to ambiguous XML schema if two roles have the same type H MSR
0 0 1 0 Not allowed: typeWrapperElement without typeElement N
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
26 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
xm
l.ro
leW
rap
pe
rEle
men
t
xm
l.ro
leE
lem
en
t
xm
l.ty
pe
Wra
pp
erE
lem
en
t
xm
l.ty
pe
Ele
men
t
description Usag
e (
P=
pre
ferr
ed
,
A=
alt
ern
ati
ve, H
=h
an
dle
wit
h c
are
, N
=n
ot
allo
wed
)
used
in
sta
nd
ard
0 0 1 1 Handle with care: Role Information is missing - might lead to ambiguous descriptions if two roles have the same type H MSR
0 1 0 0
Preferred for properties without inheritance and upper multiplicity = 1, Handle with care if used with inheritance P
XMI2.0, XMI2.1, MSR
0 1 0 1 Preferred for properties with inheritance and upper multiplicity = 1. P XMI1.2
0 1 1 0 Not allowed: typeWrapperElement without typeElement N
0 1 1 1 Alternative solution for 0101 if the typeElements need to be wrapped by a typeWrapperElements. A MSR
1 0 0 0 Not allowed: roleWrapperElement without roleElement or typeElement N
1 0 0 1 Preferred for properties with upper multiplicity > 1 P MSR
1 0 1 0 Not allowed: typeWrapperElement without typeElement N
1 0 1 1 Alternative mapping for (1001) if the typeElements need to be wrapped by a typeWrapperElements. A MSR
1 1 0 0 alternative for properties without inheritance and upper multiplicity > 1, handle with care if used with inheritance A MSR
1 1 0 1 Alternative solution for properties with inheritance and upper multiplicity > 1 (1001) A MSR
1 1 1 0 Not allowed: typeWrapperElement without typeElement N
1 1 1 1 Alternative solution for (1001) A MSR
4.2 Default configuration of XML schema production [Tc0006]
This chapter describes how the XML persistence rules are configured for mapping the AUTOSAR meta-model to the AUTOSAR XML schema. Tagged values that are already defined in the AUTOSAR meta-model are not overwritten: The configuration rules defined in this chapter add missing tagged values. If the resulting combination of tagged values is invalid, an error needs to be indicated. The fault needs to be resolved by editing the tagged values in the AUTOSAR meta-model.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
27 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
4.2.1 Configuration of multiplicities
The tagged values ‘xml.enforceMinMultiplicity’ and ‘xml.enforceMaxMultiplicity’ are set to the default values (see chapter 4.1.1) if not explicitly defined otherwise in the AUTOSAR meta-model. Additionally, the multiplicities of all properties are updated according to the following rules:
If ‘xml.enforceMinMultiplicity = false’, then set ‘lower multiplicity’ of property to 0.
If ‘xml.enforceMinMultiplicity = true’, then no changes on ‘lower multiplicity’ of property.
If ‘xml.enforceMaxMultiplicity = false’, then set ‘upper multiplicity’ of property to unbounded.
If ‘xml.enforceMaxMultiplicity = true’, then no changes on ‘upper multiplicity’ of property.
4.2.2 Mapping configuration for properties
A B
{abstract}
B1
+ attB1: String
B2
+ attB2: String
C
+ attC: String
*
+theB
1+theC
Figure 4-1: Example meta-model
Four cases are distinguished when configuring the mapping of properties in the AUTOSAR meta-model:
1. Upper multiplicity of property = 1 and type of property has no subclasses (see property ‘theC’ in Figure 4-1): [Tc0006Sc1] [ Tc0006Sc5]
xml.roleWrapperElement = false Note: upper multiplicity of property = 1, no need for a wrapper
xml.roleElement = true
xml.typeWrapperElement = false Note: upper multiplicity of property = 1, no need for a wrapper
xml.typeElement = false Note: the type can uniquely be derived from meta-model
Note: If the tagged value ‘extensionPoint’ is used for a class and set to true, then the class is mapped as it would have subclasses. This allows for later
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
28 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
adding subclasses without loosing backwards compatibility to older XML descriptions. In this case the “*Element” tagged values are set according to case 3.
2. Upper multiplicity of property > 1 and type of property has no
subclasses [Tc0006Sc2] [Tc0006Sc6]
xml.roleWrapperElement = true Note: upper multiplicity of property > 1, according to MSR-TR-CAP wrapper required
xml.roleElement = false Note: property can be determined by the roleWrapperElement, no need for an additional roleElement
xml.typeWrapperElement = false Note: roleWrapperElement is true, no additional wrapper required
xml.typeElement = true Note: the content model of each type which occurs more than once needs to be encapsulated in an XML-element. Either the roleElement or the typeElement can be chosen. We chose the typeElement since the resulting schema allows for adding subclasses to the type of the property. (see also case 4)
3. Upper multiplicity of property = 1 and type of property has subclasses
[Tc0006Sc3]
xml.roleWrapperElement = false Note: upper multiplicity of property = 1, no need for a wrapper
xml.roleElement = true
xml.typeWrapperElement = false Note: upper multiplicity of property = 1, no need for a wrapper
xml.typeElement = true Note: If no type information is given, it is not always possible to uniquely map an element in an XML description to an instance of the meta-model.
4. Upper multiplicity of property > 1 and type of property has subclasses
(see property ‘theB’ in Figure 4-1) [Tc0006Sc4]
xml.roleWrapperElement = true Note: upper multiplicity of property > 1, according to MSR-TR-CAP wrapper required
xml.roleElement = false Note: property can be determined by the roleWrapperElement, no need for an additional roleElement
xml.typeWrapperElement = false Note: roleWrapperElement is true, no additional wrapper required
xml.typeElement = true Note: If no type information is given, it is not always possible to uniquely map an element in an XML description to an instance of the meta-model.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
29 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
5. Upper multiplicity of property > 1 and type of property is primitive or enum or association
xml.roleWrapperElement = true Note: upper multiplicity of property > 1, according to MSR-TR-CAP wrapper required
xml.roleElement = true
xml.typeWrapperElement = false Note: roleWrapperElement is true, no additional wrapper required
xml.typeElement = false Note: the content model of each type which occurs more than once needs to be encapsulated in an XML-element. Either the roleElement or the typeElement can be chosen. For Primitives, we chose the roleElement since the MetaModel does not use subclassing for primitives.
Tagged values ‘xml.*Element’ that are already defined in the AUTOSAR meta-model are not overwritten. Therefore the mapping to XML can individually be configured if the default mappings are not sufficient. The default settings for the production of the AUTOSAR XML schema are summarized in Table 4-2.
applicable
for Autosar
UpperMul Target has
Subclass
(same as
Target is
abstract)
Type of
relation
xml.Role
Wrapper
Element
xml.role
Element
xml.Type
Wrapper
Element
xml.type
Element
xml.namePlural
(the
wrapperName)
xml.name
(the inner name)
XML -
Persistence-
rules
Comment
yes =1 no Subclass Aggr false true false false {role} case 1
yes =1 no Subclass Assoc false true false false {role}Ref
yes =1 no Subclass InstanceRef false true false false {role}Iref
yes =1 no Subclass IsOfType false true false false {role}Tref
yes =1 no Subclass Attr/primitive false true false false {role}
yes =1 Subclass Aggr false true false true {role} {type} case 3
yes =1 Subclass Assoc false true false false {role}Ref Subclassing is represented
in dest
yes =1 Subclass InstanceRef false true false false {role}Iref Subclassing is represented
in dest of atpTarget
yes =1 Subclass IsOfType false true false false {role}Tref Subclassing is represented
in dest
no =1 Subclass Attr/primitive false true false false {role}
yes >1 no Subclass Aggr true false false true {role}s {type} case 2
yes >1 no Subclass Assoc true true false false {role}Refs {role}Ref
yes >1 no Subclass InstanceRef true true false false {role}Irefs {role}Iref
no >1 no Subclass IsOfType true true false false {role}Trefs {role}Tref
>1 no Subclass Attr/primitive true true false false {role}s {role} case 5
yes >1 Subclass Aggr true false false true {role}s {type} case 4
yes >1 Subclass Assoc true true false false {role}Refs {role}Ref Subclassing is represented
in dest of atpTarget
yes >1 Subclass InstanceRef true true false false {role}Irefs {role}Iref Subclassing is represented
in dest of atpTarget
no >1 Subclass IsOfType true true false false {role}Trefs {role}Tref Subclassing is represented
in dest of atpTarget
no >1 Subclass Attr/primitive true true false false {role}s {type}
no =1 instanceRef
implemention
has
subclasses
InstanceRef false true false true {role}Iref {InstanceRef}
derived from the
InstanceRef
implementation
meta class
Subclassing is represented
in dest of atpTarget
no >1 instanceRef
implemention
has
subclasses
InstanceRef true false false true {role}Irefs {InstanceRef}
derived from the
InstanceRef
implementation
meta class
Subclassing is represented
in dest of atpTarget
Case Default configuration of Schema
Table 4-2: Overview of XML Schema Production Defaults
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
30 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
4.2.3 Mapping configuration for references
In addition to the configuration defined in the previous section the following configuration is applied to references (association with aggregation = none).
4.2.3.1 References without stereotypes [Tc0004Sc1]
For references we basically distinguish the following two cases:
1. Upper multiplicity of reference = 1 Xml.RoleWrapperElement = false xml.roleElememt = true xml.typeWrapperElement = false xml.typeElement = false
2. Upper Multiplicity of reference > 1 Xml.RoleWrapperElement = true xml.roleElememt = true xml.typeWrapperElement = false xml.typeElement = false
Furthermore ‘xml.name’ of properties representing the navigable association end of references is set to the default ‘xml.name’ appended by “-REF” (the default ‘xml.name’ is defined in chapter 3.6). The ‘xml.namePlural’ is set to the default ‘xml.name’ appended by “-REFS”.
4.2.3.2 Instance references [Tc0004Sc2]
The AUTOSAR Template UML Profile requires that all details of instance references are properly modeled in the AUTOSAR meta-model. The following tagged values are applied:
Composite reference between the source of the instance reference and the meta-class which contains the references to the context(s) and the target:
o xml.name = xml-name suffixed by ‘-IREF’ o xml.namePlural = xml-name suffixed by ‘-IREFS’ o xml.roleElement = true o xml.typeWrapperElement = false o xml.typeElement = false
instanceRef meta-class: o xml.name = xml-name suffixed by “-IREF”. Additionally
the “_” is replaced by “--” in order to guarantee the uniqueness of the xml name.
reference from instanceRef meta-class to the target (the reference to the target is mandatory):
o xml.enforceMinMultiplicity = true o xml.enforceMaxMultiplicity = true o xml.sequenceOffset = 9999
(the target is the last element in the list of references)
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
31 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
references from instanceRef meta-class to contexts. For each context reference: o xml.enforceMinMultiplicity = false
(references to the contexts may be added later) o xml.enforceMaxMultiplicity = true o xml.roleWrapperElement = false o xml.roleElement = true o xml.typeElement = false o xml.typeWrapperElement = false
Example
Figure 4-3 shows an example of a detailed representation of an instance reference in the AUTOSAR meta-model.
SystemTemplate::System
+ ecuExtractVersion: RevisionLabelString [0..1]
+ pncVectorLength: PositiveInteger [0..1]
+ pncVectorOffset: PositiveInteger [0..1]
+ systemVersion: RevisionLabelString
SystemTemplate::SystemMapping
SWmapping::SwcToEcuMapping
Composition::SwComponentPrototype
InstanceRefs::
ComponentInSystemInstanceRefSystemTemplate::
RootSwCompositionPrototype
Composition::
CompositionSwComponentType
Components::
SwComponentType
+mapping 0..*
«atpVariation,atpSplitable»
+swMapping *
«atpVariation»
«instanceRef»
+component 1..*
+targetComponent
1
{redefines atpTarget}
+contextComponent*
{ordered,
subsets atpContextElement}
+component 1..*
«atpDerived»
+base 0..1
{redefines atpBase}
+contextComposition
0..1
{subsets atpContextElement}
+rootSoftwareComposition 0..1
«atpVariation»
+component
0..* «atpVariation,atpSplitable»
*
«isOfType»
+softwareComposition
1
{redefines atpType}
* «isOfType»
+type
1
{redefines atpType}
Figure 4-3: Example of an instanceRef association
The following XML snippet shows how this instance reference is represented in the XML schema:
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
32 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
<!-- complex type for class InstanceRefs::ComponentInCompositionInstanceRef -->
<xsd:complexType name="COMPONENT-IN-COMPOSITION-INSTANCE-REF" abstract="false"
mixed="false">
<xsd:annotation>
<xsd:documentation>The ComponentInCompositionInstanceRef points to a
concrete SwComponentPrototype within a
CompositionSwComponentType.</xsd:documentation>
<xsd:appinfo
source="tags">mmt.qualifiedName="ComponentInCompositionInstanceRef"</xsd:appinfo>
<xsd:appinfo source="stereotypes">atpObject,instanceRef</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:group ref="AR:AR-OBJECT"/>
<xsd:group ref="AR:ATP-INSTANCE-REF"/>
<xsd:group ref="AR:COMPONENT-IN-COMPOSITION-INSTANCE-REF"/>
</xsd:sequence>
<xsd:attributeGroup ref="AR:AR-OBJECT"/>
</xsd:complexType>
<!-- element group for class InstanceRefs::ComponentInSystemInstanceRef -->
<xsd:group name="COMPONENT-IN-SYSTEM-INSTANCE-REF">
<xsd:annotation>
<xsd:appinfo
source="tags">mmt.qualifiedName="ComponentInSystemInstanceRef"</xsd:appinfo>
<xsd:appinfo source="stereotypes">atpObject,instanceRef</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<!-- Association <<atpDerived>>base skipped -->
<xsd:element name="CONTEXT-COMPOSITION-REF" minOccurs="0">
<xsd:annotation>
<xsd:appinfo
source="tags">mmt.qualifiedName="ComponentInSystemInstanceRef.contextComposition";pureMM.maxOc
curs="1";pureMM.minOccurs="0";xml.sequenceOffset="20"</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="AR:REF">
<xsd:attribute name="DEST"
type="AR:ROOT-SW-COMPOSITION-PROTOTYPE--SUBTYPES-ENUM" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="CONTEXT-COMPONENT-REF" minOccurs="0"
maxOccurs="unbounded">
<xsd:annotation>
<xsd:appinfo
source="tags">mmt.qualifiedName="ComponentInSystemInstanceRef.contextComponent";pureMM.maxOccu
rs="-1";pureMM.minOccurs="0";xml.sequenceOffset="30"</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="AR:REF">
<xsd:attribute name="DEST"
type="AR:SW-COMPONENT-PROTOTYPE--SUBTYPES-ENUM" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="TARGET-COMPONENT-REF" minOccurs="0">
<xsd:annotation>
<xsd:appinfo
source="tags">mmt.qualifiedName="ComponentInSystemInstanceRef.targetComponent";pureMM.maxOccur
s="1";pureMM.minOccurs="1";xml.sequenceOffset="40"</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="AR:REF">
<xsd:attribute name="DEST"
type="AR:SW-COMPONENT-PROTOTYPE--SUBTYPES-ENUM" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:group>
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
33 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
An example instanceRef looks like:
<…>
<COMPONENT-IREFS>
<COMPONENT-IREF>
<CONTEXT-COMPOSITION-REF DEST="ROOT-SW-COMPOSITION-PROTOTYPE">
/theSystem/aVehicle
</CONTEXT-COMPOSITION-REF>
<CONTEXT-COMPONENT-REF DEST="SW-COMPONENT-PROTOTYPE">
/vendor/theEngine
</CONTEXT-COMPONENT-REF>
<TARGET-COMPONENT-REF DEST="SW-COMPONENT-PROTOTYPE">
/theEngineVendor/engineSpeedDetermination
</TARGET-COMPONENT-REF>
</COMPONENT-IREF>
</COMPONENT-IREFS>
</ …>
4.2.3.3 References with stereotype <<isOfType>> [Tc0004Sc2]
If the stereotype <<isOfType>> is applied to an association in the AUTOSAR meta-model then the tagged value ‘xml.name’ of the navigable association end is set to the default xml.name appended by “-TREF”. According to the AUTOSAR Template Profile, the upper multiplicity of an association with stereotype <<isOfType>> is limited to 1. Therefore no multiplicity wrapper is required and no xml.namePlural needs to be defined.
4.2.4 Stereotypes applied to classes [Tc0011]
4.2.4.1 Stereotype <<atpMixed>> [Tc0011Sc1]
If the stereotype <<atpMixed>> is applied to a class in the AUTOSAR meta-model then the properties are represented by XML elements in arbitrary order and unbounded multiplicity. This only applies to properties that are not explicitly mapped to attributes by setting the 'xml.attribute' tag to 'true'. The following default values are applied to classes with stereotype <<atpMixed>> (if no other values are specified in the meta-model):
Default values of the stereotyped meta-class: o xml.ordered=false o xml.text=false
Default values of the properties of the stereotyped meta-class: o upper multiplicity = unbounded o lower multiplicity = 0 o xml.roleWrapperElement = false o xml.roleElement = true o xml.typeWrapperElement = false o xml.typeElement = true (if the type of the property has concrete
subclasses), false (otherwise)
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
34 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
4.2.4.2 Stereotype <<atpMixedString>> [Tc0011Sc2]
If the stereotype <<atpMixedString>> is applied to a class in the AUTOSAR meta-model then the properties may be represented by XML elements in arbitrary order which may have text in-between. In this case the tagged value ‘xml.ordered’ is set to false and the tagged value ‘xml.text’ is set to true. See chapter 4.1.1 for more details on the scope of the tagged value ‘xml.text’. If the stereotype <<atpMixedString>> is applied to a class in the AUTOSAR meta-model then the properties are represented by XML elements in arbitrary order and unbounded multiplicity. No wrappers are created for the properties. Additionally, the XML elements may have text in-between. The following default values are applied to classes with stereotype <<atpMixedString>> (if no other values are specified in the meta-model):
Default values of the stereotyped meta-class: o xml.ordered=false o xml.text=true
Default values of the properties of the stereotyped meta-class: o upper multiplicity = unbounded o lower multiplicity = 0 o xml.roleWrapperElement = false o xml.roleElement = true o xml.typeWrapperElement = false o xml.typeElement = true (if the type of the property has concrete
subclasses), false (otherwise)
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
35 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
5 XML Schema production rules
The following sections describe the mapping rules for an automatic generation of the AUTOSAR XML schema out of the intermediate meta-model. Please note that in the intermediate meta-model all tagged values and multiplicities are set as defined in chapter 4. Each rule is described by the following information:
Applies to: The meta-meta-model (UML2.0) element the rule applies to
Precondition: The rule can only be applied if the precondition evaluates to true
Target pattern: The target pattern describes how the respective meta-model element is mapped to XML schema. Values that need to be read out of the AUTOSAR meta-model are denoted by script tags “<%” and “%>”: e.g.: <%=my variable %>. The following color code is used in the pattern definition:
o Black: The part of the pattern which directly reflects the model element o Yellow: Information that is extracted or calculated from the AUTOSAR
meta-model.
Description: The description explains the target pattern and how it can be parameterized.
UML example, XML schema example and XML instance example: These examples illustrate the application of the rule.
5.1 Create model representation [Tc0007]
Figure 5-1 depicts how a model is mapped to a XML schema. The header of the schema is created first, followed by XML representations for each class. After that the predefined data types and the footer of the schema are created.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
36 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
«list»
metaclasses :
Classes
[APRXML0000] Create
schema frame - footer
[APRXML0000] Create
schema frame - header
for all metclassesiterativ e
metaclasses
Create class
Representation
ActivityFinal
Create predefined data
types
Figure 5-1: Model representation
5.1.1 [TR_APRXML_00000] ⌈Create xsd:schema⌋()
Applies to Package
Precondition n/a
Target pattern
<xsd:schema xmlns:<%=xmlNsPrefix%>="<%=xmlNsUri%>"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="<%=xmlNsUri%>"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>
<% for all classes { %>
<!—call class representation-->
<% } %>
</xsd:schema>
Description This rule creates the header and footer of the XML schema. By default xmlNsPrefix is set to “AR” and the xmlNsUri is set to http://autosar.org/schema/r<realease_number>. To The body of the XML schema is composed of an namespace import of the XML namespace and representations for each class (including their properties).
UML example n/a
XML schema example
<xsd:schema xmlns:AR="http://autosar.org/schema/r4.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://autosar.org/schema/r4.0" elementFormDefault="qualified"
attributeFormDefault="unqualified">
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
37 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
….
</xsd:schema>
XML instance example
<… xmlns="http://autosar.org/schema/r4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://autosar.org/schema/r4.0 autosar.xsd">….
</…>
5.2 Create class representation [Tc0008]
Figure 5-2 depicts XML schema fragments created for each class:
If the stereotype <<enumeration>> is applied, then the class is mapped to an xsd:enumeration [TR_APRXML_00007] [Tc0008Sc5].
If the stereotype <<primitive>> is applied, then the data type denoted by the tagged value ‘xml.mds.type’ or ‘xml.xsd.type’ are used to represent the class within the schema [TR_APRXML_00006] [Tc0008Sc6].
Otherwise: o If the class owns properties with ‘xml.attribute=true’ then an
xsd:attributeGroup is created [TR_APRXML_00002] [Tc0008Sc4]. o Additionally if the class owns properties with ‘xml.attribute=false’ then
an xsd:group is created [TR_APRXML_00001] [Tc0008Sc3]. o Additionally if the class is not abstract then an xsd:complexType is
created [TR_APRXML_00003]. If the tagged value ‘xml.globalElement’ is set to true, then a global XML element declaration is created. [Tc0008Sc1]
o Additionally if the uml:class is referenced then an xsd:simpleType that represents the lists possible concrete instances of the uml:class [TR_APRXML_00025].
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
38 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Class
stereotype
[APRXML003] Create
xsd:complexType
[APRXML0024] Create
xsd:complexType with
simple content
[APRXML0001] Create
xsd:group
[APRXML0002] Create
xsd:attributeGroup
[APRXML0025] Create
xsd:simpleType for subtypes
[APRXML0007] Create
xsd:simpleType for
enumeration
[APRXML0006] Create
reference to predefined
datatype
simple content
global element
[APRXML0005] Create
global xsd:element
[APRXML0026] Create a
custom simple type
simple content = true iff
number of (owned and derived) properties which are not mapped to an xml attribute = 1
AND type of property that is not mapped to xml attribute is <<primitive>> or
<<enumeration>>
upper multiplicity of property that is not mapped to xml attribute is 1
xml.*Element tagged values of property that is not mapped to xml attribute is false
has attributes
:[APRXML0001]
Create xsd:group
[has property with
'xml.attribute = true'][is referenced] [enumeration] ['xml.xsd.type' or
'xml.mds.type' is set]
[not enumeration && not primitive]
class is not abstract
[xml.globalElement = true]
[xml.globalElement = false]
[has property with
'xml.attribute = false']
[yes]
['xml.xsd.customType' is set]
[primitive]
[no]
[yes]
[no]
Figure 5-2: Class representation
5.2.1 [TR_APRXML_00001] ⌈Create xsd:group ⌋() [Tc0008Sc3]
Applies to Class
Precondition None (classes without properties with xml.attribute=false will result in empty groups).
Target pattern
<xsd:group name=”<%=xmlName%>”>
<xsd:sequence>
for all properties { %>
<!—call rule
TR_APRXML_00008 |
TR_APRXML_00009 |
TR_APRXML_00023 |
TR_APRXML_00022 |
TR_APRXML_00010 |
TR_APRXML_00011 |
TR_APRXML_00012 |
TR_APRXML_00013 |
TR_APRXML_00014 |
TR_APRXML_00015 |
TR_APRXML_00016
-->
<% } // end for
<xsd:sequence>
</xsd:group>
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
39 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Description If the class owns at least one property with ‘xml.attribute=false’, then a xsd:group is created. The name of the xsd:group maps to the XML-name of the class. The XML elements nested in the xsd:sequence are ordered as defined in section 3.7.1.
The XML-elements representing the properties are created by rules TR_APRXML_00008, TR_APRXML_00009, TR_APRXML_00023, TR_APRXML_00022, TR_APRXML_00010, TR_APRXML_00011, TR_APRXML_00012, TR_APRXML_00013, TR_APRXML_00014, TR_APRXML_00015, TR_APRXML_00016
UML example
Identifiable
+ shortName: Identifier
+ longName: String [0..1]
+ category: String [0..1]
+ uuid: String
tagged value of shortName:
xml.enforceMinimumMuiltiplicity
tagged value of uuid:
xml.attribute=true
XML schema example
<xsd:group name="IDENTIFIABLE">
<xsd:sequence>
<!— property representations created by rules TR_APRXML_00008, TR_APRXML_00009, TR_APRXML_00023,
TR_APRXML_00022, TR_APRXML_00010, TR_APRXML_00011,
TR_APRXML_00012, TR_APRXML_00013, TR_APRXML_00014,
TR_APRXML_00015, TR_APRXML_00016 -->
<xsd:element name=”SHORT-NAME” type=”AR:IDENTIFIER” minOccurs=”1” maxOccurs=”1”> <xsd:element name=”LONG-NAME” type=”xsd:string” minOccurs=”0” maxOccurs=”1”> <xsd:element name=”CATEGORY” type=”xsd:string” minOccurs=”0” maxOccurs=”1”>
<!— end property representations created by rules -->
</xsd:sequence>
</xsd:group>
XML instance example
<…>
<SHORT-NAME>theShortName</SHORT-NAME>
<LONG-NAME>theLongtName</LONG-NAME>
<CATEGORY>theCategory</ CATEGORY >
</…>
5.2.2 [TR_APRXML_00002] ⌈[Create xsd:attributeGroup⌋() [Tc0008Sc4]
Applies to Class
Precondition Exists properties with “xml.attribute=true”
Target pattern
<xsd:attributeGroup name=”<%=xmlName%>”>
<% for all properties represented as XML attributes { %>
<!— call rule TR_APRXML_00019 -->
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
40 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
<% } %}
</xsd:attributeGroup>
Description If at least one property is marked by the tagged value ‘xml.attribute=true’, then a xsd:attributeGroup is created. The name of the xsd:attributeGroup is defined by the XML-name of the class which owns the property.
UML example
Identifiable
+ shortName: Identifier
+ longName: String [0..1]
+ category: String [0..1]
+ uuid: String
tagged value of shortName:
xml.enforceMinimumMuiltiplicity
tagged value of uuid:
xml.attribute=true
XML schema example
<xsd:attributeGroup name="IDENTIFIABLE">
<!—attributes defined by rule TR_APRXML_00019 -->
</xsd:attributeGroup>
XML instance example
n/a
5.2.3 [TR_APRXML_00003] ⌈Create xsd:complexType⌋() [Tc0008Sc1]
Applies to Class
Precondition isAbstract=false
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
41 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Target pattern
<xsd:complexType name=”<%=xmlName%>” mixed=”<%=xmlText%>”>
<% if ( ordered ) { %>
<xsd:sequence>
<% } else { %>
<xsd:choice minOccurs=”0” maxOccurs=”unbounded”>
<% }
<% for (myclass in {class and all baseclasses}) { %>
<xsd:group ref=”<%=baseclassNsPrefix%>:<%=myclassXmlName%>”/>
<% } // for (class and all baseclasses) %>
<% if ( ordered ) { %>
</xsd:sequence>
<% } else { %>
</xsd:choice>
<% }
<% for (class and all baseclasses) { %>
<xsd:attributeGroup ref=”<%=baseclassNsPrefix%>:<%=baseclassXmlName%>”/>
<% } // for (class and all baseclasses) %>
</xsd:complexType>
Description If the class is not abstract then a xsd:complexType is created. The name of the xsd:complexType is defined by the XML-name of the class. The created xsd:complexType doesn’t directly define XML representations of properties. Instead it refers to the xsd:groups and xsd:attributeGroups which have been created for the class and all super-classes (see rule TR_APRXML_00001 and TR_APRXML_00002 ). The groups are ordered as defined in section 3.7.2.
If the tagged value ‘xml.ordered=true’ is set then the xsd:groups are listed in a xsd:sequence. Otherwise they are listed within a xsd:choice.
If ‘xml.text=true’ then the attribute ‘mixed’ of the xsd:complexType is set to ‘true’.
UML example
AUTOSAR
XML schema example
<xsd:complexType name="AUTOSAR">
<xsd:sequence>
<xsd:group ref="AR:AUTOSAR"/>
</xsd:sequence>
<xsd:attributeGroup ref="AR:AUTOSAR"/>
</xsd:complexType>
XML instance example
n/a
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
42 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
5.2.4 [TR_APRXML_00024] ⌈Create xsd:complexType with simple content⌋()
Applies to Class
Precondition isAbstract=false AND
number of (owned and derived) properties which are not mapped to an xml attribute = 1 AND
type of property that is not mapped to xml attribute is <<primitive>> or <<enumeration>> AND
upper multiplicity of property that is not mapped to xml attribute is 1 AND
xml.*Element tagged values of property that is not mapped to xml attribute is false
Target pattern
<xsd:complexType name=”<%=xmlName%>” mixed=”<%=xmlText%>”>
<xsd:simpleContent>
<xsd:extension base="<%=propertyTypeNsPrefix%>:<%=propertyTypeXmlName%>">
<% for (class and all baseclasses) { %>
<xsd:attributeGroup
ref=”<%=baseclassNsPrefix%>:<%=baseclassXmlName%>”/>
<% } // for (class and all baseclasses) %>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
Description If the class is not abstract and it contains exactly one (derived or owned) property that is not mapped to an xml.attribute and this property is not represented by any XML elements (tagged values xml.*Element=false) then a xsd:complexType with simpleContent is generated. The simpleContent contains the data of the property which is not mapped to an xml.attribute.
If the type of the property that is represented as attribute has properties, then these properties cannot be mapped to simpleContent. In this case an error shall be reported.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
43 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
UML example
Limit
+ limitType: LimitTypeEnum
+ value: Integer
tagged values of l imitType:
xml.attribute=true
tagged values of value:
xml.roleElement=false
xml.roleWrapperElement=false
xml.typeElement=false
xml.typeWrapperElement=false
«primitive»
Integer
XML schema example
<xsd:complexType name="LIMIT">
<xsd:simpleContent>
<xsd:extension base="AR:INTEGER">
<xsd:attributeGroup ref="AR:LIMIT"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
XML instance example
<... LIMIT-TYPE="CLOSED">
1000
</...>
5.2.5 [TR_APRXML_00005] ⌈Create global xsd:element⌋() [Tc0008Sc2]
Applies to Class
Precondition ‘xml.globalElement=true
Target pattern
<xsd:element name=”<%=typeXmlName%>”
type=”<%typeXmlNsPrefix%>:<%=typeXmlName%>”/>
Description If the class is marked by the tagged value ‘xml.globalElement=true’ then a global xsd:element is created. The name of the xsd:element is defined by the XML-name of the class and the type is defined by the xsd:complexType which was defined by TR_APRXML_00003. The namespace prefix is defined by the tagged value ‘xml.nsPrefix’.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
44 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
UML example
AUTOSAR
tags
xml.globalElement = true
XML schema example
<xsd:element name="AUTOSAR"
type="AR:AUTOSAR"/>
XML instance example
<AUTOSAR>
…
</AUTOSAR>
5.2.6 [TR_APRXML_00025] ⌈Create enumeration of subtypes⌋()
Applies to Class
Precondition Class is referenced
Target pattern
<xsd:simpleType name=”<%=xmlName%>--SUBTYPES-ENUM”>
<xsd:restriction base=”xsd:string”>
<% for type and all subtypes { %>
<xsd:enumeration value=”<%=typeXmlName%>”/>
<%} // for type and all subtypes %>
</xsd:restriction>
</xsd:simpleType>
Description Creates an enumeration which represents the XML names of the class and all its subtypes. This enumeration is required for describing potential destination types of references.
UML example See Figure 5-7.
XML schema example
<xsd:element name="B—SUBTYPES-ENUM">
<xsd:restriction base=”xsd:string”>
<xsd:enumeration value=”B-1”/>
<xsd:enumeration value=”B-2”/>
</restriction>
</xsd:element>
XML instance example
<THE-B-REF DEST=”B-1”>/shortname</THE-B-REF>
5.2.7 [TR_APRXML_00006] ⌈Create reference to XML predefined data type⌋()
[Tc0005Sc8] [Tc0008Sc6]
Applies to class with stereotype <<primitive>>
Precondition tagged value ‘xml.xsd.type=…’
or
‘xml.mds.type=…’
defined
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
45 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Target pattern
…. type=”<%=typeXmlNsPrefix%>:<%=xmlXsdType%>” ….
Description Each class with the stereotype <<primitive>> is represented by the xsd:simpleType that is defined by the tagged value ‘xml.xsd.type’ or ‘xml.mds.type’, unless a custom xsd:simpleType is defined by the tagged value ‘xml.xsd.customType’. In the latter case rule XXX is applied.
If xml.xsd.type is used, then the type is defined in the W3C xml schema and the typeXmlNsPrefix corresponds to “xsd”.
If xml.mds.type is used, then the type is defined in the namespace of the generated XML schema (“AR”).
UML example «primitive»
String
tags
xml.xsd.type = string
XML schema example
The predefined W3C XML schema data type string is used to represent the primitive class String.
XML instance example
<…. type=”xsd:string” ….>
5.2.8 [TR_APRXML_00026] ⌈Create a custom simple type⌋()
Applies to class with stereotype <<primitive>>
Precondition tagged value ‘xml.xsd.customType=…’
defined
Target pattern
<xsd:simpleType name="<%=xmlName%>--SIMPLE"> <xsd:restriction base="<%=xmlXsdType%>"> <xsd:pattern value="<%=xmlXsdPattern%>"/> </xsd:restriction> </xsd:simpleType> <xsd:complexType name="<%=xmlName%>"> <xsd:simpleContent> <xsd:extension base="AR: <%=xmlName%>--SIMPLE">
<xsd:attributeGroup ref="AR:AR-OBJECT"/> <% if (class has attributes) { %>
<xsd:attributeGroup ref=”<%=xmlName%>” /> <% } // end if (class has attributes) %>
</xsd:extension> </xsd:simpleContent> </xsd:complexType>
Description Each class with stereotype <<primitive>> and tagged value xml.xsd.customType set is represented by two elements in the schema, a custom xsd:simpleType and a xsd:complexType with simple content. The name of the xsd:simpleType maps to the XML-name of the class suffixed by “--SIMPLE", the name of the xsd:complexType maps to XML-name of the class. The base for the simple type is the type defined in the tagged value xml.xsd.type. The restriction pattern is taken from the tagged value xml.xsd.pattern.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
46 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
UML example
XML schema example
<xsd:simpleType name="POSITIVE-INTEGER--SIMPLE"> <xsd:restriction base="xsd:string"> <xsd:pattern value="[1-9][0-9]*|0x[0-9a-f]*|0[0-7]*|0b[0-1]*"/> </xsd:restriction> </xsd:simpleType> <xsd:complexType name="POSITIVE-INTEGER"> <xsd:simpleContent> <xsd:extension base="AR:POSITIVE-INTEGER--SIMPLE"> <xsd:attributeGroup ref="AR:AR-OBJECT"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType>
XML instance example
<…. type=”AR:POSITIVE-INTEGER” ….>
5.2.9 [TR_APRXML_00007] ⌈Create xsd:simpleType for enumeration⌋()
[Tc0008Sc5]
Applies to class with stereotype <<enumeration>>
Precondition n/a
Target pattern
<xsd:simpleType name=”<%=xmlName%>”>
<xsd:restriction base=”xsd:string”>
<% for all attributes { %>
<xsd:enumeration value=”<%=attributeXmlName%>”/>
<%} // end for all attributes %>
</restriction>
</xsd:simpleType>
Description A xsd:simpleType is created for each class which is marked by the stereotype <<enumeration>>. The name of the xsd:element maps to the XML-name of the class. The xsd:simpleType defines an enumeration. The enumeration literals are defined by the property names of the class.
UML example «enumeration»
EnumerationInfoType
+ data:
+ event:
XML schema example
<xsd:simpleType name="ENUMERATION-INFO-TYPE”>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="data"/>
<xsd:enumeration value="event"/>
</xsd:restriction>
</xsd:simpleType>
XML instance example
“data”
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
47 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
5.3 Create composite property representation (mapping to XML attributes) [Tc0009]
5.3.1 [TR_APRXML_00019] ⌈Create xsd:attribute⌋()
Applies to Property
Precondition xml.attribute=true
upper multiplicity of property = 1
Target pattern
<xsd:attribute name=”<%=xmlName%>”
type=”<%=typeXmlNsPrefix%>:<%=typeXmlName%>”
<% if lowerMultiplicity > 0 { %>
use=”required”
<% } else { %>
use=”optional”
<% } %>
/>
Description An xsd:attribute is created for each property with the tagged value ‘xml.attribute=true’. The name of the xsd:attribute is defined by the XML name of the represented property. If the lower multiplicity of the property is bigger than 0 then the use of the attribute is required, otherwise it is optional.
UML example
Identifiable
+ shortName: Identifier
+ longName: String [0..1]
+ category: String [0..1]
+ uuid: String
tagged value of shortName:
xml.enforceMinimumMuiltiplicity
tagged value of uuid:
xml.attribute=true
XML schema example
<xsd:attribute name=”UUID” type=”xsd:string” use=”optional”/>
XML instance example
<…. UUID=”12343-23342-12345-2333”/>
5.4 Create composite property representation (mapping to XML elements) [Tc0010]
Composite properties are properties with ‘aggregation=composite’. If the tagged value ‘xml.attribute=false’ (default), then those properties are mapped to XML-elements. Depending on the values of the tagged values ‘xml.roleWrapperElement’, ‘xml.roleElement’, ‘xml.typeWrapperElement’ and ‘xml.typeElement’ one of the following rules is chosen. All rules that map composite properties to XML elements
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
48 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
are called ‘Composite Property Representation’ extended by a number denoting the settings of the aforementioned tagged values. The first digit reflects the value of ‘xml.roleWrapperElement’, the second digit reflects the value of ‘xml.roleElement’, the third digit reflects the value of ‘xml.typeWrapperElement’ and the last digit reflects the value of ‘xml.typeElement’. Figure 5-3 illustrates how the rules are chosen based on the tagged values.
:Property
xml. *Element ?
[APRXML0008] Create
composite property
representation (1111)
[APRXML0009] Create
composite property
representation (1101)
[APRXML0023] Create
composite property
representation (1100)
[APRXML0022] Create
composite property
representation (1011)
[APRXML0010] Create
composite property
representation (1001)
[APRXML0011] Create
composite property
representation (0111)
[APRXML0012] Create
composite property
representation (0101)
[APRXML0013] Create
composite property
representation (0100)
[APRXML0014] Create
composite property
representation (0011)
[APRXML0015] Create
composite property
representation (0001)
[APRXML0016] Create
composite property
representation (0000)
Error
[xml.roleWrapperElement &&
xml.roleElement && NOT
xml.typeWrapperElement &&
xml.typeElement]
[xml.roleWrapperElement
&& xml.roleElement &&
NOT xml.
typeWrapperElement &&
NOT xml.typeElement]
[xml.roleWrapperElement
&& NOT xml.roleElement
&& xml.
typeWrapperElement &&
xml.typeElement]
[xml.roleWrapperElement
&& NOT xml.roleElement
&& NOT xml.
typeWrapperElement &&
xml.typeElement]
[NOT xml.
roleWrapperElement &&
xml.roleElement && xml.
typeWrapperElement &&
xml.typeElement]
[NOT xml.
roleWrapperElement &&
xml.roleElement && NOT
xml.typeWrapperElement
&& xml.typeElement]
[NOT xml.
roleWrapperElement &&
xml.roleElement && NOT
xml.typeWrapperElement
&& NOT xml.
typeElement]
[NOT xml.
roleWrapperElement &&
NOT xml.roleElement &&
xml.typeWrapperElement
&& xml.typeElement]
[NOT xml.
roleWrapperElement &&
NOT xml.roleElement &&
NOT xml.
typeWrapperElement &&
xml.typeElement]
[NOT xml.
roleWrapperElement &&
NOT xml.roleElement &&
NOT xml.
typeWrapperElement &&
NOT xml.typeElement]
[xml.roleWrapperElement
&& xml.roleElement &&
xml.typeWrapperElement
&& xml.typeElement]
[otherwise]
Figure 5-3: Property representation (aggregation = composite)
Figure 5-4 shows an example meta-model that is used as an example for the following mapping rules. The class ‘A’ owns a property called ‘theB’ which is of type ‘B’. The multiplicity of this property is 0..*. Additionally the class ‘A’ owns a property
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
49 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
called ‘theC’ which is of type ‘C’. The upper multiplicity of ‘theC’ is 1 and the lower multiplicity is 1.
A B
{abstract}
B1
+ attB1: String
B2
+ attB2: String
C
+ attC: String
*
+theB
1+theC
Figure 5-4: Example meta-model of composite property
Figure 5-5 shows an example instance of the meta-model shown in Figure 5-4. This instance is used as a basis for the XML instance examples of the following rules.
:A
:B1
attB1 = someValueB1
:B2
attB2 = someValueB2
:C
attC = someValueC
+theB
+theB
+theC
Figure 5-5: Example instance of composite property
5.4.1 [TR_APRXML_00008] ⌈Create composite property representation⌋()
(1111) [Tc0010Sc1111]
Applies to Property
Precondition xml.roleWrapperElement == true && xml.roleElement == true && xml.typeWrapperElement == true && xml.typeElement == true
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
50 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Target pattern
<xsd:element name="<%=roleXmlNamePlural%>"
minOccurs="<%if (lowerMultiplicity.equals("0"))
{%>0<%} else {%>1<%}%>"
maxOccurs="1”>
<xsd:complexType>
<xsd:choice minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>">
<xsd:element name="<%=roleXmlName%>">
<xsd:complexType>
<xsd:all minOccurs="<%if (lowerMultiplicity.equals("0")) {%>0<%}
else {%>1<%}%>">
<%
for all types {
%>
<xsd:element name="<%=typeXmlNamePlural%>" minOccurs="0"
maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>">
<xsd:element name="<%=typeXmlName%>"
type="<%=typeXmlNsPrefix%>:<%=typeXmlName%>"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<%
} // end for all types
%>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType> </xsd:element>
Description A set of XML elements is created that represent the property:
A role wrapper XML element with maxOccurs=1. The name of the XML element is defined by the xml.namePlural of the property.
Role XML elements are nested within the role wrapper element. The name of these XML-elements is defined by the xml.name of the property. The minimum occurrence of these elements is the lower multiplicity of the property; the maximum occurrence is the upper multiplicity.
For each type and subtype of the property a type wrapper XML element is created. The name of the XML element is defined by the xml.namePlural of the type of the property.
Nested in these type wrappers only elements representing the same types as the type wrapper are allowed.
UML example See above
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
51 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
XML schema example
<xsd:element name="THE-BS" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="THE-B" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:all minOccurs="0">
<xsd:element name="B1S" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="B1" type="AR:B1"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="B2S" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="B2" type="AR:B2"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="THE-CS" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:element name="THE-C" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:all minOccurs="0">
<xsd:element name="CS" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:element name="C" type="AR:C"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
XML instance example
<…>
<THE-BS>
<THE-B>
<B1S>
<B1>
<ATT-B1>someValueB1</ATT-B1>
</B1>
</B1S>
<B2S>
<B2>
<ATT-B2>someValueB2</ATT-B2>
</B2>
</B2S>
</THE-B>
</THE-BS>
<THE-CS>
<THE-C>
<CS>
<C>
<ATT-C>someValueC</ATT-C>
</C>
</CS>
</THE-C>
</THE-CS>
</…>
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
52 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
5.4.2 [TR_APRXML_00009] ⌈Create composite property representation⌋()
(1101) [Tc0010Sc1101]
Applies to Property
Precondition xml.roleWrapperElement == true && xml.roleElement == true && xml.typeWrapperElement == false && xml.typeElement == true
Target pattern
<xsd:element name="<%=roleXmlNamePlural%>"
minOccurs="<%if (lowerMultiplicity.equals("0")) {%>0<%}
else {%>1<%}%>"
maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>">
<xsd:element name="<%=roleXmlName%>">
<xsd:complexType>
<xsd:choice minOccurs="<%=lowerMultiplicity%>" maxOccurs="1">
<%
for all types {
%>
<xsd:element name="<%=typeXmlName%>"
type="<%=typeXmlNsPrefix%>:<%=typeXmlName%>" />
<%
} // end for all types
%>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
Description A set of XML elements is created that represent the property:
A role wrapper XML element with maxOccurs=1. The name of the XML element is defined by the xml.namePlural of the property.
Role XML elements are nested within the role wrapper element. The minimum occurrence of these elements is the lower multiplicity of the property; the maximum occurrence is the upper multiplicity.
Nested in role element at most one XML-element representing the type is allowed.
UML example See above
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
53 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
XML schema example
<xsd:element name="THE-BS" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="THE-B">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:element name="B1" type="AR:B1"/>
<xsd:element name="B2" type="AR:B2"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="THE-CS" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:element name="THE-C">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:element name="C" type="AR:C"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
XML instance example
<…>
<THE-BS>
<THE-B>
<B1>
<ATT-B1>someValueB1</ATT-B1>
</B1>
<B2>
<ATT-B2>someValueB2</ATT-B2>
</B2>
</THE-B>
</THE-BS>
<THE-CS>
<THE-C>
<C>
<ATT-C>someValueC</ATT-C>
</C>
</THE-C>
</THE-CS>
</…>
5.4.3 [TR_APRXML_00023] ⌈Create composite property representation⌋()
(1100) [Tc0010Sc1100]
Applies to Property
Precondition xml.roleWrapperElement == true && xml.roleElement == true && xml.typeWrapperElement == false && xml.typeElement == false
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
54 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Target pattern
<% if ( types.length > 1 ) { %>
<xsd:element name="<%=roleXmlNamePlural%>"
minOccurs="<% if (lowerMultiplicity>0) {%>1<% } else {
%>0<%}%>" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>">
<xsd:element name="<%=roleXmlName%>">
<xsd:complexType>
<xsd:choice minOccurs="<% if (lowerMultiplicity>0) {%>1<% } else {
%>0<%}%>" maxOccurs="1">
<%
for all types {
%>
<xsd:group ref="<%=typeXmlNsPrefix%>:<%=typeXmlName%>"/>
<% } // end for all types %>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<% } else { %>
<xsd:element name="<%=roleXmlNamePlural%>"
minOccurs="<% if (lowerMultiplicity>0) {%>1<% } else {
%>0<%}%>" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>">
<xsd:element name="<%=roleXmlName%>"
type="<%=typeXmlNsPrefix%>:<%=typeXmlName%>"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<% } %>
Description A set of XML elements is created that represent the property:
A role wrapper XML element with maxOccurs=1. The name of the XML element is defined by the xml.namePlural of the property.
Role XML elements are nested within the role wrapper element. The minimum occurrence of these elements is the lower multiplicity of the property; the maximum occurrence is the upper multiplicity. The content model of the type directly shows up within the declaration of this element.
UML example See above
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
55 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
XML schema example
<xsd:element name="THE-BS" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="THE-B">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:group ref="AR:B1"/>
<xsd:group ref="AR:B2"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="THE-CS" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:element name="THE-C" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:group ref="AR:C"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
XML instance example
<…>
<THE-BS>
<THE-B>
<ATT-B1>someValueB1</ATT-B1>
</THE-B>
<THE-B>
<ATT-B2>someValueB2</ATT-B2>
</THE-B>
</THE-BS>
<THE-CS>
<THE-C>
<ATT-C>someValueC</ATT-C>
</THE-C>
</CS>
</THE-CS>
</…>
5.4.4 [TR_APRXML_00022] ⌈Create composite property representation⌋()
(1011) [Tc0010Sc1011]
Applies to Property
Precondition xml.roleWrapperElement == true && xml.roleElement == false && xml.typeWrapperElement == true && xml.typeElement == true
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
56 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Target pattern
<xsd:element name="<%=roleXmlNamePlural%>"
minOccurs="<%if (lowerMultiplicity>0) {%>1<%} else
{%>0<%}%>"
maxOccurs="1">
<xsd:complexType>
<xsd:all minOccurs="<%if (lowerMultiplicity>0) {%>1<%} else {%>0<%}%>"
maxOccurs="<%=types.length%>">
<%
for all types {
%>
<xsd:element name="<%=typeXmlNamePlural%>" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>">
<xsd:element name="<%=typeXmlName%>"
type="<%=typeXmlNsPrefix%>:<%=typeXmlName%>"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<% } // end for all types %>
</xsd:all>
</xsd:complexType>
</xsd:element>
Description A set of XML elements is created that represent the property:
A role wrapper XML element with maxOccurs=1. The name of the XML element is defined by the xml.namePlural of the property.
For each type and subtype of the property a type wrapper XML element is created.
Nested in these type wrappers only elements representing the same types as the type wrapper are allowed.
UML example See above
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
57 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
XML schema example
<xsd:element name="THE-BS" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:all minOccurs="0" maxOccurs="2">
<xsd:element name="B1S" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="B2" type="AR:B2"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="B2S" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="B2" type="AR:B2"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
<xsd:element name="THE-CS" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:all minOccurs="0" maxOccurs="1">
<xsd:element name="CS" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:element name=”C" type="AR:C"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
XML instance example
<…>
<THE-BS>
<B1S>
<B1>
<ATT-B1>someValueB1</ATT-B1>
</B1>
</B1S>
<B2S>
<B2>
<ATT-B2>someValueB2</ATT-B2>
</B2>
</B2S>
</THE-BS>
<THE-CS>
<CS>
<C>
<ATT-C>someValueC</ATT-C>
</C>
</CS>
</THE-CS>
</…>
5.4.5 [TR_APRXML_00010] ⌈Create composite property representation⌋()
(1001) [Tc0010Sc1001]
Applies to Property
Precondition xml.roleWrapperElement == true && xml.roleElement == false && xml.typeWrapperElement == false && xml.typeElement == true
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
58 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Target pattern
<xsd:element name="<%=roleXmlNamePlural%>"
minOccurs="<%if (lowerMultiplicity>0) {%>1<%} else
{%>0<%}%>"
maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>">
<%
for all types {
%>
<xsd:element name="<%=typeXmlName%>"
type="<%=typeXmlNsPrefix%>:<%=typeXmlName%>"/>
<%
} // end for all types
%>
</xsd:choice>
</xsd:complexType>
</xsd:element>
Description A set of XML elements is created that represent the property:
A role wrapper XML element with maxOccurs=1. The name of the XML element is defined by the xml.namePlural of the property.
An XML-element representing the type or subtype of the property. The name of this element is defined by the xml.name of the type of the property.
UML example See above
XML schema example
<xsd:element name="THE-BS" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="B1" type="AR:B1"/>
<xsd:element name="B2" type="AR:B2"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="THE-CS" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:element name="C" type="AR:C"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
XML instance example
<…>
<THE-BS>
<B1>
<ATT-B1>someValueB1</ATT-B1>
</B1>
<B2>
<ATT-B2>someValueB2</ATT-B2>
</B2>
</THE-BS>
<THE-CS>
<C>
<ATT-C>someValueC</ATT-C>
</C>
</THE-CS>
</…>
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
59 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
5.4.6 [TR_APRXML_00011] ⌈Create composite property representation⌋()
(0111) [Tc0010Sc0111]
Applies to Property
Precondition xml.roleWrapperElement == false && xml.roleElement == true && xml.typeWrapperElement == true && xml.typeElement == true
Target pattern
<xsd:element name="<%=roleXmlName%>" minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>">
<xsd:complexType>
<xsd:all minOccurs="<%if (lowerMultiplicity.equals("0")) {%>0<%} else
{%>1<%}%>">
<%
for all types {
%>
<xsd:element name="<%=typeXmlNamePlural%>" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>">
<xsd:element name="<%=typeXmlName%>"
type="<%=typeXmlNsPrefix%>:<%=typeXmlName%>"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<%
} // end for all types
%>
</xsd:all>
</xsd:complexType>
</xsd:element>
Description A set of XML elements is created that represent the property:
XML elements representing the property name. The name of these XML-elements is defined by the xml.name of the property. The minimum occurrence of these elements is the lower multiplicity of the property; the maximum occurrence is the upper multiplicity.
For each type and subtype of the property a type wrapper XML element is created. The name of the XML element is defined by the xml.namePlural of the type of the property.
Nested in these type wrappers only elements representing the same types as the type wrapper are allowed.
UML example See above
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
60 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
XML schema example
<xsd:element name="THE-B" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:all minOccurs="0">
<xsd:element name="B1S" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="B1" type="AR:B1"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="B2S" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="B2" type="AR:B2"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
<xsd:element name="THE-C" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:all minOccurs="0">
<xsd:element name="CS" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:element name="C" type="AR:C"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
XML instance example
<…>
<THE-B>
<B1S>
<B1>
<ATT-B1>someValueB1</ATT-B1>
</B1>
</B1S>
<B2S>
<B2>
<ATT-B2>someValueB2</ATT-B2>
</B2>
</B2S>
</THE-B>
<THE-C>
<CS>
<C>
<ATT-C>someValueC</ATT-C>
</C>
</CS>
</THE-C>
</…>
5.4.7 [TR_APRXML_00012] ⌈Create composite property representation⌋()
(0101) [Tc0010Sc0101]
Applies to Property
Precondition xml.roleWrapperElement == false && xml.roleElement == true && xml.typeWrapperElement == false && xml.typeElement == true
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
61 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Target pattern
<xsd:element name="<%=roleXmlName%>" minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>">
<xsd:complexType>
<xsd:choice minOccurs="<%=lowerMultiplicity%>" maxOccurs="1">
<%
for all types {
%>
<xsd:element name="<%=typeXmlName%>"
type="<%=typeXmlNsPrefix%>:<%=typeXmlName%>"/>
<%
} // end for all types
%>
</xsd:choice>
</xsd:complexType>
</xsd:element>
Description A set of XML elements is created that represent the property:
XML elements representing the property name. The name of these XML-elements is defined by the xml.name of the property. The minimum occurrence of these elements is the lower multiplicity of the property; the maximum occurrence is the upper multiplicity.
Nested in role XML element at most one XML-element representing the type is allowed.
UML example See above
XML schema example
<xsd:element name="THE-B" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:element name="B1" type="AR:B1"/>
<xsd:element name="B2" type="AR:B2"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="THE-C" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:element name="C" type="AR:C"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
XML instance example
<…>
<THE-B>
<B1>
<ATT-B1>someValueB1</ATT-B1>
</B1>
</THE-B>
<THE-B>
<B2>
<ATT-B2>someValueB2</ATT-B2>
</B2>
</THE-B>
<THE-C>
<C>
<ATT-C>someValueC</ATT-C>
</C>
</THE-C>
</…>
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
62 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
5.4.8 [TR_APRXML_00013] ⌈Create composite property representation⌋()
(0100) [Tc0010Sc0100]
Applies to Property
Precondition xml.roleWrapperElement == false && xml.roleElement == true && xml.typeWrapperElement == false && xml.typeElement == false
Target pattern
<%
if (types.length > 1) {
%>
<xsd:element name="<%=roleXmlName%>" minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>">
<xsd:complexType>
<xsd:choice minOccurs="<%=lowerMultiplicity%>" maxOccurs="1">
<%
for all types {
%>
<xsd:group ref="<%=typeXmlNsPrefix%>:<%=typeXmlName%>"/>
<%
} // end for all types
%>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<%
} else {
// NOT type.length >1
%>
<xsd:element name="<%=roleXmlName%>"
type="<%=typeXmlNsPrefix%>:<%=typeXmlName%>"
minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>"/>
<%
}
%>
Description An XML element is created that represents the property:
The name of the XML element is defined by the xml.name of the property. The minimum occurrence of this element is the lower multiplicity of the property; the maximum occurrence is the upper multiplicity. The content model of the type directly shows up within the declaration of this element.
UML example See above
XML schema example
<xsd:element name="THE-B" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:group ref="AR:B1"/>
<xsd:group ref="AR:B2"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="THE-C" type="AR:C" minOccurs="0" maxOccurs="1"/>
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
63 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
XML instance example
<…>
<THE-B>
<ATT-B1>someValueB1</ATT-B1>
</THE-B>
<THE-B>
<ATT-B2>someValueB2</ATT-B2>
</THE-B>
<THE-C>
<ATT-C>someValueC</ATT-C>
</THE-C>
</…>
5.4.9 [TR_APRXML_00014] ⌈Create composite property representation⌋()
(0011) [Tc0010Sc0011]
Applies to Property
Precondition xml.roleWrapperElement == false && xml.roleElement == false && xml.typeWrapperElement == true && xml.typeElement == true
Target pattern
<%
for all types {
%>
<xsd:element name="<%=typeXmlNamePlural%>"
minOccurs="<%if (lowerMultiplicity>0) {%>1<%} else
{%>0<%}%>"
maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>">
<xsd:element name="<%=typeXmlName%>"
type="<%=typeXmlNsPrefix%>:<%=typeXmlName%>"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<%
} // end for all types
%>
Description A set of XML elements is created that represent the property:
For each type and subtype of the property a type wrapper XML element is created. The name of the XML element is defined by the xml.namePlural of the type of the property.
Nested in these type wrappers only elements representing the same types as the type wrapper are allowed.
UML example See above
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
64 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
XML schema example
<xsd:element name="B1S" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="B1" type="AR:B1"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="B2S" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="B2" type="AR:B2"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="CS" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:element name="C" type="AR:C"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
XML instance example
<…>
<B1S>
<B1>
<ATT-B1>someValueB1</ATT-B1>
</B1>
</B1S>
<B2S>
<B2>
<ATT-B2>someValueB2</ATT-B2>
</B2>
</B2S>
<CS>
<C>
<ATT-C>someValueC</ATT-C>
</C>
</CS>
</…>
5.4.10 [TR_APRXML_00015] ⌈Create composite property representation⌋()
(0001) [Tc0010Sc0001]
Applies to Property
Precondition xml.roleWrapperElement == false && xml.roleElement == false && xml.typeWrapperElement == false && xml.typeElement == true
Target pattern
<xsd:choice minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>">
<%
for all types {
%>
<xsd:element name="<%=typeXmlName%>"
type="<%=typeXmlNsPrefix%>:<%=typeXmlName%>"/>
<%
} // end for all types
%>
</xsd:choice>
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
65 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Description An XML element is created that represents the property:
The name of the XML element is defined by the xml.name of the type of the property. The minimum occurrence of this element is the lower multiplicity of the property; the maximum occurrence is the upper multiplicity. The content model of the type directly shows up within the declaration of this element.
UML example See above
XML schema example
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="B1" type="AR:B1"/>
<xsd:element name="B2" type="AR:B2"/>
</xsd:choice>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:element name="C" type="AR:C"/>
</xsd:choice>
XML instance example
<…>
<B1>
<ATT-B1>someValueB1</ATT-B1>
</B1>
<B2>
<ATT-B2>someValueB2</ATT-B2>
</B2>
<C>
<ATT-C>someValueC</ATT-C>
</C>
</…>
5.4.11 [TR_APRXML_00016] ⌈Create composite property representation⌋()
(0000) [Tc0010Sc0000]
Applies to Property
Precondition xml.roleWrapperElement == false && xml.roleElement == false && xml.typeWrapperElement == false && xml.typeElement == false
Target pattern
<xsd:choice minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>">
<%
for all types {
%>
<xsd:group ref="<%=typeXmlNsPrefix%>:<%=typeXmlName%>"/>
<%
} // end for all types
%>
</xsd:choice>
Description No XML element is defined for the property. The content model of the type and all subtypes of the property is inserted directly in the xsd:group that represents the class that owns the property.
UML example See above
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
66 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
XML schema example
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:group ref="AR:B1"/>
<xsd:group ref="AR:B2"/>
</xsd:choice>
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:group ref="AR:C"/>
</xsd:choice>
XML instance example
<…>
<ATT-B1>someValueB1</ATT-B1>
<ATT-B2>someValueB2</ATT-B2>
<ATT-C>someValueC</ATT-C>
</…>
5.5 Create reference representation [Tc0012]
Figure 5-6 shows an overview on mapping rules for references (properties with aggregation=none). References are always mapped to XML-elements. If the tagged value xml.propertyWrapperElement=true is applied to the property, then a wrapper element is created for the reference.
:Property
propertyWrapper?
ActivityFinal
[APRXML0017] Create
reference property (1)[APRXML0018] Create
reference property (0)
[NOT propertyWrapperElement][propertyWrapperElement]
Figure 5-6: Property representation (aggregation = none)
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
67 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Figure 5-7 shows an example meta-model that uses a reference. This example is used to illustrate the following two mapping rules.
DIdentifiable
B
{abstract}
B1
+ attB1: String
B2
+ attB2: String
0..*
+theB
Figure 5-7: Example meta-model using a reference
Figure 5-8 shows an example instance of a reference. This example is used to illustrate the following two mapping rules.
:D
:B1
shortName = instance1
attB1 = someValueB1
:B2
shortName = instance2
attB2 = someValueB2
+theB
+theB
Figure 5-8: Example instance of reference
5.5.1 [TR_APRXML_00017] ⌈Create reference property representation (1)
⌋()[Tc0012Sc1]
Applies to Property
Precondition xml.roleWrapperElement=true
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
68 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Target pattern
<xsd:element name="<%=roleXmlNamePlural%>" minOccurs="<%=lowerMultiplicity%>"
maxOccurs="1">
<xsd:complexType>
<xsd:choice minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>">
<xsd:element name="<%=roleXmlName%>">
</xsd:complexType>
<xsd:simpleContent>
<xsd:extension base=”AR:REF”>
<xsd:attribute name=”DEST”
type=”<%=typeXmlNsPrefix%>:<%=typeXmlName%>-
-SUBTYPE-ENUM”
use=”required”/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
Description The following XML-elements represent a property (if aggregation=none):
A XML element that wraps several XML-element of the same XML-name. The name of the wrapper is defined by the xml.namePlural of the property. Please not the default xml.namePlural is defined by the default singular XML name appended by “-REFS”, “-TREFS” (see section 4.2.3).
An XML element that represents the reference itself. The name of this element is defined by the xml.name of the property. Please not the default xml.name is defined by the default singular XML name appended by “-REF”, “-TREF” (see section 4.2.3).
UML example See above
XML schema example
<xsd:element name=”THE-B-REFS” >
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name=”THE-B-REF” type=”AR:REF”
minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base=”AR:REF”>
<xsd:attribute name=”DEST”
type=”B--SUBTYPES-ENUM”
use=”required”/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
XML instance example
<…>
<THE-B-REFS>
<THE-B-REF DEST=”B-1”>instance1</THE-B-REF>
<THE-B-REF DEST=”B-2”>instance2</THE-B-REF>
</THE-B-REFS>
</…>
5.5.2 [TR_APRXML_00018] ⌈Create reference property representation (0)
⌋()[Tc0012Sc2]
Applies to Property
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
69 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
Precondition Xml.roleWrapperElement=false
Target pattern
<xsd:element name="<%=roleXmlName%>"
minOccurs="<%=lowerMultiplicity%>"
maxOccurs="<%=upperMultiplicity%>">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base=”AR:REF”>
<xsd:attribute name=”DEST”
type=”<%=typeXmlNsPrefix%>:<%=typeXmlName%>-
-SUBTYPES-ENUM”
use=”required”/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
Description An XML element represents the reference. The name of this element is defined by the xml.name of the property. Please not the default xml.name is defined by the default singular XML name appended by “-REF”, “-TREF” (see section 4.2.3).
UML example See above
XML schema example
<xsd:element name=”THE-B-REF” type=”AR:REF”
minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base=”AR:REF”>
<xsd:attribute name=”DEST”
type=”B--SUBTYPES-ENUM”
use=”required”/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
XML instance example
<…>
<THE-B-REF DEST=”B-1”>instance1</THE-B-REF>
<THE-B-REF DEST=”B-2”>instance2</THE-B-REF>
</…>
5.5.3 [TR_APRXML_00027] ⌈Create a reference to attributes in foreign
namespaces⌋()
Applies to Property
Precondition xml.attributeRef=true
Target pattern
<xsd:attribute ref="<%=nsPrefix%>:<%=xmlName%>"/>
Description An XML attribute that references attributes from foreign namespaces, e.g. the XML namespace. The name of the reference is defined by the xml.name of the property concatenated after the namespace prefix. Currently, only the XML namespace (nsPrefix=xml) is allowed.
UML example
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
70 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
XML schema example
<xsd:attributeGroup name="WHITESPACE-CONTROLLED">
<xsd:attribute ref="xml:space" use="required">
<xsd:annotation>
<xsd:documentation>This attrbute is used to signal an intention that
in that element, white space should be preserved by applications. It is
defined according to xml:space as declared by W3C.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:attributeGroup>
XML instance example
<ADMIN-DATA>
<LANGUAGE>EN</LANGUAGE>
<USED-LANGUAGES>
<L-10 L="EN" xml:space="default">English</L-10>
</USED-LANGUAGES>
</ADMIN-DATA>
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
71 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
6 XML description production
6.1 Introduction
This chapter specifies rules for the serialization of AUTOSAR models (instances of the AUTOSAR meta-model) to AUTOSAR XML descriptions. The inverse of these rules can be applied to an AUTOSAR XML description to reconstruct the AUTOSAR model. The production rules are provided as a specification of the AUTOSAR XML description production and consumption process. They should not be viewed as prescribing any particular algorithm for XML producer or consumer implementations.
6.2 Overall document structure
The AUTOSAR XML schema is monolithic and defines one single XML namespace (http://autosar.org/schema/r<major>.<minor>) for all its XML elements and XML attributes. <major> and <minor> can be arbitrary non-negative integers (that do not need to be related to the major and minor version number of the AUTOSAR standard or any AUTOSAR document). The namespace is kept across multiple releases of the AUTOSAR XML schema as long as backward compatibility is kept. Additionally, the AUTOSAR XML schema does not contain any anchor for integrating XML elements or attributes defined in other XML schemas or XML namespaces3. In order to simplify the implementation of the first AUTOSAR tools, the AUTOSAR XML namespace (http://autosar.org/schema/r<major>.<minor>) SHALL be used as the default XML namespace4. Additionally the AUTOSAR XML descriptions SHALL be UTF-8 encoded. AUTOSAR XML descriptions SHALL use the following XML document header. The namespace contains information of the AUTOSAR release. Encoding the release information into the namespace allows for parallel use of different versions of XML schema and XML descriptions. E.g. the XML namespace http://autosar.org/schema/r4.0 corresponds to the AUTOSAR XML schema of the AUTOSAR release 4.0. <?xml version="1.0" encoding="UTF-8"?>
<AUTOSAR xmlns=”http://autosar.org/schema/r4.0”
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://autosar.org/schema/r4.0 autosar_4-0-3.xsd">
<!—the topLevelPackages go here -->
3 The only exception is the namespace http://www.w3.org/2001/XMLSchema-instance and the
namespace prefix xsi. 4 It is highly recommended to support the XML namespace concepts for tools that are intended to
interpret or produce AUTOSAR XML descriptions. Later versions of the AUTOSAR XML schema might be more modular and might use more than one XML namespace.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
72 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
</AUTOSAR>
AUTOSAR XML descriptions may be shipped with or without the AUTOSAR XML schema. Therefore all AUTOSAR tools that validate AUTOSAR XML descriptions against the AUTOSAR XML schema SHALL have their own copy of the supported AUTOSAR XML schema. They SHALL be able to find their local copy of the XML schema by evaluating xsi:schemaLocation field in the AUTOSAR XML description. xsi:schemaLocation thereby denotes the release of the schema which was used to create the document. In other words:
The field xsi:schemaLocation is mandatory
AUTOSAR tools SHALL continue interpreting AUTOSAR XML descriptions even if the path defined in the xsi:schemaLocation is not valid.
More details can be found in [2].
6.3 Linking
Linking and details of shortname references, including absolute and relative shortname-paths is described in the Generic Structure Template [19].
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
73 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
7 Compliance
7.1 AUTOSAR XML schema compliance
AUTOSAR XML Schemas must be equivalent to those generated by the AUTOSAR XML Schema production rules specified in this document. Equivalence means that:
XML documents that are valid under the AUTOSAR XML Schema would be valid in a conforming XML Schema
and that those XML documents that are not valid under the AUTOSAR XML Schema are not valid in a conforming XML Schema.
7.2 AUTOSAR XML document compliance
The XML document must be “valid” and “well-formed” as defined by the XML recommendation, whether used with or without the document’s corresponding AUTOSAR XML Schema(s). Although it is optional not to transmit and/or validate a document with its AUTOSAR XML Schema(s), the document must still conform as if the check had been made.
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
74 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
8 References
8.1 Normative references to AUTOSAR documents
[1] Glossary AUTOSAR_TR_Glossary.pdf.
[2] Specification of Interoperability of AUTOSAR Tools AUTOSAR_TR_InteroperabilityOfAutosarTools.pdf
[3] Meta-model, AUTOSAR_MMOD_MetaModel.EAP
[19] Generic Structure Template AUTOSAR_TPS_GenericStructureTemplate.pdf
8.2 Normative references to external documents
[5] XML Metadata Interchange (XMI) Specification version 2.1,
http://www.omg.org/cgi-bin/apps/doc?formal/05-09-01.pdf
[6] XML Metadata Interchange (XMI) Specification version 1.2, http://www.omg.org/cgi-bin/apps/doc?formal/02-01-01.pdf
[7] XML Information Set (Second Edition), W3C Recommendation 4 February 2004, http://www.w3.org/TR/xml-infoset/
[8] XML Schema 1.1, http://www.w3.org/XML/Schema
[9] Extensible Markup Language (XML) 1.1, http://www.w3.org/TR/xml11/
[10] Namespaces in XML 1.1, W3C Recommendation 4 February 2004, http://www.w3.org/TR/xml-names11/
[11] MSR-TR-CAP, http://www.msr-wg.de/medoc/download/msr-tr-cap/msr-tr-cap.pdf
[12] MSR-SW, http://www.msr-wg.de/medoc/download/msrsw/v230/msrsw_v230-eadoc-en/msrsw_v2_3_0.sl-eadoc.pdf
[13] XHTML, http://www.w3.org/TR/xhtml11/
[14] Unified Modeling Language: Superstructure, Version 2.0, OMG Available Specification, ptc/05-07-04. http://www.omg.org/cgi-bin/apps/doc?formal/05-07-04.pdf
[15] Unified Modeling Language: Infrastructure, Version 2.0. OMG Adopted Specification, ptc/03-09-15. http://www.omg.org/cgi-bin/apps/doc?ptc/03-09-15.pdf
Model Persistence Rules for XML V2.7.0
R4.1 Rev 3
75 of 75 Document ID 122: AUTOSAR_TR_XMLPersistenceRules
- AUTOSAR Confidential -
[16] Unified Modeling Language OCL, Version 2.0, OMG Available Specification, ptc/05-06-06. http://www.omg.org/cgi-bin/apps/doc?ptc/05-06-06.pdf
[17] Meta-Object Facility MOF, Version 2.0, OMG Available Specification, ptc/04-10-15. http://www.omg.org/cgi-bin/apps/doc?ptc/04-10-15.pdf
8.3 Other references
[18] Carlson, David; Modeling XML Applications with UML, Practical e-Business Applications; Addison Wesley; 2001.