LCOV - code coverage report
Current view: top level - io/source/xmi - xmi_element_writer.c (source / functions) Coverage Total Hit
Test: crystal-facet-uml_v1.63.2_covts Lines: 0.0 % 764 0
Test Date: 2025-05-01 10:10:14 Functions: 0.0 % 29 0

            Line data    Source code
       1              : /* File: xmi_element_writer.c; Copyright and License: see below */
       2              : 
       3              : #include "xmi/xmi_element_writer.h"
       4              : #include "xmi/xmi_element_info_map.h"
       5              : #include "xmi/xmi_element_info.h"
       6              : #include "xmi/xmi_element_part.h"
       7              : #include "xmi/xmi_xml.h"
       8              : #include "utf8stringbuf/utf8string.h"
       9              : #include "utf8stringbuf/utf8stringview.h"
      10              : #include "utf8stringbuf/utf8stringviewiterator.h"
      11              : #include "entity/data_id.h"
      12              : #include "meta/meta_version.h"
      13              : #include "meta/meta_info.h"
      14              : #include "u8/u8_trace.h"
      15              : #include "u8/u8_log.h"
      16              : #include <stdio.h>
      17              : #include <stdbool.h>
      18              : #include <assert.h>
      19              : 
      20              : #define io_element_writer_impl_t xmi_element_writer_t
      21              : /*!
      22              :  *  \brief A struct of function pointers which is the interface of an io_element_writer
      23              :  *
      24              :  *  To avoid typecasts, this struct provides function pointers with the exact right signatures
      25              :  *  provided via io_element_writer_impl_t
      26              :  */
      27              : struct xmi_element_writer_io_element_writer_if_struct {
      28              : #include "io_element_writer_if.inl"
      29              : };
      30              : #undef io_element_writer_impl_t
      31              : 
      32              : /* the vmt implementing the interface */
      33              : static const struct xmi_element_writer_io_element_writer_if_struct xmi_element_writer_private_io_element_writer_if
      34              :     = {
      35              :         .write_header = &xmi_element_writer_write_header,
      36              :         .start_main = &xmi_element_writer_start_main,
      37              :         .can_classifier_nest_classifier = &xmi_element_writer_can_classifier_nest_classifier,
      38              :         .can_classifier_nest_relationship = &xmi_element_writer_can_classifier_nest_relationship,
      39              :         .start_classifier = &xmi_element_writer_start_classifier,
      40              :         .assemble_classifier = &xmi_element_writer_assemble_classifier,
      41              :         .end_classifier = &xmi_element_writer_end_classifier,
      42              :         .start_feature = &xmi_element_writer_start_feature,
      43              :         .assemble_feature = &xmi_element_writer_assemble_feature,
      44              :         .end_feature = &xmi_element_writer_end_feature,
      45              :         .start_relationship = &xmi_element_writer_start_relationship,
      46              :         .assemble_relationship = &xmi_element_writer_assemble_relationship,
      47              :         .end_relationship = &xmi_element_writer_end_relationship,
      48              :         .start_diagram = &xmi_element_writer_start_diagram,
      49              :         .assemble_diagram = &xmi_element_writer_assemble_diagram,
      50              :         .end_diagram = &xmi_element_writer_end_diagram,
      51              :         .start_diagramelement = &xmi_element_writer_start_diagramelement,
      52              :         .assemble_diagramelement = &xmi_element_writer_assemble_diagramelement,
      53              :         .end_diagramelement = &xmi_element_writer_end_diagramelement,
      54              :         .end_main = &xmi_element_writer_end_main,
      55              :         .write_footer = &xmi_element_writer_write_footer
      56              :     };
      57              : 
      58              : /* GENERAL STRUCTURE */
      59              : 
      60              : /*
      61              :  *    <THING>_START
      62              :  *    <THING>_MIDDLE            #optional, if dynamic content needs to be added to the start
      63              :  *    <THING>_TITLE_START       #alternative to TITLE: NAME
      64              :  *    <THING>_TITLE_END         #alternative to TITLE: NAME
      65              :  *    ...                       #optional text
      66              :  *    <THING>_<OTHERSUB>_START  #optional if there ore other sub-things
      67              :  *    <THING>_<OTHERSUB>_END    #optional if there ore other sub-things
      68              :  *    <THING>_END
      69              :  */
      70              : 
      71              : /* Note: when writing, each method typically starts with writing a newline, it does not end with writing a newline. */
      72              : 
      73              : /* IO_FILE_FORMAT_XMI2 */
      74              : 
      75              : static const char XMI2_ENC[]
      76              :     = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>";
      77              : /* spec-ref: https://www.omg.org/spec/XMI/2.5.1/PDF chapter 9.5.1 : 1,1a,1e,1f */
      78              : /* spec-ref: https://www.omg.org/spec/UML/2.5.1/PDF chapter 12.3.3.1.3 */
      79              : /* spec-ref: https://www.omg.org/spec/SysML/1.6/PDF chapter G.3 */
      80              : /* spec-ref: https://www.omg.org/spec/MOF/2.5.1/PDF annex A */
      81              : //static const char XMI2_DOC_START[]
      82              : //    = "\n<xmi:XMI xmlns:xmi=\"http://www.omg.org/spec/XMI/20131001\""
      83              : //      "\n         xmlns:uml=\"http://www.omg.org/spec/UML/20161101\""
      84              : //      "\n         xmlns:SysML=\"http://www.omg.org/spec/SysML/20181001\">"
      85              : //      "\n         <!-- XMI 2.5.1, UML 2.5.1, SysML 1.6 -->";
      86              : static const char XMI2_DOC_START[]
      87              :     = "\n<xmi:XMI xmlns:uml=\"http://www.omg.org/spec/UML/20110701\""
      88              :       "\n         xmlns:StandardProfile=\"http://www.omg.org/spec/UML/20131001/StandardProfile\""
      89              :       "\n         xmlns:xmi=\"http://www.omg.org/spec/XMI/20110701\""
      90              :       "\n         xmlns:SysML=\"http://www.omg.org/spec/SysML/20131001/SysML.xmi\""
      91              :       "\n         xmlns:mofext=\"http://www.omg.org/spec/MOF/20131001\""
      92              :       "\n         xmlns:LocalProfile=\"http://localhost/crystal-facet-uml/298b72db-cc85-4ed0-bd7b-01dc4efd52b4\">"
      93              :       "\n         <!-- XMI 2.4.1, UML 2.4.1, SysML 1.4, MOF 2.5.1 -->";
      94              : /* spec-ref: https://www.omg.org/spec/XMI/2.5.1/PDF chapter 9.5.1 : 1,1a */
      95              : static const char XMI2_DOC_END[]
      96              :     = "\n</xmi:XMI>";
      97              : /* spec-ref: https://www.omg.org/spec/XMI/2.5.1/PDF chapter 7.5.3 + 7.5.5 */
      98              : static const char XMI2_DOC_METAINFO_START[]
      99              :     = "\n<xmi:Documentation exporter=\"";
     100              : /* spec-ref: https://www.omg.org/spec/XMI/2.5.1/PDF chapter 7.5.3 + 7.5.5 */
     101              : static const char XMI2_DOC_METAINFO_MIDDLE[]
     102              :     = "\" exporterVersion=\"";
     103              : /* spec-ref: https://www.omg.org/spec/XMI/2.5.1/PDF chapter 7.5.3 + 7.5.5 */
     104              : static const char XMI2_DOC_METAINFO_END[]
     105              :     = "\"/>";
     106              : 
     107              : /* spec-ref: https://www.omg.org/spec/UML/2.5.1/PDF chapter 12.2.2, 12.3.5 */
     108              : /* spec: https://www.omg.org/spec/UML/20161101/UML.xmi (v2.5.1) pkg: Packages */
     109              : static const char XMI2_UML_MODEL_START[]
     110              :     = "\n<uml:Model xmi:type=\"uml:Model\" xmi:id=\"00000\" ";
     111              : static const char XMI2_UML_MODEL_MIDDLE[]
     112              :     = ">";
     113              : static const char XMI2_UML_MODEL_END[]
     114              :     = "\n</uml:Model>";
     115              : 
     116              : /* spec-ref: https://www.omg.org/spec/UML/2.5.1/PDF chapter 7.8.2 */
     117              : static const char XMI2_UML_COMMENT_BODY_START[]
     118              :     = "\n<body>";
     119              : static const char XMI2_UML_COMMENT_BODY_END[]
     120              :     = "\n</body>";
     121              : 
     122              : /* spec: https://www.omg.org/spec/SysML/20181001/SysML.xmi (v1.6) pkg: all */
     123              : static const char XMI2_EXT_BASE_ELEMENT_START[]
     124              :     = "base_";
     125              : static const char XMI2_EXT_BASE_ELEMENT_MIDDLE[]
     126              :     = "=\"";
     127              : static const char XMI2_EXT_BASE_ELEMENT_END[]
     128              :     = "\" ";
     129              : 
     130              : static const char XMI2_STATE_REGION_NESTING_STATE[]
     131              :     = "region";
     132              : static const char XMI2_STATE_REGION_TYPE[]
     133              :     = "Region";
     134              : 
     135            0 : void xmi_element_writer_init ( xmi_element_writer_t *this_,
     136              :                                data_stat_t *io_export_stat,
     137              :                                universal_output_stream_t *output )
     138              : {
     139            0 :     U8_TRACE_BEGIN();
     140            0 :     assert( NULL != output );
     141            0 :     assert( NULL != io_export_stat );
     142              : 
     143            0 :     (*this_).mode = XMI_WRITER_PASS_BASE;
     144            0 :     (*this_).export_stat = io_export_stat;
     145              : 
     146            0 :     io_element_writer_private_init( &((*this_).element_writer),
     147              :                                     (io_element_writer_if_t*) &xmi_element_writer_private_io_element_writer_if,
     148              :                                     this_
     149              :                                   );
     150            0 :     io_xml_writer_init( &((*this_).xml_writer), output );
     151            0 :     xmi_type_converter_init( &((*this_).xmi_types) );
     152            0 :     xmi_atom_writer_init( &((*this_).atom_writer), &((*this_).xml_writer) );
     153              : 
     154            0 :     xmi_interaction_writer_init( &((*this_).interaction_writer),
     155              :                                  io_export_stat,
     156              :                                  &((*this_).xml_writer)
     157              :                                );
     158              : 
     159            0 :     U8_TRACE_END();
     160            0 : }
     161              : 
     162            0 : void xmi_element_writer_destroy( xmi_element_writer_t *this_ )
     163              : {
     164            0 :     U8_TRACE_BEGIN();
     165              : 
     166            0 :     xmi_interaction_writer_destroy( &((*this_).interaction_writer) );
     167              : 
     168            0 :     xmi_atom_writer_destroy( &((*this_).atom_writer) );
     169            0 :     xmi_type_converter_destroy( &((*this_).xmi_types) );
     170            0 :     io_xml_writer_destroy( &((*this_).xml_writer) );
     171            0 :     io_element_writer_private_destroy( &((*this_).element_writer) );
     172              : 
     173            0 :     U8_TRACE_END();
     174            0 : }
     175              : 
     176            0 : io_element_writer_t * xmi_element_writer_get_element_writer( xmi_element_writer_t *this_ )
     177              : {
     178            0 :     U8_TRACE_BEGIN();
     179              : 
     180            0 :     io_element_writer_t * base = &((*this_).element_writer);
     181              : 
     182            0 :     U8_TRACE_END();
     183            0 :     return base;
     184              : }
     185              : 
     186            0 : void xmi_element_writer_set_mode( xmi_element_writer_t *this_, xmi_writer_pass_t mode )
     187              : {
     188            0 :     U8_TRACE_BEGIN();
     189              : 
     190            0 :     U8_TRACE_INFO_STR("mode:", (mode==XMI_WRITER_PASS_BASE) ? "XMI_WRITER_PASS_BASE" : "XMI_WRITER_PASS_PROFILE");
     191            0 :     (*this_).mode = mode;
     192              : 
     193            0 :     U8_TRACE_END();
     194            0 : }
     195              : 
     196            0 : u8_error_t xmi_element_writer_write_header( xmi_element_writer_t *this_, const char *document_title )
     197              : {
     198            0 :     U8_TRACE_BEGIN();
     199            0 :     assert ( NULL != document_title );
     200            0 :     u8_error_t export_err = U8_ERROR_NONE;
     201              : 
     202            0 :     io_xml_writer_reset_indent ( &((*this_).xml_writer) );
     203              : 
     204              :     /* xml header */
     205            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_ENC );
     206            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_DOC_START );
     207              :     /* meta info */
     208            0 :     io_xml_writer_increase_indent ( &((*this_).xml_writer) );
     209            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_DOC_METAINFO_START );
     210            0 :     export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), META_INFO_PROGRAM_ID_STR );
     211            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_DOC_METAINFO_MIDDLE );
     212            0 :     export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), META_VERSION_STR );
     213            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_DOC_METAINFO_END );
     214              : 
     215            0 :     U8_TRACE_END_ERR( export_err );
     216            0 :     return export_err;
     217              : }
     218              : 
     219            0 : u8_error_t xmi_element_writer_start_main( xmi_element_writer_t *this_, const char *document_title )
     220              : {
     221            0 :     U8_TRACE_BEGIN();
     222            0 :     u8_error_t export_err = U8_ERROR_NONE;
     223              : 
     224              :     /* uml model */
     225            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_UML_MODEL_START );
     226            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_NAME_START );
     227            0 :     export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), document_title );
     228            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_NAME_END );
     229            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_UML_MODEL_MIDDLE );
     230            0 :     io_xml_writer_increase_indent ( &((*this_).xml_writer) );
     231              : 
     232            0 :     U8_TRACE_END_ERR( export_err );
     233            0 :     return export_err;
     234              : }
     235              : 
     236            0 : bool xmi_element_writer_can_classifier_nest_classifier ( xmi_element_writer_t *this_,
     237              :                                                          data_classifier_type_t host_type,
     238              :                                                          data_classifier_type_t child_type )
     239              : {
     240            0 :     const bool base_pass = ( XMI_WRITER_PASS_BASE == (*this_).mode );
     241            0 :     const bool can_nest = xmi_type_converter_can_nest_classifier( &((*this_).xmi_types), host_type, child_type );
     242            0 :     return ( can_nest && base_pass );
     243              : }
     244              : 
     245            0 : bool xmi_element_writer_can_classifier_nest_relationship ( xmi_element_writer_t *this_,
     246              :                                                            data_classifier_type_t host_type,
     247              :                                                            data_relationship_type_t child_type )
     248              : {
     249            0 :     const bool base_pass = ( XMI_WRITER_PASS_BASE == (*this_).mode );
     250            0 :     const bool can_nest = xmi_type_converter_can_nest_relationship( &((*this_).xmi_types), host_type, child_type );
     251            0 :     return ( can_nest && base_pass );
     252              : }
     253              : 
     254            0 : u8_error_t xmi_element_writer_start_classifier( xmi_element_writer_t *this_,
     255              :                                                 data_classifier_type_t host_type,
     256              :                                                 const data_classifier_t *classifier_ptr )
     257              : {
     258            0 :     U8_TRACE_BEGIN();
     259            0 :     assert ( NULL != classifier_ptr );
     260            0 :     u8_error_t export_err = U8_ERROR_NONE;
     261              : 
     262            0 :     const data_id_t classifier_id = data_classifier_get_data_id(classifier_ptr);
     263            0 :     const data_classifier_type_t classifier_type = data_classifier_get_main_type(classifier_ptr);
     264              :     const xmi_element_info_t *classifier_info;
     265            0 :     const u8_error_t map_err = xmi_element_info_map_get_classifier( &xmi_element_info_map_standard,
     266              :                                                                     host_type,
     267              :                                                                     classifier_type,
     268              :                                                                     &classifier_info
     269              :                                                                   );
     270            0 :     U8_TRACE_INFO_STR("xmi_element_info_t:", xmi_element_info_get_name( classifier_info ));
     271              : 
     272            0 :     if ( map_err != 0 )
     273              :     {
     274              :         /* The caller requested to write a classifier of unknown type */
     275            0 :         U8_TRACE_INFO("xmi_element_writer: request to write a classifier of unknown type!");
     276              : 
     277            0 :         if ( (*this_).mode == XMI_WRITER_PASS_BASE )  /* count errors only once */
     278              :         {
     279              :             /* update export statistics */
     280            0 :             data_stat_inc_count ( (*this_).export_stat, DATA_STAT_TABLE_CLASSIFIER, DATA_STAT_SERIES_ERROR );
     281              :             /* inform the user via an XML comment: */
     282            0 :             export_err |= xmi_atom_writer_report_unknown_classifier( &((*this_).atom_writer),
     283              :                                                                      classifier_id,
     284              :                                                                      classifier_type
     285              :                                                                    );
     286              :         }
     287              :     }
     288            0 :     else if ( (*this_).mode == XMI_WRITER_PASS_BASE )
     289              :     {
     290              : 
     291              :         /* determine nesting tag */
     292              :         const char* nesting_property;
     293              :         const u8_error_t nesting_err
     294            0 :             = xmi_type_converter_get_xmi_nesting_property_of_classifier( &((*this_).xmi_types),
     295              :                                                                          host_type,
     296              :                                                                          classifier_type,
     297              :                                                                          &nesting_property
     298              :                                                                        );
     299            0 :         if ( nesting_err != 0 )
     300              :         {
     301              :             /* The caller requested to write a classifier to an illegal place. */
     302              :             /* This can happen in the fallback case. */
     303              :             /* During the regular tree traversal, xmi_element_writer_can_classifier_nest_classifier is checked and adhered. */
     304            0 :             U8_TRACE_INFO("xmi_element_writer: request to write a classifier to an illegal place!");
     305              :             /* update export statistics */
     306            0 :             data_stat_inc_count ( (*this_).export_stat, DATA_STAT_TABLE_CLASSIFIER, DATA_STAT_SERIES_WARNING );
     307              :             /* inform the user via an XML comment: */
     308            0 :             export_err |= xmi_atom_writer_report_illegal_container( &((*this_).atom_writer),
     309              :                                                                     classifier_id,
     310              :                                                                     classifier_type,
     311              :                                                                     host_type
     312              :                                                                   );
     313              :             /* use a fallback */
     314            0 :             nesting_property = XMI_ELEMENT_PART_FALLBACK_NESTING_ELEMENT;
     315              :         }
     316              : 
     317              :         /* write nesting tag */
     318            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     319            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_START_TAG_START );
     320            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), nesting_property );
     321            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
     322            0 :         io_xml_writer_increase_indent ( &((*this_).xml_writer) );
     323              :     }
     324              : 
     325            0 :     U8_TRACE_END_ERR( export_err );
     326            0 :     return export_err;
     327              : }
     328              : 
     329            0 : u8_error_t xmi_element_writer_assemble_classifier( xmi_element_writer_t *this_,
     330              :                                                    data_classifier_type_t host_type,
     331              :                                                    const data_classifier_t *classifier_ptr )
     332              : {
     333            0 :     U8_TRACE_BEGIN();
     334            0 :     assert ( NULL != classifier_ptr );
     335            0 :     u8_error_t export_err = U8_ERROR_NONE;
     336              : 
     337            0 :     const char *const classifier_name = data_classifier_get_name_const(classifier_ptr);
     338            0 :     const char *const classifier_stereo = data_classifier_get_stereotype_const(classifier_ptr);
     339            0 :     const char *const classifier_descr = data_classifier_get_description_const(classifier_ptr);
     340            0 :     const size_t classifier_descr_len = utf8string_get_length(classifier_descr);
     341            0 :     const data_id_t classifier_id = data_classifier_get_data_id(classifier_ptr);
     342            0 :     const data_classifier_type_t classifier_type = data_classifier_get_main_type(classifier_ptr);
     343              :     const xmi_element_info_t *classifier_info;
     344            0 :     const u8_error_t map_err = xmi_element_info_map_get_classifier( &xmi_element_info_map_standard,
     345              :                                                                     host_type,
     346              :                                                                     classifier_type,
     347              :                                                                     &classifier_info
     348              :                                                                   );
     349              : 
     350            0 :     if ( map_err != 0 )
     351              :     {
     352              :         /* The caller requested to write a classifier of unknown type, error was already logged at xmi_element_writer_start_classifier */
     353            0 :         U8_TRACE_INFO_INT("xmi_element_writer: request to write a classifier of unknown type", classifier_type );
     354              :     }
     355            0 :     else if ( (*this_).mode == XMI_WRITER_PASS_BASE )
     356              :     {
     357            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_TYPE_START );
     358            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_NS_UML );
     359            0 :         const char* c_type = xmi_type_converter_get_xmi_type_of_classifier ( &((*this_).xmi_types),
     360              :                                                                              host_type,
     361              :                                                                              classifier_type,
     362              :                                                                              XMI_SPEC_UML
     363              :                                                                            );
     364            0 :         export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), c_type );
     365            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_TYPE_END );
     366              : 
     367            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_START );
     368            0 :         export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), classifier_id );
     369            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_END );
     370              : 
     371            0 :         if ( xmi_element_info_is_a_named_element( classifier_info ) )
     372              :         {
     373            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_NAME_START );
     374            0 :             export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), classifier_name );
     375            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_NAME_END );
     376              :         }
     377              :         else
     378              :         {
     379              :             /* only comments and imaged do not have names */
     380            0 :             assert(( classifier_type == DATA_CLASSIFIER_TYPE_COMMENT )||( classifier_type == DATA_CLASSIFIER_TYPE_IMAGE ));
     381              :         }
     382              : 
     383            0 :         if ( NULL != xmi_element_info_get_additional_properties( classifier_info ) )
     384              :         {
     385            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer),
     386            0 :                                                    xmi_element_info_get_additional_properties( classifier_info )
     387              :                                                  );
     388            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
     389              :         }
     390              : 
     391            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_START_TAG_END );
     392              : 
     393            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_COMMENT_START );
     394            0 :         export_err |= io_xml_writer_write_plain_id( &((*this_).xml_writer), classifier_id );
     395            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_COMMENT_END );
     396              : 
     397            0 :         if ( classifier_type == DATA_CLASSIFIER_TYPE_COMMENT )
     398              :         {
     399            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_UML_COMMENT_BODY_START );
     400            0 :             io_xml_writer_increase_indent ( &((*this_).xml_writer) );
     401              : 
     402            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     403            0 :             export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), classifier_name );
     404              : 
     405            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "\n" );
     406              : 
     407            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     408            0 :             export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), classifier_descr );
     409              : 
     410            0 :             io_xml_writer_decrease_indent ( &((*this_).xml_writer) );
     411            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_UML_COMMENT_BODY_END );
     412              :         }
     413            0 :         else if ( classifier_type == DATA_CLASSIFIER_TYPE_REQUIREMENT )
     414              :         {
     415              :             /* nothing to do here, classifier_descr will be written later at XMI_WRITER_PASS_PROFILE */
     416              :         }
     417            0 :         else if ( 0 != classifier_descr_len )
     418              :         {
     419            0 :             export_err |= xmi_atom_writer_write_xmi_comment( &((*this_).atom_writer),
     420              :                                                              classifier_id,
     421              :                                                              "specification",
     422              :                                                              classifier_descr
     423              :                                                            );
     424              :         }
     425              : 
     426              :         /* generate extension point for use cases */
     427            0 :         if ( classifier_type == DATA_CLASSIFIER_TYPE_USE_CASE )
     428              :         {
     429            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     430            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_EMPTY_TAG_START );
     431            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "extensionPoint" );
     432            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
     433            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_TYPE_START );
     434            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_NS_UML );
     435            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "ExtensionPoint" );
     436            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_TYPE_END );
     437              : 
     438            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_START );
     439            0 :             export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), classifier_id );
     440            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "#extensionpoint" );
     441            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_END );
     442              : 
     443            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_NAME_START );
     444            0 :             export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), "" );
     445            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_NAME_END );
     446            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_EMPTY_TAG_END );
     447              :         }
     448              : 
     449              :         /* generate start of pseudo subelement region to statemachines and states */
     450            0 :         if ( classifier_type == DATA_CLASSIFIER_TYPE_STATE )
     451              :         {
     452            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     453            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_START_TAG_START );
     454            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_STATE_REGION_NESTING_STATE );
     455            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
     456            0 :             io_xml_writer_increase_indent ( &((*this_).xml_writer) );
     457            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_TYPE_START );
     458            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_NS_UML );
     459            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_STATE_REGION_TYPE );
     460            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_TYPE_END );
     461              : 
     462            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_START );
     463            0 :             export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), classifier_id );
     464            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "#region" );
     465            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_END );
     466            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_START_TAG_END );
     467              :         }
     468              : 
     469              :         /* update export statistics */
     470            0 :         data_stat_inc_count ( (*this_).export_stat, DATA_STAT_TABLE_CLASSIFIER, DATA_STAT_SERIES_EXPORTED );
     471              :     }
     472            0 :     else if ( (*this_).mode == XMI_WRITER_PASS_PROFILE )
     473              :     {
     474              :         /* write profile tag if sysml/standardprofile-only extension */
     475            0 :         if ( xmi_type_converter_get_xmi_spec_of_classifier( &((*this_).xmi_types), classifier_type ) == XMI_SPEC_SYSML )
     476              :         {
     477            0 :             const char* profile_type = xmi_type_converter_get_xmi_type_of_classifier ( &((*this_).xmi_types),
     478              :                                                                                        host_type,
     479              :                                                                                        classifier_type,
     480              :                                                                                        XMI_SPEC_SYSML
     481              :                                                                                      );
     482            0 :             assert( profile_type != NULL );
     483            0 :             const utf8stringview_t profile_type_view = UTF8STRINGVIEW_STR(profile_type);
     484            0 :             const char* base_type = xmi_type_converter_get_xmi_type_of_classifier ( &((*this_).xmi_types),
     485              :                                                                                     host_type,
     486              :                                                                                     classifier_type,
     487              :                                                                                     XMI_SPEC_UML
     488              :                                                                                   );
     489            0 :             if ( classifier_type == DATA_CLASSIFIER_TYPE_REQUIREMENT )
     490              :             {
     491              :                 /* the base class is a Class, but the derived property name from AbstractRequirement is base_NamedElement */
     492            0 :                 base_type = "NamedElement";
     493              :                 /* but: one could understand differently the SysML 1.6 chapter 16.3.2.5 Requirement */
     494              :             }
     495              : 
     496            0 :             export_err |=  xmi_element_writer_private_start_stereotype( this_,
     497              :                                                                         XMI_XML_NS_SYSML,
     498              :                                                                         &profile_type_view,
     499              :                                                                         base_type,
     500              :                                                                         classifier_id
     501              :                                                                       );
     502              : 
     503            0 :             if ( classifier_type == DATA_CLASSIFIER_TYPE_REQUIREMENT )
     504              :             {
     505            0 :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     506            0 :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "<id>" );
     507              :                 /* for postfix: see xmi_element_writer_private_start_stereotype */
     508            0 :                 export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), classifier_id );
     509            0 :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "#" );
     510            0 :                 export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), profile_type );
     511            0 :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "</id>" );
     512              : 
     513            0 :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     514            0 :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "<text>" );
     515            0 :                 io_xml_writer_increase_indent ( &((*this_).xml_writer) );
     516              : 
     517            0 :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     518            0 :                 export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), classifier_descr );
     519              : 
     520            0 :                 io_xml_writer_decrease_indent ( &((*this_).xml_writer) );
     521            0 :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "\n</text>" );
     522              : 
     523              :                 /*
     524              :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     525              :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "<master xmi:idref=\"" );
     526              :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "1" );
     527              :                 export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer),classifier_id );
     528              :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "\" />" );
     529              :                 */
     530              :             }
     531              : 
     532              :             /*
     533              :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_COMMENT_START );
     534              :             export_err |= io_xml_writer_write_plain_id( &((*this_).xml_writer), classifier_id );
     535              :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_COMMENT_END );
     536              :             */
     537              : 
     538            0 :             export_err |=  xmi_element_writer_private_end_stereotype( this_, XMI_XML_NS_SYSML, &profile_type_view );
     539              :         }
     540              : 
     541              :         /* write user-defined stereotypes */
     542              :         {
     543            0 :             const utf8stringview_t classifier_stereo_view = UTF8STRINGVIEW_STR(classifier_stereo);
     544              :             utf8stringviewiterator_t stereo_iterator;
     545            0 :             utf8stringviewiterator_init( &stereo_iterator,
     546              :                                          &classifier_stereo_view,
     547              :                                          ","
     548              :                                        );
     549            0 :             while( utf8stringviewiterator_has_next( &stereo_iterator ) )
     550              :             {
     551            0 :                 const utf8stringview_t stereotype_view = utf8stringviewiterator_next( &stereo_iterator );
     552            0 :                 size_t stereotype_len = utf8stringview_get_length( &stereotype_view );
     553            0 :                 if ( stereotype_len != 0 )
     554              :                 {
     555            0 :                     bool is_name = io_xml_writer_contains_xml_tag_name_characters( &((*this_).xml_writer), &stereotype_view );
     556            0 :                     if ( is_name )
     557              :                     {
     558            0 :                         const char* base_type = xmi_type_converter_get_xmi_type_of_classifier ( &((*this_).xmi_types),
     559              :                                                                                                 host_type,
     560              :                                                                                                 classifier_type,
     561              :                                                                                                 XMI_SPEC_UML
     562              :                                                                                               );
     563            0 :                         if ( classifier_type == DATA_CLASSIFIER_TYPE_REQUIREMENT )
     564              :                         {
     565              :                             /* the base class is a Class, but the derived property name from AbstractRequirement is base_NamedElement */
     566            0 :                             base_type = "NamedElement";
     567              :                             /* but: one could understand differently the SysML 1.6 chapter 16.3.2.5 Requirement */
     568              :                         }
     569              : 
     570            0 :                         export_err |=  xmi_element_writer_private_start_stereotype( this_,
     571              :                                                                                     XMI_XML_NS_LOCALPROF,
     572              :                                                                                     &stereotype_view,
     573              :                                                                                     base_type,
     574              :                                                                                     classifier_id
     575              :                                                                                 );
     576            0 :                         export_err |=  xmi_element_writer_private_end_stereotype( this_, XMI_XML_NS_LOCALPROF, &stereotype_view );
     577              :                     }
     578              :                     else
     579              :                     {
     580            0 :                         export_err |= xmi_atom_writer_report_illegal_stereotype( &((*this_).atom_writer),
     581              :                                                                                  classifier_id,
     582              :                                                                                  &stereotype_view
     583              :                                                                                );
     584              :                         /* update export statistics */
     585            0 :                         data_stat_inc_count ( (*this_).export_stat, DATA_STAT_TABLE_CLASSIFIER, DATA_STAT_SERIES_WARNING );
     586              :                     }
     587              :                 }
     588              :             }
     589              :         }
     590              :     }
     591              : 
     592            0 :     U8_TRACE_END_ERR( export_err );
     593            0 :     return export_err;
     594              : }
     595              : 
     596            0 : u8_error_t xmi_element_writer_end_classifier( xmi_element_writer_t *this_,
     597              :                                               data_classifier_type_t host_type,
     598              :                                               const data_classifier_t *classifier_ptr )
     599              : {
     600            0 :     U8_TRACE_BEGIN();
     601            0 :     assert ( NULL != classifier_ptr );
     602            0 :     u8_error_t export_err = U8_ERROR_NONE;
     603              : 
     604            0 :     const data_classifier_type_t classifier_type = data_classifier_get_main_type(classifier_ptr);
     605              :     const xmi_element_info_t *classifier_info;
     606            0 :     const u8_error_t map_err = xmi_element_info_map_get_classifier( &xmi_element_info_map_standard,
     607              :                                                                     host_type,
     608              :                                                                     classifier_type,
     609              :                                                                     &classifier_info
     610              :                                                                   );
     611              : 
     612            0 :     if ( map_err != 0 )
     613              :     {
     614              :         /* The caller requested to write a classifier of unknown type, error was already logged at xmi_element_writer_start_classifier */
     615            0 :         U8_TRACE_INFO_INT("xmi_element_writer: request to write a classifier of unknown type", classifier_type );
     616              :     }
     617            0 :     else if ( (*this_).mode == XMI_WRITER_PASS_BASE )
     618              :     {
     619              :         /* generate end to pseudo subelement region to statemachines and states */
     620            0 :         if ( classifier_type == DATA_CLASSIFIER_TYPE_STATE )
     621              :         {
     622            0 :             io_xml_writer_decrease_indent ( &((*this_).xml_writer) );
     623            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     624            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_END_TAG_START );
     625            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_STATE_REGION_NESTING_STATE );
     626            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_END_TAG_END );
     627              :         }
     628              : 
     629              :         /* determine nesting tag */
     630              :         const char* nesting_property;
     631              :         const u8_error_t nesting_err
     632            0 :             = xmi_type_converter_get_xmi_nesting_property_of_classifier( &((*this_).xmi_types),
     633              :                                                                          host_type,
     634              :                                                                          classifier_type,
     635              :                                                                          &nesting_property
     636              :                                                                        );
     637            0 :         if ( nesting_err != 0 )
     638              :         {
     639              :             /* The caller requested to write a classifier to an illegal place */
     640              :             /* use a fallback */
     641            0 :             nesting_property = XMI_ELEMENT_PART_FALLBACK_NESTING_ELEMENT;
     642              :         }
     643              : 
     644              :         /* adjust indentation, write end tag */
     645            0 :         io_xml_writer_decrease_indent ( &((*this_).xml_writer) );
     646            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     647            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_END_TAG_START );
     648            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), nesting_property );
     649            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_END_TAG_END );
     650              :     }
     651              : 
     652            0 :     U8_TRACE_END_ERR( export_err );
     653            0 :     return export_err;
     654              : }
     655              : 
     656            0 : u8_error_t xmi_element_writer_start_feature( xmi_element_writer_t *this_,
     657              :                                              data_classifier_type_t parent_type,
     658              :                                              const data_feature_t *feature_ptr )
     659              : {
     660            0 :     U8_TRACE_BEGIN();
     661            0 :     assert ( NULL != feature_ptr );
     662            0 :     u8_error_t export_err = U8_ERROR_NONE;
     663              : 
     664            0 :     const char *const feature_key = data_feature_get_key_const( feature_ptr );
     665            0 :     const data_id_t feature_id = data_feature_get_data_id( feature_ptr );
     666            0 :     const data_feature_type_t feature_type = data_feature_get_main_type( feature_ptr );
     667            0 :     const data_stat_table_t feat_or_lifeline
     668            0 :         = ( feature_type == DATA_FEATURE_TYPE_LIFELINE ) ? DATA_STAT_TABLE_LIFELINE : DATA_STAT_TABLE_FEATURE;
     669              :     const xmi_element_info_t *feature_info;
     670            0 :     const u8_error_t map_err = xmi_element_info_map_get_feature( &xmi_element_info_map_standard,
     671              :                                                                  parent_type,
     672              :                                                                  feature_type,
     673              :                                                                  &feature_info
     674              :                                                                );
     675            0 :     U8_TRACE_INFO_STR("xmi_element_info_t:", xmi_element_info_get_name( feature_info ));
     676              : 
     677            0 :     if ( map_err != 0 )
     678              :     {
     679              :         /* The caller requested to write a feature of unknown type */
     680            0 :         U8_TRACE_INFO("xmi_element_writer: request to write a feature of unknown type!");
     681              : 
     682            0 :         if ( (*this_).mode == XMI_WRITER_PASS_BASE )  /* count errors only once */
     683              :         {
     684              :             /* update export statistics */
     685            0 :             data_stat_inc_count ( (*this_).export_stat, feat_or_lifeline, DATA_STAT_SERIES_ERROR );
     686              :             /* inform the user via an XML comment: */
     687            0 :             export_err |= xmi_atom_writer_report_unknown_feature( &((*this_).atom_writer),
     688              :                                                                   feature_id,
     689              :                                                                   feature_type
     690              :                                                                 );
     691              :         }
     692              :     }
     693            0 :     else if ( (*this_).mode == XMI_WRITER_PASS_BASE )
     694              :     {
     695            0 :         if ( ! xmi_element_info_is_a_tagged_value( feature_info ) )
     696              :         {
     697              :             /* determine nesting tag */
     698              :             const char* owning_type;
     699              :             const u8_error_t owning_err
     700            0 :                 = xmi_type_converter_get_xmi_owning_property_of_feature( &((*this_).xmi_types),
     701              :                                                                          parent_type,
     702              :                                                                          feature_type,
     703              :                                                                          &owning_type
     704              :                                                                        );
     705            0 :             if ( owning_err != 0 )
     706              :             {
     707              :                 /* The caller requested to write a feature to an illegal place */
     708            0 :                 U8_TRACE_INFO("xmi_element_writer: request to write a feature to an illegal place!");
     709              :                 /* update export statistics */
     710            0 :                 data_stat_inc_count ( (*this_).export_stat, feat_or_lifeline, DATA_STAT_SERIES_WARNING );
     711              :                 /* inform the user via an XML comment: */
     712            0 :                 export_err |= xmi_atom_writer_report_illegal_parent( &((*this_).atom_writer),
     713              :                                                                      feature_id,
     714              :                                                                      feature_type,
     715              :                                                                      parent_type
     716              :                                                                    );
     717            0 :                 owning_type = XMI_ELEMENT_PART_FALLBACK_OWNED_FEATURE;
     718              :             }
     719              : 
     720              :             /* write nesting tag */
     721            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     722            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_START_TAG_START );
     723            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), owning_type );
     724            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
     725              : 
     726              :             /* write type attribute */
     727            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_TYPE_START );
     728            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_NS_UML );
     729            0 :             const char* f_type = xmi_type_converter_get_xmi_type_of_feature ( &((*this_).xmi_types),
     730              :                                                                               parent_type,
     731              :                                                                               feature_type,
     732              :                                                                               XMI_SPEC_UML
     733              :                                                                             );
     734            0 :             export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), f_type );
     735            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_TYPE_END );
     736              : 
     737              :             /* write id attribute */
     738            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_START );
     739            0 :             export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), feature_id );
     740            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_END );
     741              : 
     742              :             /* write name attribute */
     743            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_NAME_START );
     744            0 :             export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), feature_key );
     745            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_NAME_END );
     746              : 
     747            0 :             if ( NULL != xmi_element_info_get_additional_properties( feature_info ) )
     748              :             {
     749            0 :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer),
     750            0 :                                                        xmi_element_info_get_additional_properties( feature_info )
     751              :                                                      );
     752            0 :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
     753              :             }
     754              : 
     755            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_START_TAG_END );
     756              : 
     757            0 :             io_xml_writer_increase_indent ( &((*this_).xml_writer) );
     758              : 
     759              :             /* update export statistics */
     760            0 :             data_stat_inc_count ( (*this_).export_stat, feat_or_lifeline, DATA_STAT_SERIES_EXPORTED );
     761              :         }
     762              :     }
     763            0 :     else if ( (*this_).mode == XMI_WRITER_PASS_PROFILE )
     764              :     {
     765            0 :         if ( xmi_element_info_is_a_tagged_value( feature_info ) )
     766              :         {
     767              :             /* write nesting tag */
     768            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     769            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_START_TAG_START );
     770            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_NS_MOFEXT );
     771            0 :             const char* f_type = xmi_type_converter_get_xmi_type_of_feature ( &((*this_).xmi_types),
     772              :                                                                               parent_type,
     773              :                                                                               feature_type,
     774              :                                                                               XMI_SPEC_MOF
     775              :                                                                             );
     776            0 :             export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), f_type );
     777            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
     778              : 
     779              :             /* write type attribute */
     780            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_TYPE_START );
     781            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_NS_MOFEXT );
     782            0 :             export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), f_type );
     783            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_TYPE_END );
     784              : 
     785              :             /* write id attribute */
     786            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_START );
     787            0 :             export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), feature_id );
     788            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_END );
     789              : 
     790              :             /* write name attribute */
     791            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_NAME_START );
     792            0 :             export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), feature_key );
     793            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_NAME_END );
     794              : 
     795              :             /* write value attribute */
     796            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_VALUE_START );
     797            0 :             export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer),
     798            0 :                                                      data_feature_get_value_const( feature_ptr )
     799              :                                                    );
     800            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_VALUE_END );
     801              : 
     802            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_START_TAG_END );
     803              : 
     804            0 :             io_xml_writer_increase_indent ( &((*this_).xml_writer) );
     805              : 
     806              :             /* update export statistics */
     807            0 :             data_stat_inc_count ( (*this_).export_stat, feat_or_lifeline, DATA_STAT_SERIES_EXPORTED );
     808              :         }
     809              :     }
     810              : 
     811            0 :     U8_TRACE_END_ERR( export_err );
     812            0 :     return export_err;
     813              : }
     814              : 
     815            0 : u8_error_t xmi_element_writer_assemble_feature( xmi_element_writer_t *this_,
     816              :                                                 const data_classifier_t *parent,
     817              :                                                 const data_feature_t *feature_ptr )
     818              : {
     819            0 :     U8_TRACE_BEGIN();
     820            0 :     assert ( NULL != feature_ptr );
     821            0 :     assert( parent != NULL );
     822            0 :     u8_error_t export_err = U8_ERROR_NONE;
     823              : 
     824            0 :     const data_classifier_type_t parent_type = data_classifier_get_main_type( parent );
     825            0 :     const char *const feature_value = data_feature_get_value_const( feature_ptr );
     826            0 :     const size_t feature_value_len = utf8string_get_length(feature_value);
     827            0 :     const char *const feature_descr = data_feature_get_description_const( feature_ptr );
     828            0 :     const size_t feature_descr_len = utf8string_get_length(feature_descr);
     829            0 :     const data_id_t feature_id = data_feature_get_data_id( feature_ptr );
     830            0 :     const data_feature_type_t feature_type = data_feature_get_main_type( feature_ptr );
     831              :     const xmi_element_info_t *feature_info;
     832            0 :     const u8_error_t map_err = xmi_element_info_map_get_feature( &xmi_element_info_map_standard,
     833              :                                                                  parent_type,
     834              :                                                                  feature_type,
     835              :                                                                  &feature_info
     836              :                                                                );
     837              : 
     838            0 :     if ( map_err != 0 )
     839              :     {
     840              :         /* The caller requested to write a feature of unknown type, error was already logged at xmi_element_writer_start_feature */
     841            0 :         U8_TRACE_INFO_INT("xmi_element_writer: request to write a feature of unknown type", feature_type );
     842              :     }
     843            0 :     else if ( (*this_).mode == XMI_WRITER_PASS_BASE )
     844              :     {
     845            0 :         if ( ! xmi_element_info_is_a_tagged_value( feature_info ) )
     846              :         {
     847            0 :             if ( 0 != feature_value_len )
     848              :             {
     849            0 :                 if ( xmi_element_info_is_a_typed_element( feature_info ) )
     850              :                 {
     851            0 :                     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     852            0 :                     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_EMPTY_TAG_START );
     853            0 :                     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "type" );
     854            0 :                     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
     855              : 
     856            0 :                     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_TYPE_START );
     857            0 :                     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_NS_UML );
     858            0 :                     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "DataType" );
     859            0 :                     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_TYPE_END );
     860              : 
     861            0 :                     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_START );
     862            0 :                     export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), feature_id );
     863            0 :                     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "#type" );
     864            0 :                     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_END );
     865              : 
     866            0 :                     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_NAME_START );
     867            0 :                     export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), feature_value );
     868            0 :                     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_NAME_END );
     869              : 
     870            0 :                     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_EMPTY_TAG_END );
     871              :                 }
     872              :                 else
     873              :                 {
     874            0 :                     export_err |= xmi_atom_writer_report_illegal_datatype( &((*this_).atom_writer),
     875              :                                                                            feature_id,
     876              :                                                                            feature_value
     877              :                                                                          );
     878              :                 }
     879              :             }
     880              : 
     881            0 :             if ( 0 != feature_descr_len )
     882              :             {
     883            0 :                 export_err |= xmi_atom_writer_write_xmi_comment( &((*this_).atom_writer),
     884              :                                                                  feature_id,
     885              :                                                                  "specification",
     886              :                                                                  feature_descr
     887              :                                                                );
     888              :             }
     889              : 
     890            0 :             if ( parent_type == DATA_CLASSIFIER_TYPE_INTERACTION )
     891              :             {
     892            0 :                 const data_id_t classifier_id = data_feature_get_classifier_data_id ( feature_ptr );
     893            0 :                 export_err |= xmi_interaction_writer_assemble_feature( &((*this_).interaction_writer),
     894              :                                                                        classifier_id,
     895              :                                                                        DATA_CLASSIFIER_TYPE_INTERACTION,
     896              :                                                                        feature_ptr
     897              :                                                                      );
     898              :             }
     899              :         }
     900              :     }
     901            0 :     else if ( (*this_).mode == XMI_WRITER_PASS_PROFILE )
     902              :     {
     903            0 :         if ( xmi_element_info_is_a_tagged_value( feature_info ) )
     904              :         {
     905            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     906            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_EMPTY_TAG_START );
     907            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "element" );
     908            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
     909              : 
     910            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_IDREF_START );
     911            0 :             export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), data_classifier_get_data_id( parent ) );
     912            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_IDREF_END );
     913              : 
     914            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_EMPTY_TAG_END );
     915              :         }
     916              :     }
     917              : 
     918            0 :     U8_TRACE_END_ERR( export_err );
     919            0 :     return export_err;
     920              : }
     921              : 
     922            0 : u8_error_t xmi_element_writer_end_feature( xmi_element_writer_t *this_,
     923              :                                            data_classifier_type_t parent_type,
     924              :                                            const data_feature_t *feature_ptr )
     925              : {
     926            0 :     U8_TRACE_BEGIN();
     927            0 :     assert ( NULL != feature_ptr );
     928            0 :     u8_error_t export_err = U8_ERROR_NONE;
     929              : 
     930            0 :     const data_feature_type_t feature_type = data_feature_get_main_type( feature_ptr );
     931              :     const xmi_element_info_t *feature_info;
     932            0 :     const u8_error_t map_err = xmi_element_info_map_get_feature( &xmi_element_info_map_standard,
     933              :                                                                  parent_type,
     934              :                                                                  feature_type,
     935              :                                                                  &feature_info
     936              :                                                                );
     937              : 
     938            0 :     if ( map_err != 0 )
     939              :     {
     940              :         /* The caller requested to write a feature of unknown type, error was already logged at xmi_element_writer_start_feature */
     941            0 :         U8_TRACE_INFO_INT("xmi_element_writer: request to write a feature of unknown type", feature_type );
     942              :     }
     943            0 :     else if ( (*this_).mode == XMI_WRITER_PASS_BASE )
     944              :     {
     945            0 :         if ( ! xmi_element_info_is_a_tagged_value( feature_info ) )
     946              :         {
     947              :             /* determine nesting tag */
     948              :             const char* owning_type;
     949              :             const u8_error_t owning_err
     950            0 :                 = xmi_type_converter_get_xmi_owning_property_of_feature( &((*this_).xmi_types),
     951              :                                                                          parent_type,
     952              :                                                                          feature_type,
     953              :                                                                          &owning_type
     954              :                                                                        );
     955            0 :             if ( owning_err != 0 )
     956              :             {
     957              :                 /* The caller requested to write a feature to an illegal place */
     958            0 :                 U8_TRACE_INFO("xmi_element_writer: request to write a feature to an illegal place!");
     959            0 :                 owning_type = XMI_ELEMENT_PART_FALLBACK_OWNED_FEATURE;
     960              :             }
     961              : 
     962            0 :             io_xml_writer_decrease_indent ( &((*this_).xml_writer) );
     963            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     964            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_END_TAG_START );
     965            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), owning_type );
     966            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_END_TAG_END );
     967              :         }
     968              :     }
     969            0 :     else if ( (*this_).mode == XMI_WRITER_PASS_PROFILE )
     970              :     {
     971            0 :         if ( xmi_element_info_is_a_tagged_value( feature_info ) )
     972              :         {
     973            0 :             io_xml_writer_decrease_indent ( &((*this_).xml_writer) );
     974            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
     975            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_END_TAG_START );
     976            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_NS_MOFEXT );
     977            0 :             const char* f_type = xmi_type_converter_get_xmi_type_of_feature ( &((*this_).xmi_types),
     978              :                                                                               parent_type,
     979              :                                                                               feature_type,
     980              :                                                                               XMI_SPEC_MOF
     981              :                                                                             );
     982            0 :             export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), f_type );
     983            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_END_TAG_END );
     984              :         }
     985              :     }
     986              : 
     987            0 :     U8_TRACE_END_ERR( export_err );
     988            0 :     return export_err;
     989              : }
     990              : 
     991            0 : u8_error_t xmi_element_writer_start_relationship( xmi_element_writer_t *this_,
     992              :                                                   data_classifier_type_t host_type,
     993              :                                                   const data_relationship_t *relation_ptr )
     994              : {
     995            0 :     U8_TRACE_BEGIN();
     996            0 :     assert ( NULL != relation_ptr );
     997              :     /* NULL is allowed here: dest_classifier_ptr */
     998            0 :     u8_error_t export_err = U8_ERROR_NONE;
     999              : 
    1000            0 :     const char *const relation_name = data_relationship_get_name_const( relation_ptr );
    1001            0 :     const size_t relation_name_len = utf8string_get_length(relation_name);
    1002            0 :     const char *const relation_stereo = data_relationship_get_stereotype_const(relation_ptr);
    1003            0 :     const data_id_t relation_id = data_relationship_get_data_id( relation_ptr );
    1004            0 :     const data_relationship_type_t relation_type = data_relationship_get_main_type( relation_ptr );
    1005              :     const xmi_element_info_t *relation_info;
    1006            0 :     const u8_error_t map_err = xmi_element_info_map_get_relationship( &xmi_element_info_map_standard,
    1007              :                                                                       (host_type==DATA_CLASSIFIER_TYPE_STATE),
    1008              :                                                                       relation_type,
    1009              :                                                                       &relation_info
    1010              :                                                                     );
    1011            0 :     U8_TRACE_INFO_STR("xmi_element_info_t:", xmi_element_info_get_name( relation_info ));
    1012            0 :     const bool is_annotated_element
    1013            0 :         = (( host_type == DATA_CLASSIFIER_TYPE_COMMENT )&&( relation_type == DATA_RELATIONSHIP_TYPE_UML_DEPENDENCY ));
    1014              : 
    1015            0 :     if ( map_err != 0 )
    1016              :     {
    1017              :         /* The caller requested to write a relationship of unknown type */
    1018            0 :         U8_TRACE_INFO("xmi_element_writer: request to write a relationship of unknown type!");
    1019              : 
    1020            0 :         if ( (*this_).mode == XMI_WRITER_PASS_BASE )  /* count errors only once */
    1021              :         {
    1022              :             /* update export statistics */
    1023            0 :             data_stat_inc_count ( (*this_).export_stat, DATA_STAT_TABLE_RELATIONSHIP, DATA_STAT_SERIES_ERROR );
    1024              :             /* inform the user via an XML comment: */
    1025            0 :             export_err |= xmi_atom_writer_report_unknown_relationship( &((*this_).atom_writer),
    1026              :                                                                        relation_id,
    1027              :                                                                        relation_type
    1028              :                                                                      );
    1029              :         }
    1030              :     }
    1031            0 :     else if ( (*this_).mode == XMI_WRITER_PASS_BASE )
    1032              :     {
    1033              :         /* determine nesting tag */
    1034              :         const char* nesting_property;
    1035              :         const u8_error_t nesting_err
    1036            0 :             = xmi_type_converter_get_xmi_nesting_property_of_relationship( &((*this_).xmi_types),
    1037              :                                                                            host_type,
    1038              :                                                                            relation_type,
    1039              :                                                                            &nesting_property
    1040              :                                                                          );
    1041            0 :         if ( nesting_err != 0 )
    1042              :         {
    1043              :             /* The caller requested to write a relationship to an illegal place */
    1044            0 :             U8_TRACE_INFO("xmi_element_writer: request to write a relationship to an illegal place!");
    1045              :             /* update export statistics */
    1046            0 :             data_stat_inc_count ( (*this_).export_stat, DATA_STAT_TABLE_RELATIONSHIP, DATA_STAT_SERIES_WARNING );
    1047              :             /* inform the user via an XML comment: */
    1048            0 :             export_err |= xmi_atom_writer_report_illegal_location( &((*this_).atom_writer),
    1049              :                                                                    relation_id,
    1050              :                                                                    relation_type,
    1051              :                                                                    host_type
    1052              :                                                                  );
    1053              :             /* use a fallback */
    1054            0 :             nesting_property = XMI_ELEMENT_PART_FALLBACK_NESTING_ELEMENT;
    1055              :         }
    1056              : 
    1057            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
    1058            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_START_TAG_START );
    1059            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), nesting_property );
    1060            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
    1061              : 
    1062            0 :         if ( is_annotated_element )
    1063              :         {
    1064            0 :             const data_id_t to_classifier_id = data_relationship_get_to_classifier_data_id( relation_ptr );
    1065            0 :             const data_id_t to_feature_id = data_relationship_get_to_feature_data_id( relation_ptr );
    1066              : 
    1067            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_IDREF_START );
    1068            0 :             if ( data_id_is_valid( &to_feature_id ) )
    1069              :             {
    1070            0 :                 export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), to_feature_id );
    1071              :             }
    1072              :             else
    1073              :             {
    1074            0 :                 export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), to_classifier_id );
    1075              :             }
    1076            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_IDREF_END );
    1077              :         }
    1078              :         else
    1079              :         {
    1080              :             /* write type attribute */
    1081            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_TYPE_START );
    1082            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_NS_UML );
    1083            0 :             const char* r_type = xmi_type_converter_get_xmi_type_of_relationship ( &((*this_).xmi_types),
    1084              :                                                                                    host_type,
    1085              :                                                                                    relation_type,
    1086              :                                                                                    XMI_SPEC_UML
    1087              :                                                                                  );
    1088            0 :             export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), r_type );
    1089            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_TYPE_END );
    1090              : 
    1091              :             /* write id attribute */
    1092            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_START );
    1093            0 :             export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer),relation_id );
    1094            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_END );
    1095              : 
    1096              :             /* write name attribute */
    1097            0 :             if ( xmi_element_info_is_a_named_element( relation_info ) )
    1098              :             {
    1099            0 :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_NAME_START );
    1100            0 :                 export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), relation_name );
    1101            0 :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_NAME_END );
    1102              :             }
    1103              : 
    1104            0 :             if ( NULL != xmi_element_info_get_additional_properties( relation_info ) )
    1105              :             {
    1106            0 :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer),
    1107            0 :                                                        xmi_element_info_get_additional_properties( relation_info )
    1108              :                                                      );
    1109            0 :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
    1110              :             }
    1111              :         }
    1112              : 
    1113            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_START_TAG_END );
    1114              : 
    1115            0 :         io_xml_writer_increase_indent ( &((*this_).xml_writer) );
    1116              : 
    1117              :         /* write name comment */
    1118            0 :         if (( ! xmi_element_info_is_a_named_element( relation_info ) )&&( relation_name_len > 0 ))
    1119              :         {
    1120            0 :             export_err |= xmi_atom_writer_write_xmi_comment( &((*this_).atom_writer),
    1121              :                                                              relation_id,
    1122              :                                                              "name",
    1123              :                                                              relation_name
    1124              :                                                            );
    1125              :         }
    1126              : 
    1127              :         /* update export statistics */
    1128            0 :         data_stat_inc_count ( (*this_).export_stat, DATA_STAT_TABLE_RELATIONSHIP, DATA_STAT_SERIES_EXPORTED );
    1129              :     }
    1130            0 :     else if ( (*this_).mode == XMI_WRITER_PASS_PROFILE )
    1131              :     {
    1132              :         /* write profile tag if sysml/standardprofile-only extention */
    1133            0 :         if ( xmi_type_converter_get_xmi_spec_of_relationship( &((*this_).xmi_types), relation_type ) == XMI_SPEC_STANDARD )
    1134              :         {
    1135            0 :             const char* profile_type = xmi_type_converter_get_xmi_type_of_relationship ( &((*this_).xmi_types),
    1136              :                                                                                          host_type,
    1137              :                                                                                          relation_type,
    1138              :                                                                                          XMI_SPEC_STANDARD
    1139              :                                                                                        );
    1140            0 :             assert( profile_type != NULL );
    1141            0 :             const utf8stringview_t profile_type_view = UTF8STRINGVIEW_STR(profile_type);
    1142            0 :             const char* base_type = xmi_type_converter_get_xmi_type_of_relationship ( &((*this_).xmi_types),
    1143              :                                                                                       host_type,
    1144              :                                                                                       relation_type,
    1145              :                                                                                       XMI_SPEC_UML
    1146              :                                                                                     );
    1147            0 :             export_err |=  xmi_element_writer_private_start_stereotype( this_,
    1148              :                                                                         XMI_XML_NS_STDPROF,
    1149              :                                                                         &profile_type_view,
    1150              :                                                                         base_type,
    1151              :                                                                         relation_id
    1152              :                                                                       );
    1153            0 :             export_err |=  xmi_element_writer_private_end_stereotype( this_, XMI_XML_NS_STDPROF, &profile_type_view );
    1154              :         }
    1155              : 
    1156              :         /* write user-defined stereotypes */
    1157              :         {
    1158            0 :             const utf8stringview_t relation_stereo_view = UTF8STRINGVIEW_STR(relation_stereo);
    1159              :             utf8stringviewiterator_t stereo_iterator;
    1160            0 :             utf8stringviewiterator_init( &stereo_iterator,
    1161              :                                          &relation_stereo_view,
    1162              :                                          ","
    1163              :                                        );
    1164            0 :             while( utf8stringviewiterator_has_next( &stereo_iterator ) )
    1165              :             {
    1166            0 :                 const utf8stringview_t stereotype_view = utf8stringviewiterator_next( &stereo_iterator );
    1167            0 :                 size_t stereotype_len = utf8stringview_get_length( &stereotype_view );
    1168            0 :                 if ( stereotype_len != 0 )
    1169              :                 {
    1170            0 :                     bool is_name = io_xml_writer_contains_xml_tag_name_characters( &((*this_).xml_writer), &stereotype_view );
    1171            0 :                     if ( is_name )
    1172              :                     {
    1173            0 :                         const char* base_type = xmi_type_converter_get_xmi_type_of_relationship ( &((*this_).xmi_types),
    1174              :                                                                                                   host_type,
    1175              :                                                                                                   relation_type,
    1176              :                                                                                                   XMI_SPEC_UML
    1177              :                                                                                                 );
    1178              : 
    1179            0 :                         export_err |=  xmi_element_writer_private_start_stereotype( this_,
    1180              :                                                                                     XMI_XML_NS_LOCALPROF,
    1181              :                                                                                     &stereotype_view,
    1182              :                                                                                     base_type,
    1183              :                                                                                     relation_id
    1184              :                                                                                   );
    1185            0 :                         export_err |=  xmi_element_writer_private_end_stereotype( this_, XMI_XML_NS_LOCALPROF, &stereotype_view );
    1186              :                     }
    1187              :                     else
    1188              :                     {
    1189            0 :                         export_err |= xmi_atom_writer_report_illegal_stereotype( &((*this_).atom_writer),
    1190              :                                                                                  relation_id,
    1191              :                                                                                  &stereotype_view
    1192              :                                                                                );
    1193              :                         /* update export statistics */
    1194            0 :                         data_stat_inc_count ( (*this_).export_stat, DATA_STAT_TABLE_RELATIONSHIP, DATA_STAT_SERIES_WARNING );
    1195              :                     }
    1196              :                 }
    1197              :             }
    1198              :         }
    1199              :     }
    1200              : 
    1201            0 :     U8_TRACE_END_ERR( export_err );
    1202            0 :     return export_err;
    1203              : }
    1204              : 
    1205            0 : u8_error_t xmi_element_writer_assemble_relationship( xmi_element_writer_t *this_,
    1206              :                                                      const data_classifier_t *host,
    1207              :                                                      const data_relationship_t *relation_ptr,
    1208              :                                                      const data_classifier_t *from_c,
    1209              :                                                      const data_feature_t *from_f,
    1210              :                                                      const data_classifier_t *to_c,
    1211              :                                                      const data_feature_t *to_f )
    1212              : {
    1213            0 :     U8_TRACE_BEGIN();
    1214              : 
    1215            0 :     assert ( NULL != relation_ptr );
    1216            0 :     assert ( NULL != from_c );
    1217            0 :     assert ( NULL != to_c );
    1218              : 
    1219              :     const data_classifier_type_t from_c_type
    1220            0 :         = data_classifier_get_main_type( from_c );
    1221            0 :     const data_feature_type_t from_f_type
    1222              :         = (from_f==NULL)
    1223              :         ? DATA_FEATURE_TYPE_VOID
    1224            0 :         : data_feature_is_valid(from_f) ? data_feature_get_main_type( from_f ) : DATA_FEATURE_TYPE_VOID;
    1225              :     const data_classifier_type_t to_c_type
    1226            0 :         = data_classifier_get_main_type( to_c );
    1227            0 :     const data_feature_type_t to_f_type
    1228              :         = (to_f==NULL)
    1229              :         ? DATA_FEATURE_TYPE_VOID
    1230            0 :         : data_feature_is_valid(to_f) ? data_feature_get_main_type( to_f ) : DATA_FEATURE_TYPE_VOID;
    1231              :     data_id_t host_id;
    1232              :     data_classifier_type_t host_type;
    1233              :     bool host_is_source;
    1234            0 :     if ( host == NULL )
    1235              :     {
    1236            0 :         host_id = DATA_ID_VOID;
    1237            0 :         host_type = DATA_CLASSIFIER_TYPE_PACKAGE;  /* a uml:Model is a uml:Package*/
    1238            0 :         host_is_source = false;
    1239              :     }
    1240              :     else
    1241              :     {
    1242            0 :         host_id = data_classifier_get_data_id( host );
    1243            0 :         host_type = data_classifier_get_main_type( host );
    1244            0 :         host_is_source = ( data_classifier_get_row_id( from_c ) == data_classifier_get_row_id( host ) );
    1245              :     }
    1246              : 
    1247              :     const u8_error_t export_err
    1248            0 :         = xmi_element_writer_private_assemble_relationship( this_,
    1249              :                                                             host_type,
    1250              :                                                             host_is_source,
    1251              :                                                             host_id,
    1252              :                                                             relation_ptr,
    1253              :                                                             from_c_type,
    1254              :                                                             from_f_type,
    1255              :                                                             to_c_type,
    1256              :                                                             to_f_type
    1257              :                                                           );
    1258              : 
    1259            0 :     U8_TRACE_END_ERR( export_err );
    1260            0 :     return export_err;
    1261              : }
    1262              : 
    1263            0 : u8_error_t xmi_element_writer_private_assemble_relationship( xmi_element_writer_t *this_,
    1264              :                                                              data_classifier_type_t host_type,
    1265              :                                                              bool host_is_source,
    1266              :                                                              data_id_t host_id,
    1267              :                                                              const data_relationship_t *relation_ptr,
    1268              :                                                              data_classifier_type_t from_c_type,
    1269              :                                                              data_feature_type_t from_f_type,
    1270              :                                                              data_classifier_type_t to_c_type,
    1271              :                                                              data_feature_type_t to_f_type )
    1272              : {
    1273            0 :     U8_TRACE_BEGIN();
    1274            0 :     assert ( NULL != relation_ptr );
    1275              :     /* NULL is allowed here: dest_classifier_ptr */
    1276            0 :     u8_error_t export_err = U8_ERROR_NONE;
    1277              : 
    1278            0 :     const data_id_t relation_id = data_relationship_get_data_id( relation_ptr );
    1279            0 :     const char *const relation_descr = data_relationship_get_description_const( relation_ptr );
    1280            0 :     const size_t relation_descr_len = utf8string_get_length(relation_descr);
    1281            0 :     const data_id_t from_classifier_id = data_relationship_get_from_classifier_data_id( relation_ptr );
    1282            0 :     const data_id_t from_feature_id = data_relationship_get_from_feature_data_id( relation_ptr );
    1283            0 :     const data_id_t from_end_id = data_id_is_valid( &from_feature_id ) ? from_feature_id : from_classifier_id;
    1284            0 :     const data_id_t to_classifier_id = data_relationship_get_to_classifier_data_id( relation_ptr );
    1285            0 :     const data_id_t to_feature_id = data_relationship_get_to_feature_data_id( relation_ptr );
    1286            0 :     const data_id_t to_end_id = data_id_is_valid( &to_feature_id ) ? to_feature_id : to_classifier_id;
    1287            0 :     const data_relationship_type_t relation_type = data_relationship_get_main_type( relation_ptr );
    1288              :     const xmi_element_info_t *relation_info;
    1289            0 :     const u8_error_t map_err = xmi_element_info_map_get_relationship( &xmi_element_info_map_standard,
    1290              :                                                                       (host_type==DATA_CLASSIFIER_TYPE_STATE),
    1291              :                                                                       relation_type,
    1292              :                                                                       &relation_info
    1293              :                                                                     );
    1294            0 :     if ( map_err != 0 )
    1295              :     {
    1296              :         /* The caller requested to write a relationship of unknown type, error was already logged at xmi_element_writer_start_relationship */
    1297            0 :         U8_TRACE_INFO_INT("xmi_element_writer: request to write a relationship of unknown type", relation_type );
    1298              :     }
    1299              : 
    1300            0 :     const xmi_element_info_t *from_end_info = NULL;
    1301            0 :     if (from_f_type == DATA_FEATURE_TYPE_VOID)
    1302              :     {
    1303              :         const u8_error_t map_err_2
    1304            0 :             = xmi_element_info_map_get_classifier( &xmi_element_info_map_standard, host_type /*wrong host here*/, from_c_type, &from_end_info );
    1305            0 :         if ( map_err_2 != 0 )
    1306              :         {
    1307            0 :             U8_TRACE_INFO_INT("xmi_element_writer: request to write a relationship from-end of unknown c-type", from_c_type );
    1308              :         }
    1309              :     }
    1310              :     else
    1311              :     {
    1312              :         const u8_error_t map_err_3
    1313            0 :             = xmi_element_info_map_get_feature( &xmi_element_info_map_standard, from_c_type, from_f_type, &from_end_info );
    1314            0 :         if ( map_err_3 != 0 )
    1315              :         {
    1316            0 :             U8_TRACE_INFO_INT("xmi_element_writer: request to write a relationship from-end of unknown f-type", from_f_type );
    1317              :         }
    1318              :     }
    1319            0 :     assert ( from_end_info != NULL );
    1320              : 
    1321            0 :     const xmi_element_info_t *to_end_info = NULL;
    1322            0 :     if (to_f_type == DATA_FEATURE_TYPE_VOID)
    1323              :     {
    1324              :         const u8_error_t map_err_4
    1325            0 :             = xmi_element_info_map_get_classifier( &xmi_element_info_map_standard, host_type /*wrong host here*/, to_c_type, &to_end_info );
    1326            0 :         if ( map_err_4 != 0 )
    1327              :         {
    1328            0 :             U8_TRACE_INFO_INT("xmi_element_writer: request to write a relationship to-end of unknown c-type", to_c_type );
    1329              :         }
    1330              :     }
    1331              :     else
    1332              :     {
    1333              :         const u8_error_t map_err_5
    1334            0 :             = xmi_element_info_map_get_feature( &xmi_element_info_map_standard, to_c_type, to_f_type, &to_end_info );
    1335            0 :         if ( map_err_5 != 0 )
    1336              :         {
    1337            0 :             U8_TRACE_INFO_INT("xmi_element_writer: request to write a relationship to-end of unknown f-type", to_f_type );
    1338              :         }
    1339              :     }
    1340            0 :     assert ( to_end_info != NULL );
    1341              : 
    1342              :     /* evaluate if xmi requires to generate fake properties */
    1343            0 :     const bool fake_property_ends = xmi_element_info_is_a_association( relation_info );
    1344            0 :     const bool fake_property_at_from_end
    1345            0 :         = fake_property_ends && ( ! xmi_element_info_is_a_property( from_end_info ) );
    1346            0 :     const bool fake_property_at_to_end
    1347            0 :         = fake_property_ends && ( ! xmi_element_info_is_a_property( to_end_info ) );
    1348              :     /* check if suppress source end */
    1349            0 :     const bool suppress_source
    1350              :         = (( relation_type == DATA_RELATIONSHIP_TYPE_UML_GENERALIZATION )
    1351            0 :         || ( relation_type == DATA_RELATIONSHIP_TYPE_UML_EXTEND )
    1352            0 :         || ( relation_type == DATA_RELATIONSHIP_TYPE_UML_INCLUDE ))
    1353            0 :         && host_is_source;
    1354            0 :     const bool is_annotated_element
    1355            0 :         = (( host_type == DATA_CLASSIFIER_TYPE_COMMENT )&&( relation_type == DATA_RELATIONSHIP_TYPE_UML_DEPENDENCY ));
    1356            0 :     const bool is_message = ( xmi_element_info_is_a_message ( relation_info ) );
    1357              : 
    1358            0 :     if ( map_err != 0 )
    1359              :     {
    1360              :         /* The caller requested to write a relationship of unknown type, error was already logged at xmi_element_writer_start_relationship */
    1361            0 :         U8_TRACE_INFO_INT("xmi_element_writer: request to write a relationship of unknown type", relation_type );
    1362              :     }
    1363            0 :     else if (( host_type == DATA_CLASSIFIER_TYPE_INTERACTION )&&( is_message ))
    1364              :     {
    1365            0 :         export_err |= xmi_interaction_writer_assemble_relationship( &((*this_).interaction_writer),
    1366              :                                                                     host_id,
    1367              :                                                                     DATA_CLASSIFIER_TYPE_INTERACTION,  /* fake host type */
    1368              :                                                                     relation_ptr,
    1369              :                                                                     DATA_CLASSIFIER_TYPE_INTERACTION,  /* fake from classifier type */
    1370              :                                                                     DATA_FEATURE_TYPE_LIFELINE,  /* guess from feature type */
    1371              :                                                                     DATA_CLASSIFIER_TYPE_INTERACTION,  /* fake to classifier type */
    1372              :                                                                     DATA_FEATURE_TYPE_LIFELINE  /* guess to feature type */
    1373            0 :                                                                   );
    1374              :     }
    1375            0 :     else if (( (*this_).mode == XMI_WRITER_PASS_BASE )&&( ! is_annotated_element ))
    1376              :     {
    1377            0 :         if ( 0 != relation_descr_len )
    1378              :         {
    1379            0 :             export_err |= xmi_atom_writer_write_xmi_comment( &((*this_).atom_writer),
    1380              :                                                              relation_id,
    1381              :                                                              "specification",
    1382              :                                                              relation_descr
    1383              :                                                            );
    1384              :         }
    1385              : 
    1386              :         /* source */
    1387            0 :         if ( ! suppress_source )
    1388              :         {
    1389              :             /* determine from type tag */
    1390              :             const char* from_type_tag;
    1391              :             const u8_error_t from_type_err
    1392            0 :                 = xmi_type_converter_get_xmi_from_property_of_relationship ( &((*this_).xmi_types),
    1393              :                                                                              host_type,
    1394              :                                                                              relation_type,
    1395              :                                                                              from_c_type,
    1396              :                                                                              from_f_type,
    1397              :                                                                              &from_type_tag
    1398              :                                                                            );
    1399            0 :             if ( from_type_err != 0 )
    1400              :             {
    1401              :                 /* The caller requested to write a relationship of illegal source end type */
    1402            0 :                 U8_TRACE_INFO("xmi_element_writer: request to write a relationship connecting an illegal source end type!");
    1403              :                 /* update export statistics */
    1404            0 :                 data_stat_inc_count ( (*this_).export_stat, DATA_STAT_TABLE_RELATIONSHIP, DATA_STAT_SERIES_WARNING );
    1405              :                 /* inform the user via an XML comment: */
    1406            0 :                 export_err |= xmi_atom_writer_report_illegal_relationship_end ( &((*this_).atom_writer),
    1407              :                                                                                 relation_id,
    1408              :                                                                                 relation_type,
    1409              :                                                                                 host_type,
    1410              :                                                                                 true /* = from_end */,
    1411              :                                                                                 from_c_type,
    1412              :                                                                                 from_f_type
    1413              :                                                                               );
    1414              :             }
    1415              : 
    1416            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
    1417            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_EMPTY_TAG_START );
    1418            0 :             export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), from_type_tag );
    1419            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
    1420              : 
    1421            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_IDREF_START );
    1422            0 :             if ( fake_property_at_from_end )
    1423              :             {
    1424            0 :                 export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), relation_id );
    1425            0 :                 export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_ELEMENT_PART_ID_FRAGMENT_SOURCE_END );
    1426              :             }
    1427              :             else
    1428              :             {
    1429            0 :                 export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), from_end_id );
    1430              :             }
    1431            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_IDREF_END );
    1432              : 
    1433            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_EMPTY_TAG_END );
    1434              : 
    1435            0 :             if ( fake_property_at_from_end )
    1436              :             {
    1437            0 :                 export_err |= xmi_element_writer_private_fake_memberend ( this_,
    1438              :                                                                           relation_id,
    1439              :                                                                           relation_type,
    1440              :                                                                           from_end_id,
    1441              :                                                                           from_c_type,
    1442              :                                                                           from_f_type,
    1443              :                                                                           false /* = is_target_end */
    1444              :                                                                         );
    1445              :             }
    1446              :         }
    1447              : 
    1448              :         /* destination */
    1449              :         /* determine from type tag */
    1450              :         const char* to_type_tag;
    1451              :         const u8_error_t to_type_err
    1452            0 :             = xmi_type_converter_get_xmi_to_property_of_relationship ( &((*this_).xmi_types),
    1453              :                                                                        host_type,
    1454              :                                                                        relation_type,
    1455              :                                                                        to_c_type,
    1456              :                                                                        to_f_type,
    1457              :                                                                        &to_type_tag
    1458              :                                                                      );
    1459            0 :         if ( to_type_err != 0 )
    1460              :         {
    1461              :             /* The caller requested to write a relationship of illegal target end type */
    1462            0 :             U8_TRACE_INFO("xmi_element_writer: request to write a relationship connecting an illegal target end type!");
    1463              :             /* update export statistics */
    1464            0 :             data_stat_inc_count ( (*this_).export_stat, DATA_STAT_TABLE_RELATIONSHIP, DATA_STAT_SERIES_WARNING );
    1465              :             /* inform the user via an XML comment: */
    1466            0 :             export_err |= xmi_atom_writer_report_illegal_relationship_end ( &((*this_).atom_writer),
    1467              :                                                                             relation_id,
    1468              :                                                                             relation_type,
    1469              :                                                                             host_type,
    1470              :                                                                             false /* = from_end */,
    1471              :                                                                             to_c_type,
    1472              :                                                                             to_f_type
    1473              :                                                                           );
    1474              :         }
    1475              : 
    1476            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
    1477            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_EMPTY_TAG_START );
    1478            0 :         export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), to_type_tag );
    1479            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
    1480              : 
    1481            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_IDREF_START );
    1482            0 :         if ( fake_property_at_to_end )
    1483              :         {
    1484            0 :             export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), relation_id );
    1485            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_ELEMENT_PART_ID_FRAGMENT_TARGET_END );
    1486              :         }
    1487              :         else
    1488              :         {
    1489            0 :             export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), to_end_id );
    1490              :         }
    1491            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_IDREF_END );
    1492              : 
    1493            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_EMPTY_TAG_END );
    1494              : 
    1495            0 :         if ( fake_property_at_to_end )
    1496              :         {
    1497            0 :             export_err |= xmi_element_writer_private_fake_memberend ( this_,
    1498              :                                                                       relation_id,
    1499              :                                                                       relation_type,
    1500              :                                                                       to_end_id,
    1501              :                                                                       to_c_type,
    1502              :                                                                       to_f_type,
    1503              :                                                                       true /* = is_target_end */
    1504              :                                                                     );
    1505              :         }
    1506              : 
    1507              :         /* generate extension point for use cases */
    1508            0 :         if ( relation_type == DATA_RELATIONSHIP_TYPE_UML_EXTEND )
    1509              :         {
    1510            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
    1511            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_EMPTY_TAG_START );
    1512            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "extensionLocation" );
    1513            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
    1514            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_IDREF_START );
    1515            0 :             export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), to_end_id );
    1516            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "#extensionpoint" );
    1517            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_IDREF_END );
    1518            0 :             export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_EMPTY_TAG_END );
    1519              :         }
    1520              :     }
    1521              : 
    1522            0 :     U8_TRACE_END_ERR( export_err );
    1523            0 :     return export_err;
    1524              : }
    1525              : 
    1526            0 : u8_error_t xmi_element_writer_end_relationship( xmi_element_writer_t *this_,
    1527              :                                                 data_classifier_type_t host_type,
    1528              :                                                 const data_relationship_t *relation_ptr )
    1529              : {
    1530            0 :     U8_TRACE_BEGIN();
    1531            0 :     assert ( NULL != relation_ptr );
    1532              :     /* NULL is allowed here: dest_classifier_ptr */
    1533            0 :     u8_error_t export_err = U8_ERROR_NONE;
    1534              : 
    1535            0 :     const data_relationship_type_t relation_type = data_relationship_get_main_type( relation_ptr );
    1536              :     const xmi_element_info_t *relation_info;
    1537            0 :     const u8_error_t map_err = xmi_element_info_map_get_relationship( &xmi_element_info_map_standard,
    1538              :                                                                       (host_type==DATA_CLASSIFIER_TYPE_STATE),
    1539              :                                                                       relation_type,
    1540              :                                                                       &relation_info
    1541              :                                                                     );
    1542              : 
    1543            0 :     if ( map_err != 0 )
    1544              :     {
    1545              :         /* The caller requested to write a relationship of unknown type, error was already logged at xmi_element_writer_start_relationship */
    1546            0 :         U8_TRACE_INFO_INT("xmi_element_writer: request to write a relationship of unknown type", relation_type );
    1547              :     }
    1548            0 :     else if ( (*this_).mode == XMI_WRITER_PASS_BASE )
    1549              :     {
    1550              :         /* determine nesting tag */
    1551              :         const char* nesting_property;
    1552              :         const u8_error_t nesting_err
    1553            0 :             = xmi_type_converter_get_xmi_nesting_property_of_relationship( &((*this_).xmi_types),
    1554              :                                                                            host_type,
    1555              :                                                                            relation_type,
    1556              :                                                                            &nesting_property
    1557              :                                                                          );
    1558            0 :         if ( nesting_err != 0 )
    1559              :         {
    1560              :             /* use a fallback */
    1561            0 :             nesting_property = XMI_ELEMENT_PART_FALLBACK_NESTING_ELEMENT;
    1562              :         }
    1563              : 
    1564            0 :         io_xml_writer_decrease_indent ( &((*this_).xml_writer) );
    1565            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
    1566            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_END_TAG_START );
    1567            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), nesting_property );
    1568            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_END_TAG_END );
    1569              :     }
    1570              : 
    1571            0 :     U8_TRACE_END_ERR( export_err );
    1572            0 :     return export_err;
    1573              : }
    1574              : 
    1575            0 : u8_error_t xmi_element_writer_start_diagram( xmi_element_writer_t *this_, const data_diagram_t *diag_ptr )
    1576              : {
    1577            0 :     U8_TRACE_BEGIN();
    1578            0 :     const u8_error_t export_err = U8_ERROR_NOT_YET_IMPLEMENTED;
    1579            0 :     U8_LOG_WARNING( "xmi_element_writer_t does not export data_diagram_t" );
    1580            0 :     U8_TRACE_END_ERR( export_err );
    1581            0 :     return export_err;
    1582              : }
    1583              : 
    1584            0 : u8_error_t xmi_element_writer_assemble_diagram( xmi_element_writer_t *this_,
    1585              :                                                 const data_diagram_t *parent,
    1586              :                                                 const data_diagram_t *diag_ptr,
    1587              :                                                 const char *diagram_file_base_name )
    1588              : {
    1589            0 :     U8_TRACE_BEGIN();
    1590            0 :     const u8_error_t export_err = U8_ERROR_NOT_YET_IMPLEMENTED;
    1591            0 :     U8_LOG_WARNING( "xmi_element_writer_t does not export data_diagram_t" );
    1592            0 :     U8_TRACE_END_ERR( export_err );
    1593            0 :     return export_err;
    1594              : }
    1595              : 
    1596            0 : u8_error_t xmi_element_writer_end_diagram( xmi_element_writer_t *this_, const data_diagram_t *diag_ptr )
    1597              : {
    1598            0 :     U8_TRACE_BEGIN();
    1599            0 :     const u8_error_t export_err = U8_ERROR_NOT_YET_IMPLEMENTED;
    1600            0 :     U8_LOG_WARNING( "xmi_element_writer_t does not export data_diagram_t" );
    1601            0 :     U8_TRACE_END_ERR( export_err );
    1602            0 :     return export_err;
    1603              : }
    1604              : 
    1605            0 : u8_error_t xmi_element_writer_start_diagramelement( xmi_element_writer_t *this_,
    1606              :                                                     const data_diagram_t *parent,
    1607              :                                                     const data_diagramelement_t *diagramelement_ptr )
    1608              : {
    1609            0 :     U8_TRACE_BEGIN();
    1610            0 :     const u8_error_t export_err = U8_ERROR_NOT_YET_IMPLEMENTED;
    1611            0 :     U8_LOG_WARNING( "xmi_element_writer_t does not export data_diagramelement_t" );
    1612            0 :     U8_TRACE_END_ERR( export_err );
    1613            0 :     return export_err;
    1614              : }
    1615              : 
    1616            0 : u8_error_t xmi_element_writer_assemble_diagramelement( xmi_element_writer_t *this_,
    1617              :                                                        const data_diagram_t *parent,
    1618              :                                                        const data_diagramelement_t *diagramelement_ptr,
    1619              :                                                        const data_classifier_t *occurrence,
    1620              :                                                        const data_feature_t *feat_occur )
    1621              : {
    1622            0 :     U8_TRACE_BEGIN();
    1623              :     /* NULL is allowed here: feat_occur */
    1624            0 :     const u8_error_t export_err = U8_ERROR_NOT_YET_IMPLEMENTED;
    1625            0 :     U8_LOG_WARNING( "xmi_element_writer_t does not export data_diagramelement_t" );
    1626            0 :     U8_TRACE_END_ERR( export_err );
    1627            0 :     return export_err;
    1628              : }
    1629              : 
    1630            0 : u8_error_t xmi_element_writer_end_diagramelement( xmi_element_writer_t *this_,
    1631              :                                                   const data_diagram_t *parent,
    1632              :                                                   const data_diagramelement_t *diagramelement_ptr )
    1633              : {
    1634            0 :     U8_TRACE_BEGIN();
    1635            0 :     const u8_error_t export_err = U8_ERROR_NOT_YET_IMPLEMENTED;
    1636            0 :     U8_LOG_WARNING( "xmi_element_writer_t does not export data_diagramelement_t" );
    1637            0 :     U8_TRACE_END_ERR( export_err );
    1638            0 :     return export_err;
    1639              : }
    1640              : 
    1641            0 : u8_error_t xmi_element_writer_end_main( xmi_element_writer_t *this_ )
    1642              : {
    1643            0 :     U8_TRACE_BEGIN();
    1644            0 :     u8_error_t export_err = U8_ERROR_NONE;
    1645              : 
    1646            0 :     io_xml_writer_decrease_indent ( &((*this_).xml_writer) );
    1647            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_UML_MODEL_END );
    1648              : 
    1649            0 :     U8_TRACE_END_ERR( export_err );
    1650            0 :     return export_err;
    1651              : }
    1652              : 
    1653            0 : u8_error_t xmi_element_writer_write_footer( xmi_element_writer_t *this_ )
    1654              : {
    1655            0 :     U8_TRACE_BEGIN();
    1656            0 :     u8_error_t export_err = U8_ERROR_NONE;
    1657              : 
    1658            0 :     io_xml_writer_decrease_indent ( &((*this_).xml_writer) );
    1659            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_DOC_END );
    1660            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
    1661              : 
    1662            0 :     U8_TRACE_END_ERR( export_err );
    1663            0 :     return export_err;
    1664              : }
    1665              : 
    1666            0 : u8_error_t xmi_element_writer_private_fake_memberend ( xmi_element_writer_t *this_,
    1667              :                                                        data_id_t relationship_id,
    1668              :                                                        data_relationship_type_t relationship_type,
    1669              :                                                        data_id_t end_object_id,
    1670              :                                                        data_classifier_type_t end_classifier_type,
    1671              :                                                        data_feature_type_t end_feature_type,
    1672              :                                                        bool is_target_end )
    1673              : {
    1674            0 :     U8_TRACE_BEGIN();
    1675            0 :     u8_error_t export_err = U8_ERROR_NONE;
    1676              : 
    1677            0 :     const bool is_composition
    1678              :         = ( relationship_type == DATA_RELATIONSHIP_TYPE_UML_CONTAINMENT )  /* fallback relationship */
    1679            0 :         ||( relationship_type == DATA_RELATIONSHIP_TYPE_UML_COMPOSITION );
    1680            0 :     const bool is_aggregation
    1681              :         = ( relationship_type == DATA_RELATIONSHIP_TYPE_UML_AGGREGATION );
    1682              : 
    1683              :     const xmi_element_info_t *classifier_info;
    1684            0 :     u8_error_t map_err = xmi_element_info_map_get_classifier( &xmi_element_info_map_standard,
    1685              :                                                               DATA_CLASSIFIER_TYPE_PACKAGE, /* if state or activity context does not matter here */
    1686              :                                                               end_classifier_type,
    1687              :                                                               &classifier_info
    1688              :                                                             );
    1689            0 :     if ( map_err != 0 )
    1690              :     {
    1691            0 :         U8_TRACE_INFO_INT("xmi_element_writer: request to write a member end of unknown type", end_classifier_type );
    1692              :     }
    1693            0 :     assert ( classifier_info != NULL );
    1694              : 
    1695              :     /* begin start member-end element */
    1696            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
    1697            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_START_TAG_START );
    1698            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_ELEMENT_PART_ELEMENT_OWNED_END );
    1699            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
    1700              : 
    1701              :     /* write type attribute */
    1702            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_TYPE_START );
    1703            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_NS_UML );
    1704            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_ELEMENT_PART_TYPE_PROPERTY );
    1705            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_TYPE_END );
    1706              : 
    1707              :     /* write id attribute */
    1708            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_START );
    1709            0 :     export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), relationship_id );
    1710            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer),
    1711              :                                            ( is_target_end
    1712              :                                            ? XMI_ELEMENT_PART_ID_FRAGMENT_TARGET_END
    1713              :                                            : XMI_ELEMENT_PART_ID_FRAGMENT_SOURCE_END ) );
    1714            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_END );
    1715              : 
    1716              :     /* write association attribute */
    1717            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_ELEMENT_PART_PROPERTY_ASSOCIATION_ATTRIBUTE );
    1718            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_VALUE_START );
    1719            0 :     export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), relationship_id );
    1720            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_VALUE_END );
    1721            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
    1722              : 
    1723              :     /* write aggregation attribute */
    1724            0 :     if (( is_composition || is_aggregation )&& is_target_end )
    1725              :     {
    1726            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_ELEMENT_PART_PROPERTY_AGGREGATION_ATTRIBUTE );
    1727            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_VALUE_START );
    1728            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer),
    1729              :                                                is_composition
    1730              :                                                ? XMI_ELEMENT_PART_PROPERTY_AGGREGATION_COMPOSITE
    1731              :                                                : XMI_ELEMENT_PART_PROPERTY_AGGREGATION_SHARED
    1732              :                                              );
    1733            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_VALUE_END );
    1734            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
    1735              :     }
    1736              : 
    1737              :     /* end start member-end element */
    1738            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_START_TAG_END );
    1739            0 :     io_xml_writer_increase_indent ( &((*this_).xml_writer) );
    1740              : 
    1741              :     /* start type element */
    1742            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
    1743            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_EMPTY_TAG_START );
    1744            0 :     if (( end_feature_type == DATA_FEATURE_TYPE_PROVIDED_INTERFACE )||( end_feature_type == DATA_FEATURE_TYPE_REQUIRED_INTERFACE )
    1745            0 :         ||(( end_feature_type == DATA_FEATURE_TYPE_VOID )&&( end_classifier_type == DATA_CLASSIFIER_TYPE_INTERFACE )))
    1746              :     {
    1747            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_ELEMENT_PART_PROPERTY_INTERFACE_ELEMENT );
    1748              :     }
    1749            0 :     else if (( end_feature_type == DATA_FEATURE_TYPE_VOID ) && xmi_element_info_is_a_class( classifier_info ) )
    1750              :     {
    1751            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_ELEMENT_PART_PROPERTY_CLASS_ELEMENT );
    1752              :     }
    1753              :     else
    1754              :     {
    1755            0 :         export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_ELEMENT_PART_PROPERTY_TYPE_ELEMENT );
    1756              :     }
    1757            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
    1758              : 
    1759              :     /* write id-ref attribute */
    1760            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_IDREF_START );
    1761            0 :     export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), end_object_id );
    1762            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_IDREF_END );
    1763              : 
    1764              :     /* end type element */
    1765            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_EMPTY_TAG_END );
    1766              : 
    1767              :     /* end member-end element */
    1768            0 :     io_xml_writer_decrease_indent ( &((*this_).xml_writer) );
    1769            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
    1770            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_END_TAG_START );
    1771            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_ELEMENT_PART_ELEMENT_OWNED_END );
    1772            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_END_TAG_END );
    1773              : 
    1774            0 :     U8_TRACE_END_ERR( export_err );
    1775            0 :     return export_err;
    1776              : }
    1777              : 
    1778            0 : u8_error_t xmi_element_writer_private_start_stereotype( xmi_element_writer_t *this_,
    1779              :                                                         const char* profile_ns,
    1780              :                                                         const utf8stringview_t *profile_type,
    1781              :                                                         const char* base_type,
    1782              :                                                         data_id_t element_id )
    1783              : {
    1784            0 :     U8_TRACE_BEGIN();
    1785            0 :     assert( profile_type != NULL );
    1786            0 :     assert( base_type != NULL );
    1787            0 :     u8_error_t export_err = U8_ERROR_NONE;
    1788              : 
    1789            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
    1790            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_START_TAG_START );
    1791            0 :     export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), profile_ns );
    1792            0 :     export_err |= io_xml_writer_write_xml_enc_view ( &((*this_).xml_writer), profile_type );
    1793            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_ATTR_SEPARATOR );
    1794              : 
    1795            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_START );
    1796            0 :     export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), element_id );
    1797            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), "#" );
    1798            0 :     export_err |= io_xml_writer_write_xml_enc_view ( &((*this_).xml_writer), profile_type );
    1799            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI_XML_ATTR_ID_END );
    1800              : 
    1801            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_EXT_BASE_ELEMENT_START );
    1802            0 :     export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), base_type );
    1803            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_EXT_BASE_ELEMENT_MIDDLE );
    1804            0 :     export_err |= xmi_atom_writer_encode_xmi_id( &((*this_).atom_writer), element_id );
    1805            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), XMI2_EXT_BASE_ELEMENT_END );
    1806              : 
    1807            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_START_TAG_END );
    1808            0 :     io_xml_writer_increase_indent ( &((*this_).xml_writer) );
    1809              : 
    1810            0 :     U8_TRACE_END_ERR( export_err );
    1811            0 :     return export_err;
    1812              : }
    1813              : 
    1814            0 : u8_error_t xmi_element_writer_private_end_stereotype( xmi_element_writer_t *this_,
    1815              :                                                       const char* profile_ns,
    1816              :                                                       const utf8stringview_t *profile_type )
    1817              : {
    1818            0 :     U8_TRACE_BEGIN();
    1819            0 :     assert( profile_type != NULL );
    1820            0 :     u8_error_t export_err = U8_ERROR_NONE;
    1821              : 
    1822            0 :     io_xml_writer_decrease_indent ( &((*this_).xml_writer) );
    1823            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_NL );
    1824            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_END_TAG_START );
    1825            0 :     export_err |= io_xml_writer_write_xml_enc ( &((*this_).xml_writer), profile_ns );
    1826            0 :     export_err |= io_xml_writer_write_xml_enc_view ( &((*this_).xml_writer), profile_type );
    1827            0 :     export_err |= io_xml_writer_write_plain ( &((*this_).xml_writer), IO_XML_WRITER_END_TAG_END );
    1828              : 
    1829            0 :     U8_TRACE_END_ERR( export_err );
    1830            0 :     return export_err;
    1831              : }
    1832              : 
    1833              : 
    1834              : /*
    1835              : Copyright 2020-2025 Andreas Warnke
    1836              : 
    1837              : Licensed under the Apache License, Version 2.0 (the "License");
    1838              : you may not use this file except in compliance with the License.
    1839              : You may obtain a copy of the License at
    1840              : 
    1841              :     http://www.apache.org/licenses/LICENSE-2.0
    1842              : 
    1843              : Unless required by applicable law or agreed to in writing, software
    1844              : distributed under the License is distributed on an "AS IS" BASIS,
    1845              : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1846              : See the License for the specific language governing permissions and
    1847              : limitations under the License.
    1848              : */
        

Generated by: LCOV version 2.0-1