lutaml / expressir

Ruby parser for the ISO EXPRESS language
3 stars 3 forks source link

Add methods to access EXPRESS XML data model #3

Closed ronaldtse closed 3 years ago

ronaldtse commented 4 years ago

Given this file, parsed by Reeper: https://github.com/metanorma/annotated-express/blob/master/data/resources/aic_curve_swept_solid/aic_curve_swept_solid.xml

SCHEMA aic_curve_swept_solid '{iso standard 10303 part(523) version(2) object(1) aic_curve_swept_solid(1)}';

  USE FROM measure_schema; -- ISO 10303-41

  USE FROM geometry_schema  -- ISO 10303-42
    (axis2_placement_2d,
...

  ENTITY curve_swept_solid_shape_representation
    SUBTYPE OF (shape_representation);
  WHERE
  WR1: SIZEOF (QUERY (it <* SELF.items |
  ...
  END_ENTITY;

I want to be able to do something like this:

context = Reeper.load('aic_curve_swept_solid.xml')

x = context.find('aic_curve_swept_solid')
=> the SCHEMA object

x.use_from
=> <#UseFrom measure_schema>, <#UseFrom geometry_schema>...

x.find('curve_swept_solid_shape_representation')
=> <#Entity curve_swept_solid_shape_representation>

csssr = x.find('curve_swept_solid_shape_representation')
=> <#Entity curve_swept_solid_shape_representation>

csssr = context.find('curve_swept_solid_shape_representation')
=> <#Entity curve_swept_solid_shape_representation>

csssr_wr1 = context.where.first
=> <#WhereRule>

annotation = context.find("curve_swept_solid_shape_representation .ruled_surface_swept_area_solid")
=> <#Annotation ruled_surface_swept_area_solid>

annotation = context.find("ruled_surface_swept_area_solid")
=> <#Annotation ruled_surface_swept_area_solid>

annotation.target
=> "ruled_surface_swept_area_solid"

annotation.text
=> "A *ruled_surface_swept_area_solid* is a type of ..."
ronaldtse commented 4 years ago

@DmitryDrobotov can you help with this? Thanks! @abunashir would be also able to help answer any questions.

ronaldtse commented 3 years ago

We are no longer going to work with the EXPRESS XML format generated from Express Engine. Closing. Some parts of the imaginary syntax can go into a new issue.