From: Eric Fayolle Date: Mon, 2 Dec 2019 15:45:22 +0000 (+0100) Subject: Mise à jour docCatawwriter X-Git-Tag: V200520bis~93 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=261659b49553df29d7da8dd20528c2e08cb3ee45;p=tools%2Feficas.git Mise à jour docCatawwriter --- diff --git a/Tests/MappingAccasXsd/TestMultipleCata/Makefile b/Tests/MappingAccasXsd/TestMultipleCata/Makefile index cefb6c3a..a0830328 100755 --- a/Tests/MappingAccasXsd/TestMultipleCata/Makefile +++ b/Tests/MappingAccasXsd/TestMultipleCata/Makefile @@ -26,6 +26,14 @@ all: xsdAll driverAll xsdAll: xsdTestMutlipleCata driverAll: pyTestMutlipleCata +#Ecrire une génération des dépendences à partir des includes xsd +cata_MDCommun_genere.xsd: cata_modeleCommun_genere.xsd +cata_CFDCommun_genere.xsd: cata_modeleCommun_genere.xsd +cata_MD1_genere.xsd: cata_MDCommun_genere.xsd cata_modeleCommun_genere.xsd +cata_MD2_genere.xsd: cata_MDCommun_genere.xsd cata_modeleCommun_genere.xsd +cata_CFD1_genere.xsd: cata_CFDCommun_genere.xsd cata_modeleCommun_genere.xsd +cata_CFD2_genere.xsd: cata_CFDCommun_genere.xsd cata_modeleCommun_genere.xsd + xsdTestMutlipleCata: cata_CFD1_genere.xsd cata_CFD2_genere.xsd cata_CFDCommun_genere.xsd cata_MD1_genere.xsd cata_MD2_genere.xsd cata_MDCommun_genere.xsd cata_modeleCommun_genere.xsd pyTestMutlipleCata: cata_CFD1_genere.py cata_CFD2_genere.py cata_CFDCommun_genere.py cata_MD1_genere.py cata_MD2_genere.py cata_MDCommun_genere.py cata_modeleCommun_genere.py diff --git a/Tests/MappingAccasXsd/TestMultipleCata/cata_MD1.py b/Tests/MappingAccasXsd/TestMultipleCata/cata_MD1.py index 0d0a0df3..fc7764b7 100755 --- a/Tests/MappingAccasXsd/TestMultipleCata/cata_MD1.py +++ b/Tests/MappingAccasXsd/TestMultipleCata/cata_MD1.py @@ -1,5 +1,5 @@ autonome = 0 -import traceback;traceback.print_stack() +#import traceback;traceback.print_stack() if autonome : from Accas import * diff --git a/Tests/MappingAccasXsd/TestMultipleCata/cata_MDCommun.py b/Tests/MappingAccasXsd/TestMultipleCata/cata_MDCommun.py index d220be45..626e498e 100755 --- a/Tests/MappingAccasXsd/TestMultipleCata/cata_MDCommun.py +++ b/Tests/MappingAccasXsd/TestMultipleCata/cata_MDCommun.py @@ -17,3 +17,4 @@ Proc1DuMDCommun=PROC(nom='Proc1DuMDCommun', Proc2DuMDCommun=PROC(nom='Proc2DuMDCommun', S2DuMDCommun= SIMP(statut='o', typ='I', defaut = 12), ) + diff --git a/Tests/MappingAccasXsd/cata_1.py b/Tests/MappingAccasXsd/cata_1.py index 06a94f71..d7bbf7e6 100644 --- a/Tests/MappingAccasXsd/cata_1.py +++ b/Tests/MappingAccasXsd/cata_1.py @@ -18,6 +18,7 @@ class MeshU(UserASSD): pass #Be careful when modidying the order/names od the test_simp since they are used bye the documentation xsd_mapping.rst #beginJdC JdC = JDC_CATA(code='Test1',) + Test_proc_1 = PROC(nom = 'Test_proc_1', test_simp_1 = SIMP(statut='o', typ='TXM', defaut='text_simp_txt_1'), test_simp_1_1 = SIMP(statut='o', typ='TXM', defaut='text_simp_txt_1'), @@ -92,8 +93,52 @@ Meshes = PROC(nom = 'Meshes', # (il faut qu'il soit crée au préalable) # statut='o', ?? MyFieldBis = PROC(nom='MyFieldBis', - onMesh = SIMP(statut='o',typ=MeshU), - ) -#endJdC + onMesh = SIMP(statut='o',typ=MeshU),) #UserASSD c'est une référence sur un objet alors qu'un ASSD c'est l'objet retourné. + +Test_proc_2 = PROC(nom = 'Test_proc_2', + job_properties = FACT(statut='o', + job_duration = SIMP(statut='o', typ='R', defaut=1000, val_min=0), + stack_size = SIMP(statut='f', typ='R', defaut=1000, val_min=0), + print_frequency = SIMP(statut='f', typ='TXM', defaut='every', into=['every','never','sometimes']), + close_time = SIMP(statut='f', typ='R', defaut=1000, val_min=0), + ) #job_properties +) + +Test_proc_3 = PROC(nom = 'Test_proc_3', + ThresholdExceedence = FACT ( + Event = FACT ( + Threshold = SIMP ( typ = "R", ang = "Failure threshold",), + ComparisonOperator = SIMP ( typ = "TXM", into = ( "Less", "LessOrEqual", "Equal", "GreaterOrEqual", "Greater" ),), + ), + Method = SIMP ( typ = "TXM", into = ( "Simulation", "FORM_SORM" ), ang = "Method",), + ) #ThresholdExceedence +) + +Test_proc_4 = PROC(nom = 'Test_proc_4', + species_parameters = FACT(statut='o', max="**", + species_name = SIMP(statut='o',typ='TXM'), + species_mass = SIMP(statut='o',typ='R',defaut=1.0), + species_is_frozen = SIMP(statut='f',typ=bool,), + ) #species_parameters +) + +Test_proc_5 = PROC(nom = 'Test_proc_5', + print_frequency = SIMP(statut='f', typ='TXM', defaut='every', into=['every','periodically','sometimes']), + frequency_every = BLOC ( condition= "print_frequency == 'every'", + particule_to_be_printed = SIMP(statut='o',typ='TXM', ), + ), #frequency_every + frequ_not_every = BLOC ( condition= "print_frequency != 'every'", + step_to_be_printed = SIMP(statut='o',typ='I', max ="**" ), + ), #frequ_not_every +)#Test_proc_5 + +Test_proc_6 = PROC(nom = 'Test_proc_6', + wind_speed = SIMP(statut='o', typ = 'R'), + b_ask_wind_direction = BLOC ( condition= 'wind_speed > 0.5', + wind_direction = SIMP(statut='o', typ='TXM'), + rain_speed = SIMP(statut='f', typ='R', val_min = 1, val_max=20), + ), #b_ask_wind_direction +) #Test_proc_6 +#endJdC diff --git a/docCataWriter/bloc.rst b/docCataWriter/bloc.rst index 0d7c265a..0a16a606 100644 --- a/docCataWriter/bloc.rst +++ b/docCataWriter/bloc.rst @@ -1,3 +1,6 @@ +.. _bloc-label: + + Defining a conditional Group ============================= @@ -23,19 +26,15 @@ Syntax is : Python statement is often <, >, == but this can be any expression returning True or False. BLOC can be seen as an 'if' statement -:: - - print_frequency = SIMP(statut='f', typ='TXM', defaut='every', into=['every','periodically','sometimes']), - frequency_every = BLOC ( condition= "print_frequency == 'every'", - particule_to_be_printed = SIMP(statut='o',typ='TXM', ), - ), - frequ_not_every = BLOC ( condition= "print_frequency != 'every'", - step_to_be_printed = SIMP(statut='o',typ=I, max ="**" ), - ), - - # this means : - # if frequency_every == 'every', particule_printed (only one) is requested - # else step_to_be_printed (list) is required. + +.. literalinclude:: ../Tests/MappingAccasXsd/cata_1.py + :language: python + :start-after: Test_proc_5 + :end-before: #Test_proc_5 + +This means : + * if frequency_every == 'every', particule_printed (only one) is requested + * else step_to_be_printed (list) is required. Remember this is as python code. All "keywords" are arguments and in python, arguments are separated by comma "," and must be inside parenthesis. Note that conditions are statement but also python string. Use single quotes inside double quotes if needed. @@ -44,20 +43,17 @@ Remember this is as python code. All "keywords" are arguments and in python, arg Cardinality ~~~~~~~~~~~ - - BLOC appears depending on the evaluation of the conditional statement. it has no mandatory or optional status - - BLOC cannot be repeat but included FACT or SIMP can - - if keywords inside the BLOC have a status. this status is applied within the BLOC +- BLOC appears depending on the evaluation of the conditional statement. it has no mandatory or optional status +- BLOC cannot be repeat but included FACT or SIMP can +- if keywords inside the BLOC have a status. this status is applied within the BLOC -:: - - wind_speed = SIMP(statut='o', typ = 'R'), - b_ask_wind_direction = BLOC ( condition= 'wind_speed > 0.5', - wind_direction = SIMP(statut='o', typ='TXM'), - rain_speed = SIMP(statut='f', typ='R', min_val = 1, max_val=20), - ), - - # this means : - # if wind_speed > 0.5, wind_direction is needed and rain_speed can be added +.. literalinclude:: ../Tests/MappingAccasXsd/cata_1.py + :language: python + :start-after: Test_proc_6 + :end-before: #Test_proc_6 + +This means : + * if wind_speed > 0.5, wind_direction is needed and rain_speed can be added diff --git a/docCataWriter/fact.rst b/docCataWriter/fact.rst index d04e94ef..0f122bc7 100644 --- a/docCataWriter/fact.rst +++ b/docCataWriter/fact.rst @@ -1,3 +1,5 @@ +.. _fact-label: + Defining a Group of Keywords ============================= @@ -22,40 +24,29 @@ Syntax is : "myGroup" is a python label. A group can not have the same name as its brothers. It contains simple elements or groups. There is no recursivity depth limit. -:: - - job_properties = FACT(statut='o', - job_duration = SIMP(statut='o', typ='R', defaut=1000, val_min=0), - stack_size = SIMP(statut='f', typ='R', defaut=1000, val_min=0), - print_frequency = SIMP(statut='f', typ='TXM', defaut='every', into=['every','never','sometimes']), - close_time = SIMP(statut='f', typ='R', defaut=1000, val_min=0), - ), -Definition of FACT including an other FACT : +.. literalinclude:: ../Tests/MappingAccasXsd/cata_1.py + :language: python + :start-at: job_properties + :end-at: #job_properties -:: +Definition of FACT including an other FACT : - ThresholdExceedence = FACT ( - Event = FACT ( - Threshold = SIMP ( typ = "R", ang = "Failure threshold",), - ComparisonOperator = SIMP ( typ = "TXM", into = ( "Less", "LessOrEqual", "Equal", "GreaterOrEqual", "Greater" ),), - ), - Method = SIMP ( typ = "TXM", into = ( "Simulation", "FORM_SORM" ), ang = "Method",), - ), # +.. literalinclude:: ../Tests/MappingAccasXsd/cata_1.py + :language: python + :start-at: ThresholdExceedence + :end-at: #ThresholdExceedence Cardinality ~~~~~~~~~~~ It is possible to constrain the number of instances (cardinality) of a FACT. The cardinality is specified using the min and max attributes. If min=max=1 (default), the FACT appears only once in a valid dataset. If max > 1, the group of parameters can appear more than once. min/max specifies the minimum/maximum number of repetitions. "**" means there is no upper limit for the maximal cardinality. -:: - - species_parameters = FACT(statut='o', max="**", - species_name = SIMP(statut='o',typ='TXM'), - species_mass = SIMP(statut='o',typ='R',defaut=1.0), - species_is_frozen = SIMP(statut='f',typ=bool,), - ) +.. literalinclude:: ../Tests/MappingAccasXsd/cata_1.py + :language: python + :start-at: species_parameters + :end-at: #species_parameters Note that a group status can be mandatory or optional. The group contents optional and mandatory elements, independantly of its status. In the previous example, species_parameters has to be defined at least one time (in a valid dataset). Inside this group, species_is_frozen is not mandatory. For each instance of species_parameters, species_is_frozen may or may not appear. diff --git a/docCataWriter/xsd_mapping.rst b/docCataWriter/xsd_mapping.rst index 5dc71117..5b07ef71 100644 --- a/docCataWriter/xsd_mapping.rst +++ b/docCataWriter/xsd_mapping.rst @@ -52,7 +52,7 @@ You can use the driver to load an xml file like |cata_1_test1.xml| conforming to .. literalinclude:: ../Tests/MappingAccasXsd/cata_1_test_1.py :end-before: CONFIGURATION -Once the .xml file is loaded you can display it in a prety xml format. +Once the .xml file is loaded you can display it in a pretty xml format. .. literalinclude:: ../Tests/MappingAccasXsd/cata_1_test_1.py :start-after: _setOrphanElementInContent @@ -67,7 +67,7 @@ Declaring an SIMP with a *type* attribute ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The *SIMP* is mapped to an xsd global type and an xsd element. -The xsd element is locally defined and may appears multiple times depending on the use the catalog does of it. +The xsd element is defined locally and may appear multiple times depending on the use the catalog does of it. If we look at the test_simp_2 in |cata_1.py| content, we get an example of an *SIMP* of *type* 'I' (int type). @@ -130,8 +130,8 @@ And the XSD element local declaration : .. note:: If two *SIMP* have the same name (so, not sibling *SIMP* ) and different *type* attributes, there will be two local element declarations with the same name and two global xsd **type** with two different typenames -Defining how many times a *SIMP* may appears -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Defining how many times a *SIMP* may appear +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ If we look at the test_simp_2_3 in |cata_1.py| content, we get an example of an *SIMP* of type 'I' using *min* and *max* attributes. @@ -388,8 +388,6 @@ The *UserASSD* class declared this way is quite the same notion as using an *ASS .. todo:: Expliciter le mécanisme en oeuvre au niveau python. You get the xsd type : - -.. todo:: Correct the mapping (see OPER) .. literalinclude:: ../Tests/MappingAccasXsd/cata_1_genere.xsd :language: xml @@ -397,8 +395,6 @@ You get the xsd type : :end-at: /xs:simpleType And the element declaration : - -.. todo:: Correct the mapping (see OPER) .. literalinclude:: ../Tests/MappingAccasXsd/cata_1_genere.xsd :language: xml @@ -420,8 +416,6 @@ The *SIMP* reference is done this way: Note the User_Data type given to the *typ* attribute. You get the xsd type : - -.. todo:: Correct the mapping (see OPER) .. literalinclude:: ../Tests/MappingAccasXsd/cata_1_genere.xsd :language: xml @@ -429,8 +423,6 @@ You get the xsd type : :end-at: /xs:simpleType And the element declaration : - -.. todo:: Correct the mapping (see OPER) .. literalinclude:: ../Tests/MappingAccasXsd/cata_1_genere.xsd :language: xml @@ -572,7 +564,7 @@ Concerning the element declaration : The way we choose to map the *OPER* to xsd allows users to create a cross reference system using name of produced structure in their dataset. -.. todo:: : Generate a schema validation rule to check that a name used as a reference is unique and exists in the corresponding object, we have to add in the root element declaration the following code : +.. todo:: Generate a schema validation rule to check that a name used as a reference is unique and exists in the corresponding object, we have to add in the root element declaration the following code : .. code-block:: xml @@ -703,11 +695,118 @@ Concerning the element declaration, you get : .. todo:: We have to write a rule to check this. -Understanding the XSD mapping for FACT and BLOC -________________________________________________ +Understanding the XSD mapping for FACT +______________________________________ +As explain in :ref:`fact-label` section, the *FACT* keyword provide a way of grouping elements. It may appear *PROC*, *OPER*, *BLOC* or *FACT*. If we review the following catalog from the :ref:`fact-label` section : + +.. literalinclude:: ../Tests/MappingAccasXsd/cata_1.py + :language: python + :start-at: ThresholdExceedence + :end-at: #ThresholdExceedence + +You get the two xsd complex types using the **** xsd element : + +.. literalinclude:: ../Tests/MappingAccasXsd/cata_1_genere.xsd + :language: xml + :start-at: name="T_ThresholdExceedence" + :end-at: /xs:complexType + +and + +.. literalinclude:: ../Tests/MappingAccasXsd/cata_1_genere.xsd + :language: xml + :start-at: name="T_Event" + :end-at: /xs:complexType + + +The element declaration is : + +.. literalinclude:: ../Tests/MappingAccasXsd/cata_1_genere.xsd + :language: xml + :dedent: 2 + :start-at: name="ThresholdExceedence" + :end-at: name="ThresholdExceedence" + +In order to illustrate the management of the cardinality, we can review the second example from the :ref:`fact-label` section : + + +.. literalinclude:: ../Tests/MappingAccasXsd/cata_1.py + :language: python + :start-at: species_parameters + :end-at: #species_parameters + +You get the xsd complex types using the **** xsd element : + +.. literalinclude:: ../Tests/MappingAccasXsd/cata_1_genere.xsd + :language: xml + :start-at: name="T_species_parameters" + :end-at: /xs:complexType + + +The element declaration is : + +.. literalinclude:: ../Tests/MappingAccasXsd/cata_1_genere.xsd + :language: xml + :dedent: 2 + :start-at: name="species_parameters" + :end-at: name="species_parameters" + +.. note:: The *FACT* cardinality is carry out by the **maxOccurs** attribute of the element declaration. The **minOccurs** attribute deserve the *statut* eficas attribute. + +Understanding the XSD mapping for BLOC +______________________________________ + +As explain in :ref:`bloc-label` section, the *BLOC* keyword provides a conditional way to make appear a group of elements. Apart of the *condition* eficas attribute, it's quite the same as the *FACT* keyword. + +If we review the following catalog from the :ref:`fact-label` section : + +.. literalinclude:: ../Tests/MappingAccasXsd/cata_1.py + :language: python + :start-after: Test_proc_5 + :end-before: #Test_proc_5 + +You get the two xsd complex types using the **** xsd element : + +.. literalinclude:: ../Tests/MappingAccasXsd/cata_1_genere.xsd + :language: xml + :start-at: name="T_frequency_every" + :end-at: /xs:group + +.. literalinclude:: ../Tests/MappingAccasXsd/cata_1_genere.xsd + :language: xml + :start-at: name="T_frequ_not_every" + :end-at: /xs:group + +The content of these groups may appear or not in the parent structure. If they appear, they will appear "as is", without any additionnal element definition. This mecanism comes from the use of the **group ref** xsd statement : + +The **group ref** declarations are : + +.. literalinclude:: ../Tests/MappingAccasXsd/cata_1_genere.xsd + :language: xml + :dedent: 2 + :start-after: name="T_Test_proc_5" + :end-before: /xs:complexType + +.. note:: Note that **minOccurs** is always 0 and **maxOccurs** is always 1. This is because *BLOC* does not have *min*,*max* eficas attributes. + +.. note:: A ambiguity problem may appear if the an element with the same name is present in different group's content. + +.. todo:: The *BLOC* xsd mapping must be refine. We may use **key**, **keyref** xsd element to restrict the possibility of activating only one branch of the conditional. However, the semantic of the *BLOC* keyword is wide. + +We may have that kind of usescases : + * A conditional E1 python expression for a B1 bloc with content C1 following a not(E1) expression for a B2 bloc with content C2 + * A conditional E1 python expression for a B1 bloc with content C1 following a not(E1) expression for a B2 bloc with content almost C1, the difference being the type of an SIMP with the same name + * A conditional E1 python expression for a B1 bloc with content C1 following a E2 expression for a B2 bloc with content C2 including partially or totally C1 + * .... + + + +Understanding the XSD mapping for included catalogs +___________________________________________________ + Understanding the XSD mapping for RULES _______________________________________