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
autonome = 0
-import traceback;traceback.print_stack()
+#import traceback;traceback.print_stack()
if autonome :
from Accas import *
Proc2DuMDCommun=PROC(nom='Proc2DuMDCommun',
S2DuMDCommun= SIMP(statut='o', typ='I', defaut = 12),
)
+
#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'),
# (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
+.. _bloc-label:
+
+
Defining a conditional Group
=============================
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.
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
+.. _fact-label:
+
Defining a Group of Keywords
=============================
"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.
.. 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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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).
.. 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.
.. 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
:end-at: /xs:simpleType
And the element declaration :
-
-.. todo:: Correct the mapping (see OPER)
.. literalinclude:: ../Tests/MappingAccasXsd/cata_1_genere.xsd
:language: xml
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
:end-at: /xs:simpleType
And the element declaration :
-
-.. todo:: Correct the mapping (see OPER)
.. literalinclude:: ../Tests/MappingAccasXsd/cata_1_genere.xsd
:language: xml
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
.. 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 **<xs:sequence>** 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 **<xs:sequence>** 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 **<xs:group>** 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
_______________________________________