Importing and Exporting AUTOSAR XML files

You can import AUTOSAR XML files into a new or existing Rhapsody® model, and you can export the data from your model to one or more AUTOSAR XML files. Import and export of AUTOSAR XML files can also be done from the command line.

To import one or more AUTOSAR XML files:

  1. From the main menu, select Tools > AUTOSAR > Import AUTOSAR XML Document.
  2. Click Browse to select the file or files to import.
    Note: You can select individual AUTOSAR XML files or select a .lst file that lists the files to import.
  3. Specify whether all ARPackages in the file should be imported, or only selected packages.
    Note: If you choose to import only selected packages, the xml file is analyzed and then you are presented with a list of packages to choose from.
  4. Select an import policy
    • Update existing model elements and add new ARXML content - information for existing elements is updated from the ARXML content, and new elements are created for new content.
    • Replace existing model elements with new ARXML content - elements are created from scratch based on the ARXML content. This means that only elements that are represented in the ARXML file will remain in the model.
    • Add to model only missing ARXML content - new elements are created for new content, but information for existing model elements is not updated from the ARXML.
    • Add ARXML content as new Top-Level ARPackages - new ARPackages are created at the highest lever to represent the ARXML content, and the existing packages are kept as they are
  5. Specify whether to use splittable definitions. If you select this option, it will be easier to later export the model information to multiple xml files.
  6. Specify whether schema validation should be performed. If yes, use the Add... button to select one or more schemas to use. If you select this option, validation is performed before the import is performed, and a warning is displayed if there are validation problems. In any case, the file will be imported into the model.
  7. Click Import.

To export model data to an AUTOSAR XML file:

  1. From the main menu, select Tools > AUTOSAR > Export AUTOSAR XML Document.
  2. Click Browse to select the file to which the data should be exported.
  3. Specify whether splittable definitions should be used. If your model contains file-splitting information, this option will export the model data to multiple xml files.
  4. Specify whether schema validation should be performed. If yes, use the Add... button to select one or more schemas to use. If you select this option, validation will be performed after the information has been exported, and a warning will be displayed if there are validation problems.
  5. Click Export.

Importing and exporting AUTOSAR XML files from the command line

In addition to the GUI that is provided, you can import AUTOSAR XML files or export AUTOSAR XML data from the command line.

Syntax for importing AUTOSAR XML data into a model:

rhapsody.exe <name of project> -cmd=call_extended "AUTOSAR XML Plugin" "import -file <name of file>"

For example:

rhapsody.exe "L:\Simple403Project.rpyx" -cmd=call_extended "AUTOSAR XML Plugin" "import -file 'C:\in.arxml'"

Note that -file can take one or more file paths, separated by semicolons. The paths can include spaces.

The following options can be added to the import command:

  • -splittableDefinitions - to import information that is required to later export model to multiple XML files - value can be True or False (if no option is selected, True is assumed)
  • -ImportPolicy <policy> - how information should be integrated into the model, must be one of the following values:
    • Update existing model elements and add new ARXML content (this is the value that is used if the option is not included in the command)
    • Replace existing model elements with ARXML content
    • Add to model only missing ARXML content
    • Add ARXML content as new Top-Level ARPackages
  • -validationSchemas - list of schema files that should be used to check the files that are being imported. Can be a single schema file or multiple files separated by a semicolon.
  • -typesAsSeparateSavedUnit - the element types that should be saved as separate units when the files are imported into the model. The value for this option should be a comma-separated list of types from the list defined in the property Model::Importer::TypesAsSeparateSavedUnit, for example, -typesAsSeparateSavedUnit 'ARPackage,ECUExtractPackage'
  • -ecuExtractPackageName - option to have all the imported information stored in a separate package when importing an ECU extract. The value for this option should be the name that you want to use for the package, for example, -ecuExtractPackageName 'ImportedElements'

For example:

rhapsody.exe "L:\Simple403Project.rpyx" -cmd=call_extended "AUTOSAR XML Plugin" "import -file 'C:\in.arxml' -splittableDefinitions False -ImportPolicy 'Add ARXML content as new Top-Level ARPackages' -validationSchemas 'c:\schemas\AUTOSAR_4-2-2.xsd;c:\schemas\xml.xsd'"

Syntax for exporting AUTOSAR XML data from a model:

rhapsody.exe <name of project> -cmd=call_extended "AUTOSAR XML Plugin" "export -file <name of file to export to>"

Note that the-file argument can specify a path that contains spaces.

For example:

rhapsody.exe "L:\Simple403Project.rpyx" -cmd=call_extended "AUTOSAR XML Plugin" "export -file 'C:\out.arxml'"

The following options can be added to the export command:

  • -splittableDefinitions - use this option if you want to split the model information into multiple xml files, value can be True or False (if no option is selected, True is assumed)
    Note: When using the -splittableDefinitions option, the file that is specified by the -file argument in the command is used for model elements that do not have a target export file set. The path that is specified with the -file argument is also used to determine the directory for the other output files that are generated.
  • -validationSchemas - list of schema files that should be used to check the files that are created during export. Can be a single schema file or multiple files separated by a semicolon.

For example:

rhapsody.exe "L:\Simple403Project.rpyx" -cmd=call_extended "AUTOSAR XML Plugin" "export -file 'C:\out.arxml' -splittableDefinitions False -validationSchemas 'c:\schemas\AUTOSAR_4-2-2.xsd;c:\schemas\xml.xsd'"