metanorma / stepmod-utils

Tools for working on the STEPmod repository.
1 stars 0 forks source link

Migrate `module.xml` `<mapping_table>` to YAML file `mapping.yaml` #239

Closed ronaldtse closed 7 months ago

ronaldtse commented 7 months ago

In every module.xml, there is a <mapping_table> element. We need to convert this into a mapping.yaml file (we already have mapping.changes.yaml, so let's keep it at the same place).

Let's use Shale to parse it according to the DTD (module.dtd).

This element looks like this:

  <mapping_table>
    <ae ...>
      ...
    </ae>
  </mapping_table>

Elements can look like:

      <!--  ++  AFFECTED_PLANE_TOLERANCE_ZONE  ++ -->
      <ae entity="Affected_plane_tolerance_zone" extensible="NO">
         <aimelt>tolerance_zone</aimelt>
         <source>ISO 10303-47</source>
         <aa attribute="affected_plane" assertion_to="Axis_placement_shape_element">
            <aimelt>PATH</aimelt>
            <refpath>
            tolerance_zone &lt;=
            shape_aspect &lt;-
            shape_aspect_relationship.relating_shape_aspect
            shape_aspect_relationship
            {shape_aspect_relationship.name = 'affected plane association'}
            shape_aspect_relationship.related_shape_aspect -&gt;
            shape_aspect
        </refpath>
         </aa>
      </ae>
      <!--  ++  ALL_AROUND_SHAPE_ELEMENT  ++ -->
      <ae entity="All_around_shape_element" extensible="NO">
         <aimelt>all_around_shape_aspect</aimelt>
         <source>ISO 10303-47</source>
      </ae>
      <!--  ++  TOLERANCE_ZONE  ++ -->
      <ae entity="Tolerance_zone" extensible="NO">
         <aimelt>tolerance_zone</aimelt>
         <source>ISO 10303-47</source>
         <aa attribute="form_type">
            <alt_map id="1">
               <description>If form_type has the value within_a_circle</description>
               <aimelt>tolerance_zone_form.name</aimelt>
               <refpath>{tolerance_zone_form.name = 'within a circle'}</refpath>
            </alt_map>
            <alt_map id="2">
               <description>If form_type has the value within_a_cylinder</description>
               <aimelt>tolerance_zone_form.name</aimelt>
               <refpath>{tolerance_zone_form.name = 'within a cylinder'}</refpath>
            </alt_map>
            <!-- ... -->
         </aa>
         <aa attribute="zone_for" assertion_to="Geometric_tolerance">
            <aimelt>PATH</aimelt>
            <refpath>tolerance_zone 
tolerance_zone.defining_tolerance[i] -&gt;
tolerance_zone_target = geometric_tolerance
geometric_tolerance
</refpath>
         </aa>
         <!-- ... -->
      </ae>
HassanAkbar commented 7 months ago

@ronaldtse what should be the format of the output in the mapping.yaml file?

ronaldtse commented 7 months ago

Just similar to the XML structure. Please take a first stab and then I’ll let you know any feedback.

HassanAkbar commented 7 months ago

@ronaldtse got it. I'm working on extracting shale mappings from the module.dtd file, will let you know once its ready.

TRThurman commented 7 months ago

I think we should implement fully qualified names, that is precede the type name in the reference path by the schema name. more later. Tom

On Apr 3, 2024, at 1:36 AM, Ronald Tse @.***> wrote:

In every module.xml, there is a element. We need to convert this into a mapping.yaml file (we already have mapping.changes.yaml, so let's keep it at the same place).

Let's use Shale to parse it according to the DTD (module.dtd).

This element looks like this:

...

Elements can look like:

  <!--  ++  AFFECTED_PLANE_TOLERANCE_ZONE  ++ -->
  <ae entity="Affected_plane_tolerance_zone" extensible="NO">
     <aimelt>tolerance_zone</aimelt>
     <source>ISO 10303-47</source>
     <aa attribute="affected_plane" assertion_to="Axis_placement_shape_element">
        <aimelt>PATH</aimelt>
        <refpath>
      shape_tolerance_schema.tolerance_zone &lt;=
      shape_aspect &lt;-
      shape_aspect_relationship.relating_shape_aspect
      shape_aspect_relationship
      {shape_aspect_relationship.name = 'affected plane association'}
      shape_aspect_relationship.related_shape_aspect -&gt;
      shape_aspect
  </refpath>
     </aa>
  </ae>
  <!--  ++  ALL_AROUND_SHAPE_ELEMENT  ++ -->
  <ae entity="All_around_shape_element" extensible="NO">
     <aimelt>all_around_shape_aspect</aimelt>
     <source>ISO 10303-47</source>
  </ae>
  <!--  ++  TOLERANCE_ZONE  ++ -->
  <ae entity="Tolerance_zone" extensible="NO">
     <aimelt>tolerance_zone</aimelt>
     <source>ISO 10303-47</source>
     <aa attribute="form_type">
        <alt_map id="1">
           <description>If form_type has the value within_a_circle</description>
           <aimelt>tolerance_zone_form.name</aimelt>
           <refpath>{tolerance_zone_form.name = 'within a circle'}</refpath>
        </alt_map>
        <alt_map id="2">
           <description>If form_type has the value within_a_cylinder</description>
           <aimelt>tolerance_zone_form.name</aimelt>
           <refpath>{tolerance_zone_form.name = 'within a cylinder'}</refpath>
        </alt_map>
        <!-- ... -->
     </aa>
     <aa attribute="zone_for" assertion_to="Geometric_tolerance">
        <aimelt>PATH</aimelt>
        <refpath>tolerance_zone 

tolerance_zone.defining_tolerance[i] -> tolerance_zone_target = geometric_tolerance geometric_tolerance

  </ae>

— Reply to this email directly, view it on GitHub https://github.com/metanorma/stepmod-utils/issues/239, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMMKVFTNBR62IYRVFA5ZFLY3OPORAVCNFSM6AAAAABFUVO4FKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGIZDEMBSHE3DONY. You are receiving this because you are subscribed to this thread.

TRThurman commented 7 months ago

The reference paths are PCDATA. which the dtd doesn't help with. To find the details look at clause 5.1 which defines the multi-character symbols that are part of the reference path. The multi-character symbols are critical part of checking technology.

ronaldtse commented 7 months ago

@HassanAkbar can you please help complete this the coming week? Thanks.

TRThurman commented 7 months ago

I think we should implement fully qualified names, that is precede the type name in the reference path by the schema name. more later. Tom On Apr 3, 2024, at 1:36 AM, Ronald Tse @.***> wrote: In every module.xml, there is a element. We need to convert this into a mapping.yaml file (we already have mapping.changes.yaml, so let's keep it at the same place). Let's use Shale to parse it according to the DTD (module.dtd). This element looks like this: <ae ...> ... Elements can look like: tolerance_zone ISO 10303-47 PATH shape_tolerance_schema.tolerance_zone <= shape_aspect <- shape_aspect_relationship.relating_shape_aspect shape_aspect_relationship {shape_aspect_relationship.name = 'affected plane association'} shape_aspect_relationship.related_shape_aspect -> shape_aspect all_around_shape_aspect ISO 10303-47 tolerance_zone ISO 10303-47 If form_type has the value within_a_circle tolerance_zone_form.name {tolerance_zone_form.name = 'within a circle'} If form_type has the value within_a_cylinder tolerance_zone_form.name {tolerance_zone_form.name = 'within a cylinder'} PATH tolerance_zone tolerance_zone.defining_tolerance[i] -> tolerance_zone_target = geometric_tolerance geometric_tolerance — Reply to this email directly, view it on GitHub <#239>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMMKVFTNBR62IYRVFA5ZFLY3OPORAVCNFSM6AAAAABFUVO4FKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGIZDEMBSHE3DONY. You are receiving this because you are subscribed to this thread.

@ronaldtse @HassanAkbar It is likely that in some cases, the query to find the schema name will fail. Ideas? Maybe just ignore the failure and continue. Then we can run a post-process check for missing schema name.