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