expressir 0.2.4-x64-mingw32 → 0.2.10-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (534) hide show
  1. checksums.yaml +5 -5
  2. data/.cross_rubies +30 -0
  3. data/.github/workflows/rake.yml +45 -46
  4. data/.github/workflows/release.yml +83 -75
  5. data/.gitignore +17 -15
  6. data/.gitmodules +3 -3
  7. data/.rspec +2 -2
  8. data/.rubocop.yml +508 -508
  9. data/Gemfile +4 -6
  10. data/README.adoc +147 -147
  11. data/Rakefile +11 -17
  12. data/bin/console +12 -12
  13. data/bin/rspec +29 -29
  14. data/bin/setup +8 -8
  15. data/demo.rb +18 -18
  16. data/docs/development.md +90 -90
  17. data/exe/expressir +20 -20
  18. data/exe/generate-parser +47 -47
  19. data/expressir.gemspec +43 -40
  20. data/lib/expressir.rb +21 -21
  21. data/lib/expressir/cli.rb +27 -27
  22. data/lib/expressir/cli/ui.rb +36 -36
  23. data/lib/expressir/config.rb +23 -23
  24. data/lib/expressir/express.rb +11 -11
  25. data/lib/expressir/express/aggregate_dimension.rb +38 -38
  26. data/lib/expressir/express/attribute.rb +15 -15
  27. data/lib/expressir/express/comment.rb +7 -7
  28. data/lib/expressir/express/defined_type.rb +36 -36
  29. data/lib/expressir/express/derived.rb +65 -65
  30. data/lib/expressir/express/derived_aggregate.rb +43 -43
  31. data/lib/expressir/express/entity.rb +137 -137
  32. data/lib/expressir/express/explicit.rb +70 -70
  33. data/lib/expressir/express/explicit_aggregate.rb +46 -46
  34. data/lib/expressir/express/explicit_or_derived.rb +16 -16
  35. data/lib/expressir/express/global_rule.rb +44 -44
  36. data/lib/expressir/express/interface_specification.rb +51 -51
  37. data/lib/expressir/express/interfaced_item.rb +38 -38
  38. data/lib/expressir/express/inverse.rb +46 -46
  39. data/lib/expressir/express/inverse_aggregate.rb +37 -37
  40. data/lib/expressir/express/model_element.rb +7 -7
  41. data/lib/expressir/express/named_type.rb +19 -19
  42. data/lib/expressir/express/remark.rb +8 -8
  43. data/lib/expressir/express/repository.rb +306 -306
  44. data/lib/expressir/express/schema_definition.rb +96 -96
  45. data/lib/expressir/express/subtype_constraint.rb +14 -14
  46. data/lib/expressir/express/type.rb +26 -26
  47. data/lib/expressir/express/type_aggregate.rb +42 -42
  48. data/lib/expressir/express/type_enum.rb +29 -29
  49. data/lib/expressir/express/type_parser.rb +45 -45
  50. data/lib/expressir/express/type_select.rb +82 -82
  51. data/lib/expressir/express/unique_rule.rb +35 -35
  52. data/lib/expressir/express/where_rule.rb +32 -32
  53. data/lib/expressir/express_exp/2.4/express_parser.so +0 -0
  54. data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
  55. data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
  56. data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
  57. data/lib/expressir/express_exp/3.0/express_parser.so +0 -0
  58. data/lib/expressir/express_exp/formatter.rb +1500 -1449
  59. data/lib/expressir/express_exp/parser.rb +53 -35
  60. data/lib/expressir/express_exp/visitor.rb +2555 -2450
  61. data/lib/expressir/express_parser.rb +30 -30
  62. data/lib/expressir/model.rb +67 -64
  63. data/lib/expressir/model/attribute.rb +28 -26
  64. data/lib/expressir/model/constant.rb +18 -16
  65. data/lib/expressir/model/entity.rb +38 -45
  66. data/lib/expressir/model/enumeration_item.rb +12 -10
  67. data/lib/expressir/model/expressions/aggregate_initializer.rb +12 -12
  68. data/lib/expressir/model/expressions/aggregate_item.rb +14 -14
  69. data/lib/expressir/model/expressions/attribute_reference.rb +14 -14
  70. data/lib/expressir/model/expressions/binary_expression.rb +39 -39
  71. data/lib/expressir/model/expressions/call.rb +14 -14
  72. data/lib/expressir/model/expressions/entity_constructor.rb +14 -14
  73. data/lib/expressir/model/expressions/group_reference.rb +14 -14
  74. data/lib/expressir/model/expressions/index_reference.rb +16 -16
  75. data/lib/expressir/model/expressions/interval.rb +20 -20
  76. data/lib/expressir/model/expressions/query_expression.rb +27 -25
  77. data/lib/expressir/model/expressions/simple_reference.rb +12 -12
  78. data/lib/expressir/model/expressions/unary_expression.rb +18 -18
  79. data/lib/expressir/model/function.rb +55 -61
  80. data/lib/expressir/model/identifier.rb +9 -8
  81. data/lib/expressir/model/informal_proposition.rb +13 -0
  82. data/lib/expressir/model/interface.rb +17 -17
  83. data/lib/expressir/model/literals/binary.rb +12 -12
  84. data/lib/expressir/model/literals/integer.rb +12 -12
  85. data/lib/expressir/model/literals/logical.rb +16 -16
  86. data/lib/expressir/model/literals/real.rb +12 -12
  87. data/lib/expressir/model/literals/string.rb +14 -14
  88. data/lib/expressir/model/model_element.rb +67 -0
  89. data/lib/expressir/model/parameter.rb +18 -16
  90. data/lib/expressir/model/procedure.rb +53 -59
  91. data/lib/expressir/model/renamed_ref.rb +12 -12
  92. data/lib/expressir/model/repository.rb +18 -18
  93. data/lib/expressir/model/rule.rb +58 -61
  94. data/lib/expressir/model/schema.rb +55 -66
  95. data/lib/expressir/model/scope.rb +62 -16
  96. data/lib/expressir/model/statements/alias.rb +27 -25
  97. data/lib/expressir/model/statements/assignment.rb +14 -14
  98. data/lib/expressir/model/statements/call.rb +14 -14
  99. data/lib/expressir/model/statements/case.rb +16 -16
  100. data/lib/expressir/model/statements/case_action.rb +14 -14
  101. data/lib/expressir/model/statements/compound.rb +12 -12
  102. data/lib/expressir/model/statements/escape.rb +7 -7
  103. data/lib/expressir/model/statements/if.rb +16 -16
  104. data/lib/expressir/model/statements/null.rb +7 -7
  105. data/lib/expressir/model/statements/repeat.rb +35 -33
  106. data/lib/expressir/model/statements/return.rb +12 -12
  107. data/lib/expressir/model/statements/skip.rb +7 -7
  108. data/lib/expressir/model/subtype_constraint.rb +28 -26
  109. data/lib/expressir/model/type.rb +33 -23
  110. data/lib/expressir/model/types/aggregate.rb +18 -16
  111. data/lib/expressir/model/types/array.rb +20 -20
  112. data/lib/expressir/model/types/bag.rb +16 -16
  113. data/lib/expressir/model/types/binary.rb +14 -14
  114. data/lib/expressir/model/types/boolean.rb +7 -7
  115. data/lib/expressir/model/types/enumeration.rb +18 -18
  116. data/lib/expressir/model/types/generic.rb +14 -12
  117. data/lib/expressir/model/types/generic_entity.rb +14 -12
  118. data/lib/expressir/model/types/integer.rb +7 -7
  119. data/lib/expressir/model/types/list.rb +18 -18
  120. data/lib/expressir/model/types/logical.rb +7 -7
  121. data/lib/expressir/model/types/number.rb +7 -7
  122. data/lib/expressir/model/types/real.rb +12 -12
  123. data/lib/expressir/model/types/select.rb +20 -20
  124. data/lib/expressir/model/types/set.rb +16 -16
  125. data/lib/expressir/model/types/string.rb +14 -14
  126. data/lib/expressir/model/unique.rb +16 -14
  127. data/lib/expressir/model/variable.rb +18 -16
  128. data/lib/expressir/model/where.rb +16 -14
  129. data/lib/expressir/parser.rb +6 -6
  130. data/lib/expressir/parser/owl_parser.rb +8 -8
  131. data/lib/expressir/version.rb +3 -3
  132. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +9589 -9589
  133. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +36619 -36619
  134. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +13293 -13293
  135. data/original/examples/employment/eclipse/.project +17 -17
  136. data/original/examples/employment/eclipse/Express/employment_schema.exp +33 -33
  137. data/original/examples/employment/eclipse/Express/employment_schema.xmi +77 -77
  138. data/original/examples/employment/eclipse/Express/employment_schema.xml +92 -92
  139. data/original/examples/employment/eclipse/Models/Employment.uml +4 -4
  140. data/original/examples/employment/eclipse/Models/Employment.umldi +240 -240
  141. data/original/examples/employment/eclipse/readme.txt +6 -6
  142. data/original/examples/employment/employment_schema.exp +33 -33
  143. data/original/examples/employment/employment_schema.rb +232 -232
  144. data/original/examples/employment/employment_schema.xml +92 -92
  145. data/original/examples/employment/employment_schema___module.rb +46 -46
  146. data/original/examples/employment/employment_schema___p28attr.rb +126 -126
  147. data/original/examples/employment/employment_schema___p28inst.rb +26 -26
  148. data/original/examples/employment/example_employment_data.xml +1 -1
  149. data/original/examples/employment/example_employment_data_copy.xml +1 -1
  150. data/original/examples/employment/example_employment_reader.rb +30 -30
  151. data/original/examples/employment/example_employment_writer.rb +51 -51
  152. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +3710 -3710
  153. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +35880 -35880
  154. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +15357 -15357
  155. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +9467 -9467
  156. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +8404 -8404
  157. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +43147 -43147
  158. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +18341 -18341
  159. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +11631 -11631
  160. data/original/examples/syntax/remark.exp +189 -145
  161. data/original/examples/syntax/remark_formatted.exp +213 -174
  162. data/original/examples/syntax/simple.exp +3 -0
  163. data/original/examples/syntax/source.exp +16 -0
  164. data/original/examples/syntax/syntax.exp +323 -310
  165. data/original/examples/syntax/syntax_formatted.exp +753 -1186
  166. data/original/exp2ruby.rb +525 -525
  167. data/original/expsm.rb +34 -34
  168. data/original/mapping_owl.rb +1018 -1018
  169. data/original/mapping_sysml.rb +2281 -2281
  170. data/original/mapping_uml2.rb +598 -598
  171. data/original/mapping_uml2_eclipse.rb +433 -433
  172. data/original/reeper.rb +134 -134
  173. data/rakelib/cross-ruby.rake +308 -0
  174. data/spec/acceptance/express_to_owl_spec.rb +18 -18
  175. data/spec/acceptance/version_spec.rb +12 -12
  176. data/spec/expressir/express/repository_spec.rb +25 -25
  177. data/spec/expressir/express_exp/ap233_spec.rb +22 -22
  178. data/spec/expressir/express_exp/format_remark_spec.rb +28 -28
  179. data/spec/expressir/express_exp/format_syntax_spec.rb +28 -28
  180. data/spec/expressir/express_exp/head_source_spec.rb +38 -0
  181. data/spec/expressir/express_exp/parse_multiple_spec.rb +32 -0
  182. data/spec/expressir/express_exp/parse_remark_spec.rb +411 -345
  183. data/spec/expressir/express_exp/parse_syntax_spec.rb +3048 -2998
  184. data/spec/expressir/express_exp/source_spec.rb +29 -0
  185. data/spec/expressir/model/model_element_spec.rb +59 -0
  186. data/spec/expressir/model/{find_spec.rb → scope_spec.rb} +123 -110
  187. data/spec/expressr_spec.rb +5 -5
  188. data/spec/spec_helper.rb +17 -17
  189. data/spec/support/console_helper.rb +29 -29
  190. metadata +41 -371
  191. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +0 -118
  192. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +0 -637
  193. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -984
  194. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +0 -652
  195. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -990
  196. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +0 -652
  197. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -990
  198. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +0 -652
  199. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -990
  200. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp-ios/Info.plist +0 -26
  201. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp-ios/antlrcpp_ios.h +0 -17
  202. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +0 -3024
  203. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  204. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  205. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4.xcscheme +0 -76
  206. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_ios.xcscheme +0 -80
  207. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_static.xcscheme +0 -80
  208. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorListener.cpp +0 -10
  209. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorListener.h +0 -167
  210. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorStrategy.cpp +0 -10
  211. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorStrategy.h +0 -121
  212. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +0 -34
  213. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.h +0 -27
  214. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +0 -155
  215. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +0 -69
  216. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BailErrorStrategy.cpp +0 -61
  217. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BailErrorStrategy.h +0 -59
  218. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BaseErrorListener.cpp +0 -25
  219. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BaseErrorListener.h +0 -36
  220. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BufferedTokenStream.cpp +0 -414
  221. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BufferedTokenStream.h +0 -200
  222. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CharStream.cpp +0 -11
  223. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CharStream.h +0 -37
  224. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +0 -195
  225. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.h +0 -158
  226. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.cpp +0 -39
  227. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.h +0 -74
  228. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenStream.cpp +0 -78
  229. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenStream.h +0 -79
  230. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ConsoleErrorListener.cpp +0 -15
  231. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ConsoleErrorListener.h +0 -35
  232. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +0 -333
  233. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.h +0 -466
  234. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DiagnosticErrorListener.cpp +0 -84
  235. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DiagnosticErrorListener.h +0 -80
  236. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +0 -64
  237. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +0 -99
  238. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +0 -51
  239. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +0 -32
  240. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/InputMismatchException.cpp +0 -18
  241. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/InputMismatchException.h +0 -24
  242. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.cpp +0 -12
  243. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +0 -218
  244. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/InterpreterRuleContext.cpp +0 -19
  245. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/InterpreterRuleContext.h +0 -45
  246. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +0 -295
  247. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +0 -196
  248. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -75
  249. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +0 -52
  250. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerNoViableAltException.cpp +0 -36
  251. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerNoViableAltException.h +0 -31
  252. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.cpp +0 -92
  253. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.h +0 -88
  254. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/NoViableAltException.cpp +0 -46
  255. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/NoViableAltException.h +0 -42
  256. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +0 -648
  257. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +0 -467
  258. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +0 -306
  259. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +0 -179
  260. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +0 -141
  261. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +0 -147
  262. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.cpp +0 -53
  263. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.h +0 -38
  264. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -66
  265. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.h +0 -98
  266. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +0 -167
  267. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +0 -164
  268. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +0 -143
  269. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +0 -137
  270. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContextWithAltNum.cpp +0 -27
  271. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContextWithAltNum.h +0 -32
  272. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +0 -53
  273. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.h +0 -155
  274. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.cpp +0 -9
  275. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +0 -92
  276. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenFactory.h +0 -30
  277. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.cpp +0 -9
  278. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.h +0 -85
  279. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStream.cpp +0 -11
  280. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStream.h +0 -137
  281. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +0 -425
  282. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +0 -293
  283. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +0 -211
  284. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +0 -123
  285. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedTokenStream.cpp +0 -270
  286. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedTokenStream.h +0 -115
  287. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +0 -104
  288. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +0 -193
  289. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/WritableToken.cpp +0 -9
  290. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/WritableToken.h +0 -23
  291. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +0 -137
  292. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +0 -167
  293. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +0 -209
  294. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +0 -112
  295. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +0 -113
  296. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +0 -148
  297. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +0 -228
  298. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +0 -110
  299. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +0 -64
  300. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +0 -50
  301. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +0 -758
  302. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +0 -85
  303. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
  304. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
  305. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +0 -63
  306. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +0 -87
  307. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +0 -72
  308. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +0 -133
  309. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNType.h +0 -20
  310. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
  311. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
  312. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +0 -33
  313. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +0 -33
  314. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AmbiguityInfo.cpp +0 -16
  315. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AmbiguityInfo.h +0 -68
  316. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +0 -82
  317. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +0 -43
  318. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +0 -31
  319. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +0 -30
  320. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
  321. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +0 -22
  322. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
  323. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +0 -21
  324. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
  325. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +0 -24
  326. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
  327. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +0 -21
  328. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ContextSensitivityInfo.cpp +0 -14
  329. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ContextSensitivityInfo.h +0 -47
  330. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionEventInfo.cpp +0 -14
  331. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionEventInfo.h +0 -70
  332. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.cpp +0 -25
  333. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +0 -227
  334. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -17
  335. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +0 -30
  336. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
  337. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
  338. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +0 -35
  339. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +0 -39
  340. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ErrorInfo.cpp +0 -15
  341. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ErrorInfo.h +0 -43
  342. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +0 -158
  343. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +0 -109
  344. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +0 -84
  345. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +0 -44
  346. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +0 -628
  347. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +0 -210
  348. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +0 -9
  349. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +0 -66
  350. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +0 -107
  351. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +0 -115
  352. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +0 -55
  353. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +0 -55
  354. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +0 -63
  355. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +0 -62
  356. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +0 -87
  357. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +0 -63
  358. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +0 -82
  359. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +0 -56
  360. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +0 -61
  361. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +0 -47
  362. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +0 -57
  363. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +0 -47
  364. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +0 -57
  365. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +0 -56
  366. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +0 -61
  367. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +0 -47
  368. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +0 -55
  369. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +0 -56
  370. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +0 -55
  371. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LookaheadEventInfo.cpp +0 -16
  372. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LookaheadEventInfo.h +0 -42
  373. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
  374. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +0 -22
  375. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
  376. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +0 -27
  377. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +0 -25
  378. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +0 -12
  379. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +0 -20
  380. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParseInfo.cpp +0 -102
  381. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParseInfo.h +0 -102
  382. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +0 -1366
  383. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +0 -904
  384. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
  385. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +0 -25
  386. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
  387. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +0 -22
  388. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +0 -32
  389. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +0 -29
  390. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +0 -17
  391. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +0 -62
  392. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +0 -34
  393. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +0 -39
  394. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +0 -662
  395. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +0 -254
  396. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +0 -201
  397. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +0 -436
  398. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +0 -179
  399. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +0 -60
  400. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +0 -30
  401. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +0 -29
  402. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
  403. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +0 -25
  404. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
  405. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +0 -25
  406. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +0 -37
  407. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +0 -40
  408. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +0 -377
  409. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +0 -222
  410. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +0 -32
  411. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +0 -30
  412. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +0 -81
  413. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +0 -36
  414. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
  415. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +0 -21
  416. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
  417. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +0 -35
  418. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +0 -19
  419. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +0 -21
  420. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
  421. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +0 -21
  422. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +0 -44
  423. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +0 -76
  424. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +0 -25
  425. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +0 -25
  426. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +0 -127
  427. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +0 -91
  428. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +0 -67
  429. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +0 -32
  430. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +0 -100
  431. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +0 -144
  432. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +0 -20
  433. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +0 -23
  434. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +0 -124
  435. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +0 -31
  436. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +0 -89
  437. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +0 -84
  438. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +0 -521
  439. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +0 -198
  440. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +0 -134
  441. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +0 -76
  442. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Predicate.cpp +0 -4
  443. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Predicate.h +0 -21
  444. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -13
  445. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +0 -170
  446. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.cpp +0 -43
  447. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +0 -110
  448. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +0 -76
  449. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +0 -248
  450. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +0 -78
  451. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -163
  452. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +0 -36
  453. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +0 -54
  454. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
  455. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
  456. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +0 -128
  457. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
  458. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +0 -19
  459. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +0 -23
  460. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +0 -33
  461. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +0 -71
  462. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.h +0 -53
  463. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -15
  464. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +0 -102
  465. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeListener.cpp +0 -9
  466. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeListener.h +0 -39
  467. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeProperty.h +0 -50
  468. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.cpp +0 -9
  469. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +0 -57
  470. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +0 -49
  471. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +0 -31
  472. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
  473. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +0 -32
  474. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +0 -57
  475. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +0 -33
  476. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.cpp +0 -241
  477. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.h +0 -78
  478. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/Chunk.cpp +0 -9
  479. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/Chunk.h +0 -44
  480. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.cpp +0 -69
  481. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.h +0 -132
  482. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.cpp +0 -64
  483. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.h +0 -105
  484. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +0 -371
  485. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.h +0 -185
  486. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.cpp +0 -77
  487. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.h +0 -117
  488. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TagChunk.cpp +0 -39
  489. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TagChunk.h +0 -86
  490. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TextChunk.cpp +0 -28
  491. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TextChunk.h +0 -51
  492. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.cpp +0 -36
  493. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.h +0 -80
  494. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.cpp +0 -154
  495. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.h +0 -86
  496. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathElement.cpp +0 -31
  497. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathElement.h +0 -40
  498. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +0 -173
  499. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.g4 +0 -64
  500. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +0 -56
  501. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.tokens +0 -12
  502. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexerErrorListener.cpp +0 -13
  503. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexerErrorListener.h +0 -22
  504. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleAnywhereElement.cpp +0 -20
  505. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleAnywhereElement.h +0 -27
  506. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.cpp +0 -30
  507. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.h +0 -26
  508. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenAnywhereElement.cpp +0 -20
  509. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenAnywhereElement.h +0 -25
  510. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.cpp +0 -33
  511. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.h +0 -26
  512. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardAnywhereElement.cpp +0 -23
  513. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardAnywhereElement.h +0 -23
  514. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardElement.cpp +0 -24
  515. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardElement.h +0 -23
  516. data/ext/express-parser/antlrgen/Express.interp +0 -532
  517. data/ext/express-parser/antlrgen/Express.tokens +0 -190
  518. data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +0 -7
  519. data/ext/express-parser/antlrgen/ExpressBaseListener.h +0 -623
  520. data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +0 -7
  521. data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +0 -816
  522. data/ext/express-parser/antlrgen/ExpressLexer.cpp +0 -1169
  523. data/ext/express-parser/antlrgen/ExpressLexer.h +0 -85
  524. data/ext/express-parser/antlrgen/ExpressLexer.interp +0 -534
  525. data/ext/express-parser/antlrgen/ExpressLexer.tokens +0 -190
  526. data/ext/express-parser/antlrgen/ExpressListener.cpp +0 -7
  527. data/ext/express-parser/antlrgen/ExpressListener.h +0 -616
  528. data/ext/express-parser/antlrgen/ExpressParser.cpp +0 -17284
  529. data/ext/express-parser/antlrgen/ExpressParser.h +0 -3696
  530. data/ext/express-parser/antlrgen/ExpressVisitor.cpp +0 -7
  531. data/ext/express-parser/antlrgen/ExpressVisitor.h +0 -422
  532. data/ext/express-parser/express_parser.cpp +0 -17931
  533. data/ext/express-parser/extconf.rb +0 -34
  534. data/lib/express_parser.so +0 -0
data/original/expsm.rb CHANGED
@@ -1,34 +1,34 @@
1
- ## EXPRESS STEPMod Model Ruby Classes
2
- ## Version 0.1
3
- ##
4
- ## The Ruby classes in the model are based on the STEPMod DTD.
5
- ##
6
-
7
- ## process descriptions in external XML file
8
- def load_descriptions( descxml, therepos )
9
-
10
- desc_list = descxml.elements.to_a("//ext_descriptions/ext_description")
11
- desclinkend_list = []
12
- XPath.each( descxml, '//ext_descriptions/ext_description/@linkend' ) { |n| desclinkend_list.push n.to_s }
13
- count_desc = desc_list.size
14
- puts "-- Processing descriptions . Count is #{count_desc.to_s}"
15
-
16
- for schema in therepos.schemas
17
-
18
- for decl in schema.contents
19
- if decl.kind_of? EXPSM::Entity
20
- pos = desclinkend_list.index(schema.name + '.' + decl.name)
21
- if pos != nil
22
- if desc_list[pos].has_elements?
23
- defn = 'ELEMENTS_FOUND'
24
- else
25
- defn = desc_list[pos].text
26
- end
27
- defn = defn.gsub('"','*')
28
- decl.definition = defn.strip
29
- end
30
- end
31
- end
32
- end
33
- end
34
-
1
+ ## EXPRESS STEPMod Model Ruby Classes
2
+ ## Version 0.1
3
+ ##
4
+ ## The Ruby classes in the model are based on the STEPMod DTD.
5
+ ##
6
+
7
+ ## process descriptions in external XML file
8
+ def load_descriptions( descxml, therepos )
9
+
10
+ desc_list = descxml.elements.to_a("//ext_descriptions/ext_description")
11
+ desclinkend_list = []
12
+ XPath.each( descxml, '//ext_descriptions/ext_description/@linkend' ) { |n| desclinkend_list.push n.to_s }
13
+ count_desc = desc_list.size
14
+ puts "-- Processing descriptions . Count is #{count_desc.to_s}"
15
+
16
+ for schema in therepos.schemas
17
+
18
+ for decl in schema.contents
19
+ if decl.kind_of? EXPSM::Entity
20
+ pos = desclinkend_list.index(schema.name + '.' + decl.name)
21
+ if pos != nil
22
+ if desc_list[pos].has_elements?
23
+ defn = 'ELEMENTS_FOUND'
24
+ else
25
+ defn = desc_list[pos].text
26
+ end
27
+ defn = defn.gsub('"','*')
28
+ decl.definition = defn.strip
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+
@@ -1,1018 +1,1018 @@
1
- require 'erb'
2
- # EXPRESS to OWL Structural Mapping
3
- # Version 0.5
4
- # This function navigates the EXPRESS STEPMod Model Ruby Classes
5
- # and performs a structural EXPRESS-to-OWL mapping using Ruby ERB templates.
6
- # The output is in OWL RDF/XML abbreviated syntax.
7
- # Mapping summary reports constructs where mapping is not sufficient (i.e. may need editing) or uses newer OWL capabilities
8
- #
9
- # Configurable items are:
10
- # If file named definitions.csv is found, definitions of items are read from that CSV.
11
- # Double quotes around ITEM and DEFINITION column values is required
12
- # include_dublin_core - If true, import of the Dublin Core OWL is included. Set to true if dc used in annotation_list
13
- # annotation_list - added to each construct created if found. Annotations are added if not 'nil'.
14
- # usr_base of namespace for OWL constructs
15
- # top_class - if not nil, makes every OWL class created a subclass if this class which is added to output
16
- # thing_attributes - if specified, OWL DatatypeProperty domain is set to OWL Thing and range set to string
17
- # datatype_hash - sets mappings for EXPRESS builtin to XSD datatypes
18
- # post_processed_schema - If true, write post-processed schema data (e.g. propety hash) for inclusion in other program or script
19
- #
20
- # Mappings are:
21
- # Entity Types and Subtypes are mapped to OWL Class hierarchy.
22
- # Entity Type SUPERTYPE OF ONEOF( list-of-EntityTypes ) are mapped to OWL disjoint between Classes
23
- # Select Types that resolve to all Entity Types are mapped to OWL Class hierarchy.
24
- # Select Types that resolve to all Type are mapped to RDFS Datatype.
25
- # Select Types that resolve to mixed Entity Types and Type are mapped to OWL Class hierarchy, so may need cleanup
26
- # Enumeration Types are mapped to OWL Enumerated Classes
27
- # Type = builtin are mapped to RDFS Datatypes that subtype XSD datatypes
28
- # Type of Type of ... that ultimately resolve to builtin are mapped to datatype subtype hierarchy
29
- # Explicit attrs of Type = builtin are mapped to OWL DatatypeProperties
30
- # Type = AGGR are mapped to subClassOf rdf:List and type of element not specified
31
-
32
- # Explicit attrs of 1-D LIST/ARRAY OF builtin/Type = builtin mapped to OWL ObjectProperty and subClassOf rdf:List and cardinality 1
33
- # Explicit attrs of n-D AGGR mapped to OWL ObjectProperty and subClassOf rdf:List, type of element not specified, and cardinality 1
34
-
35
- # Inverse attrs are mapped to OWL DatatypeProperties with inverseOf set, except inverse of inherited not mapped
36
- # BOOLEAN attributes are mapped to OWL DatatypeProperties.
37
-
38
- # Attribute redeclarations that ref Entity/Select are mapped to ObjectProperty that is subproperty of that it redeclares
39
- # Attribute redeclarations that ref builting simple types are mapped to DatatypeProperty that is subproperty of that it redeclares
40
- # Type = type that is a select are mapped to Class subclass of referenced select Class
41
- # Single Attribute OPTIONAL or not maps to cardinality restriction on Class owning attribute
42
- # 1D SET/BAG Attribute bound maps to cardinality restriction on Class owning attribute
43
- # n-dimensional aggregates map to rdf List with no internal structure and type of element not specified
44
-
45
-
46
- #
47
- def map_from_express( mapinput )
48
- puts ' '
49
- puts 'EXPRESS to OWL Structural Mapping V0.5'
50
- puts ' '
51
-
52
- ######### Mapping Configuration Starts Here ##############
53
-
54
- # Set the base of the URI (i.e. the namespace) for OWL constructs created during the mapping
55
- uri_base = 'http://www.reeper.org'
56
-
57
- # Add RDFS andor Dublin Core basic annotations
58
-
59
- # Set to true if any annotation_list elements use Dublin Core (dc: or dcterms:)
60
- include_dublin_core = false
61
-
62
- annotation_list = Array.new
63
- # rdfs:comment must be position 0 as definition assignment hardcoded there
64
- #annotation_list[0] = ['rdfs:comment', nil]
65
- #annotation_list[1] = ['owl:versionInfo', '1']
66
- #annotation_list[2] = ['dc:creator', 'David Price, TopQuadrant Limited']
67
- #annotation_list[3] = ['dcterms:created','2010-10-22']
68
- #annotation_list[4] = ['dc:source', '{ iso standard 10303 part(214) version(2) object(1) automotive-design-schema(1) }']
69
-
70
- # Read definitions from csv file if found
71
- definition_hash = Hash.new
72
- if FileTest.exist?('definitions.csv')
73
- require 'csv'
74
- puts '-- Definitions CSV File Found'
75
- CSV.open('definitions.csv', 'r') do |row|
76
- definition_hash[row[0].downcase] = row[1]
77
- end
78
- end
79
-
80
- # set to class name (e.g. 'TOP-THING') to make all created OWL Classes subclasses of a topmost class
81
- top_class = 'AP233-ARM-THING'
82
-
83
- # add common string attributes to use OWL Thing as domain rather than schema classes
84
- thing_attributes = []
85
- #thing_attributes.push 'id'
86
- #thing_attributes.push 'name'
87
- #thing_attributes.push 'description'
88
-
89
- # datatypes for simple and aggregates of simple type
90
- datatype_hash = Hash.new
91
- datatype_hash["INTEGER"] = 'http://www.w3.org/2001/XMLSchema#integer'
92
- datatype_hash["REAL"] = 'http://www.w3.org/2001/XMLSchema#float'
93
- datatype_hash["NUMBER"] = 'http://www.w3.org/2001/XMLSchema#float'
94
- datatype_hash["BINARY"] = 'http://www.w3.org/2001/XMLSchema#hexBinary'
95
- datatype_hash["BOOLEAN"] = 'http://www.w3.org/2001/XMLSchema#boolean'
96
- datatype_hash["LOGICAL"] = 'http://www.w3.org/2001/XMLSchema#boolean'
97
- datatype_hash["STRING"] = 'http://www.w3.org/2001/XMLSchema#string'
98
-
99
- # Write the property_type_hash for inclusion in other scripts or not
100
- post_processed_schema = false
101
- post_processed_schema_file_name = 'postprocessed_schema.rb'
102
- post_processed_schema_file = File.new(post_processed_schema_file_name,'w') if post_processed_schema
103
-
104
- ######### Mapping Configuration Ends Here ##############
105
-
106
-
107
- # Template covering the start of the output file
108
- overall_start_template = %{<rdf:RDF
109
- xmlns:owl="http://www.w3.org/2002/07/owl#"
110
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
111
- xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
112
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
113
- <% if include_dublin_core %>
114
- xmlns:dc="http://purl.org/dc/elements/1.1/"
115
- xmlns:dcterms="http://purl.org/dc/terms/"
116
- <% end %>
117
- }
118
-
119
- # Template covering the output file contents for each schema start
120
- schema_start_template = %{xmlns="<%= uri_base %>/<%= schema.name %>#"
121
- xml:base="<%= uri_base %>/<%= schema.name %>#" >
122
-
123
- <owl:Ontology rdf:about='' rdfs:label='<%= schema.name %>' >
124
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
125
- <% end %>
126
- <% if include_dublin_core %>
127
- <owl:imports rdf:resource="http://purl.org/dc/terms/"/>
128
- <owl:imports rdf:resource="http://purl.org/dc/elements/1.1/"/>
129
- <% end %>
130
- </owl:Ontology>
131
- <% if top_class != nil %>
132
- <owl:Class rdf:ID='<%= top_class %>' />
133
- <% end %>
134
- }
135
-
136
- # Template covering the output file contents for each entity type start or start of type = type that is a select
137
- entity_start_template = %{
138
- <owl:Class rdf:ID='<%= class_name %>' >
139
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
140
- <% end %>
141
- }
142
- # Template covering the output file contents for each entity type end or end of type = type that is a select
143
- entity_end_template = %{
144
- <% if top_class != nil %>
145
- <rdfs:subClassOf rdf:resource='#<%= top_class %>' />
146
- <% end %>
147
- </owl:Class>
148
- }
149
-
150
- # Template covering the output file contents for end of type = type that is a select
151
- class_end_template = %{</owl:Class>}
152
-
153
- # Template covering the output file contents for each select type start
154
- select_start_template = %{
155
- <owl:Class rdf:ID='<%= select.name %>' >
156
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
157
- <% end %>
158
- }
159
- # Template covering the output file contents for each select type end
160
- select_end_template = %{<% if top_class != nil %>
161
- <rdfs:subClassOf rdf:resource='#<%= top_class %>' />
162
- <% end %>
163
- </owl:Class>
164
- }
165
-
166
- # Template covering the supertype(s) for each entity type and type = type that is a select
167
- supertype_template = %{<rdfs:subClassOf rdf:resource='#<%= superclass_name %>' />
168
- }
169
-
170
- # Template covering OWL collections of class contents
171
- class_collection_template = %{<owl:Class><owl:unionOf rdf:parseType="Collection">
172
- <% item_name_list.each do |name| %>
173
- <rdf:Description rdf:about='#<%= name %>'/>
174
- <% end %>
175
- </owl:unionOf>
176
- </owl:Class>}
177
-
178
- # Template covering OWL collections of RDFS datatypes
179
- datatype_collection_template = %{<rdfs:Datatype rdf:ID='<%= type_name %>'>
180
- <owl:equivalentClass><rdfs:Datatype><owl:unionOf rdf:parseType="Collection">
181
- <% type_name_list.each do |name| %>
182
- <rdf:Description rdf:about='#<%= name %>' />
183
- <% end %>
184
- </owl:unionOf>
185
- </rdfs:Datatype></owl:equivalentClass>
186
- </rdfs:Datatype>}
187
-
188
- # Template covering abstract entity types
189
- abstract_entity_template = %{<rdfs:subClassOf rdf:resource='#<%= supertype.name %>' />
190
- }
191
-
192
- # Template covering the output file contents for each defined type of builtin datatype
193
- type_builtin_template = %{
194
- <rdfs:Datatype rdf:ID='<%= datatype_name %>'>
195
- <rdfs:subClassOf rdf:resource='<%= superdatatype_name %>'/>
196
- </rdfs:Datatype>
197
- }
198
-
199
- # Template covering the mappings to rdf list
200
- rdflist_template = %{<rdfs:Class rdf:ID='<%= list_name %>'>
201
- <rdfs:subClassOf rdf:resource='<%= superlist_name %>'/>
202
- </rdfs:Class>}
203
-
204
- # Template covering the output file contents for each attribute that is an aggregate
205
- attribute_aggregate_template = %{}
206
-
207
- # Template covering the output file contents for each attribute that is an aggregate of select of entity
208
- attribute_aggregate_entity_select_template = %{}
209
-
210
- # Template covering the output file contents for each attribute that is a select of entity
211
- attribute_entity_select_template = %{}
212
-
213
- # Template covering the output file contents for each attribute
214
- attribute_template = %{}
215
-
216
- # Template covering the output file contents for each attribute that is builtin datatype
217
- attribute_builtin_template = %{<owl:DatatypeProperty rdf:ID='<%= owl_property_name %>'>
218
- <% if owl_property_domain != nil %>
219
- <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
220
- <% end %>
221
- <rdfs:range rdf:resource='<%= owl_property_range %>' />
222
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
223
- <% end %>
224
- <% if owl_super_property_name != nil %>
225
- <rdfs:subPropertyOf rdf:resource='#<%= owl_super_property_name %>' />
226
- <% end %>
227
- </owl:DatatypeProperty>
228
- }
229
-
230
- # Template covering the output file contents for each attribute that is type that is builtin datatype
231
- attribute_typebuiltin_template = %{<owl:DatatypeProperty rdf:ID='<%= owl_property_name %>'>
232
- <% if owl_property_domain != nil %>
233
- <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
234
- <% end %>
235
- <rdfs:range rdf:resource='#<%= owl_property_range %>' />
236
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
237
- <% end %>
238
- </owl:DatatypeProperty>
239
- }
240
-
241
- # Template covering the output file contents for each attribute that is entity or select type
242
- attribute_entity_template = %{<owl:ObjectProperty rdf:ID='<%= owl_property_name %>'>
243
- <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
244
- <rdfs:range rdf:resource='#<%= owl_property_range %>' />
245
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
246
- <% end %>
247
- </owl:ObjectProperty>
248
- }
249
-
250
- # Template covering the output file contents for each attribute that is entity or select type
251
- inverse_entity_template = %{<owl:ObjectProperty rdf:ID='<%= owl_property_name %>'>
252
- <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
253
- <rdfs:range rdf:resource='#<%= owl_property_range %>' />
254
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
255
- <% end %>
256
- <owl:inverseOf rdf:resource="#<%= owl_inverted_property_name %>"/>
257
- </owl:ObjectProperty>
258
- }
259
-
260
- # Template covering the output file contents for each attribute that is a redeclaration and reference to an entity or select type
261
- attribute_redeclare_entity_template = %{<owl:ObjectProperty rdf:ID='<%= owl_property_name %>'>
262
- <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
263
- <rdfs:range rdf:resource='#<%= owl_property_range %>' />
264
- <rdfs:subPropertyOf rdf:resource='#<%= owl_super_property_name %>' />
265
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
266
- <% end %>
267
- </owl:ObjectProperty>
268
- }
269
-
270
-
271
-
272
- # Template covering the output file contents for each attribute that is enum datatype
273
- class_enum_template = %{<owl:Class rdf:ID='<%= owl_class_name %>'>
274
- <rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
275
- <owl:oneOf rdf:parseType="Collection">
276
- <% enumitem_name_list.each do |name| %>
277
- <rdf:Description rdf:ID="<%= owl_class_name + '.' + name %>"/>
278
- <% end %>
279
- </owl:oneOf>
280
- </owl:Class>}
281
-
282
-
283
- # Template covering the output file contents for each attribute that is enum datatype
284
- attribute_enum_template = %{<owl:DatatypeProperty rdf:ID='<%= owl_property_name %>'>
285
- <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
286
- <rdfs:range><owl:DataRange><owl:oneOf><rdf:List>
287
- <% enumitem_name_list.each do |name| %>
288
- <rdf:first rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= name %></rdf:first>
289
- <% if enumitem_name_list[enumitem_name_list.size-1] != name %>
290
- <rdf:rest><rdf:List>
291
- <% end %>
292
- <% if enumitem_name_list[enumitem_name_list.size-1] == name %>
293
- <rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/> </rdf:List>
294
- <% end %>
295
- <% end %>
296
- <% (1..enumitem_name_list.size-1).each do %>
297
- </rdf:rest></rdf:List>
298
- <% end %>
299
- </owl:oneOf></owl:DataRange></rdfs:range>
300
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
301
- <% end %>
302
- </owl:DatatypeProperty>}
303
-
304
-
305
-
306
- # Template covering min cardinality
307
- min_cardinality_template = %{<rdf:Description rdf:about='#<%= class_name %>'>
308
- <rdfs:subClassOf>
309
- <owl:Restriction>
310
- <owl:onProperty rdf:resource='#<%= owl_property_name %>'/>
311
- <owl:minCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger"><%= min_cardinality %></owl:minCardinality>
312
- </owl:Restriction>
313
- </rdfs:subClassOf>
314
- </rdf:Description>}
315
-
316
-
317
- # Template covering max cardinality
318
- max_cardinality_template = %{<rdf:Description rdf:about='#<%= class_name %>'>
319
- <rdfs:subClassOf>
320
- <owl:Restriction>
321
- <owl:onProperty rdf:resource='#<%= owl_property_name %>'/>
322
- <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger"><%= max_cardinality %></owl:maxCardinality>
323
- </owl:Restriction>
324
- </rdfs:subClassOf>
325
- </rdf:Description>}
326
-
327
- # Template covering cardinality
328
- cardinality_template = %{<rdf:Description rdf:about='#<%= class_name %>'>
329
- <rdfs:subClassOf>
330
- <owl:Restriction>
331
- <owl:onProperty rdf:resource='#<%= owl_property_name %>'/>
332
- <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger"><%= min_cardinality %></owl:cardinality>
333
- </owl:Restriction>
334
- </rdfs:subClassOf>
335
- </rdf:Description>}
336
-
337
- # Template covering the output file contents for each schema end
338
- disjoint_template = %{
339
- <rdf:Description rdf:about='#<%= first_class_name %>'>
340
- <owl:disjointWith rdf:resource="#<%= disjoint_class_name %>"/>
341
- </rdf:Description>}
342
-
343
-
344
- # Template covering the output file contents for each schema end
345
- schema_end_template = %{}
346
-
347
- # Template covering the end of the output file
348
- overall_end_template = %{ </rdf:RDF>}
349
-
350
-
351
- def post_process_entity(entity, post_processed_schema_file, datatype_hash)
352
- attribute_list = entity.attributes_all_array.find_all{ |a| a.kind_of? EXPSM::Explicit}
353
-
354
- for attribute in attribute_list
355
-
356
- express_attribute_domain = nil
357
- if !attribute.isBuiltin
358
- express_attribute_domain = NamedType.find_by_name( attribute.domain )
359
- end
360
- p28_property_name = entity.name.capitalize + '.' + attribute.name.capitalize
361
- property_quoted = false
362
- property_list = false
363
- property_type = '"' + attribute.domain + '"'
364
- if attribute.isBuiltin
365
- property_type = '"' + datatype_hash[attribute.domain] + '"'
366
- end
367
- if attribute.isBuiltin and attribute.domain == 'STRING'
368
- property_quoted = true
369
- end
370
- if (!attribute.redeclare_entity and express_attribute_domain.instance_of? EXPSM::Type and express_attribute_domain.isBuiltin and express_attribute_domain == 'STRING')
371
- property_quoted = true
372
- property_type = '"' + datatype_hash[express_attribute_domain.domain] + '"'
373
- end
374
- if ( attribute.isBuiltin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'LIST')
375
- property_list = true
376
- property_type = '"' + datatype_hash[attribute.domain] + '"'
377
- end
378
-
379
- if (express_attribute_domain.instance_of? EXPSM::Type and express_attribute_domain.isBuiltin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'LIST')
380
- property_list = true
381
- property_type = '"' + datatype_hash[express_attribute_domain.domain] + '"'
382
- end
383
-
384
- property_type = property_type.gsub('http://www.w3.org/2001/XMLSchema#','xsd:')
385
- post_processed_schema_file.puts 'property_range_hash["' + p28_property_name + '"] = [' + property_quoted.to_s + ',' + property_list.to_s + ',' + property_type.to_s + ']'
386
- end
387
- end
388
-
389
-
390
- # A recursive function to return complete set of items, following nested selects, for a select that are not selects themselves
391
- def get_all_selections( item_list )
392
- select_items = item_list.find_all{ |a| a.kind_of? EXPSM::TypeSelect}
393
- if select_items.size == 0
394
- return item_list
395
- end
396
- temp_item_list = item_list
397
- for select in select_items
398
- temp_item_list.delete( select )
399
- temp_item_list = temp_item_list + select.selectitems_array
400
- end
401
- final_list = get_all_selections( temp_item_list )
402
- end
403
-
404
- # A recursive function to return the ultimate underlying type of a type
405
- def is_utlimate_type_builtin( the_type )
406
- return true if the_type.isBuiltin
407
- base_type = NamedType.find_by_name( the_type.domain )
408
- case
409
- when (base_type.instance_of? EXPSM::TypeSelect or base_type.instance_of? EXPSM::Entity)
410
- return false
411
- when (base_type.kind_of? EXPSM::Type and base_type.isBuiltin)
412
- return true
413
- else
414
- return is_utlimate_type_builtin( base_type )
415
- end
416
- end
417
-
418
- # Set up list of schemas to process, input may be a repository containing schemas or a single schema
419
- if mapinput.kind_of? EXPSM::Repository
420
- schema_list = mapinput.schemas
421
- elsif mapinput.kind_of? EXPSM::SchemaDefinition
422
- schema_list = [mapinput]
423
- else
424
- puts "ERROR : map_from_express input no Repository instance or Schema instance"
425
- exit
426
- end
427
-
428
-
429
- for schema in schema_list
430
-
431
- type_mapped_list = []
432
- entity_mapped_list = []
433
- explicit_mapped_list = []
434
- inverse_mapped_list = []
435
- thing_attr_mapped_list = []
436
- superexpression_mapped_list = []
437
- list_mapped_attr_list = []
438
- list_mapped_type_list = []
439
- type_union_mapped_list = []
440
- mixed_select_list = []
441
- all_explicit_list = []
442
- all_derived_list = []
443
- all_inverse_list = []
444
- all_superexpression_list = []
445
-
446
- # Set up separate file for each schema
447
- filename = schema.name.to_s + ".owl"
448
- file = File.new(filename, "w")
449
-
450
- # Evaluate and write file start template
451
- res = ERB.new(overall_start_template)
452
- t = res.result(binding)
453
- file.puts t
454
-
455
- # Evaluate and write schema start template
456
- res = ERB.new(schema_start_template)
457
- t = res.result(binding)
458
- file.puts t
459
-
460
- select_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::TypeSelect }
461
- entity_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::Entity }
462
- defined_type_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::Type }
463
- enum_type_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::TypeEnum }
464
- defined_type_not_builtin_list = defined_type_list.find_all{ |e| !e.isBuiltin }
465
- defined_type_builtin_list = defined_type_list.find_all{ |e| e.isBuiltin }
466
-
467
- # Handle enumeration type maps to RDFS Datatype string
468
-
469
- for type_enum in enum_type_list
470
- type_mapped_list.push type_enum
471
- owl_class_name = type_enum.name
472
- enumitem_name_list = type_enum.items.scan(/\w+/)
473
- res = ERB.new(class_enum_template)
474
- t = res.result(binding)
475
- file.puts t
476
- end
477
-
478
-
479
- # Handle defined type maps to RDFS Datatype
480
-
481
- for type_builtin in defined_type_builtin_list
482
-
483
- # Handle defined type maps to RDFS Datatype
484
- if !type_builtin.instance_of? EXPSM::TypeAggregate
485
- type_mapped_list.push type_builtin
486
- datatype_name = type_builtin.name
487
- superdatatype_name = datatype_hash[type_builtin.domain]
488
- res = ERB.new(type_builtin_template)
489
- t = res.result(binding)
490
- file.puts t
491
- # Handle defined type maps to RDF List
492
- else
493
- list_mapped_type_list.push type_builtin
494
- type_mapped_list.push type_builtin
495
- list_name = type_builtin.name
496
- superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
497
- res = ERB.new(rdflist_template)
498
- t = res.result(binding)
499
- file.puts t
500
- end
501
- end
502
-
503
-
504
- for type_not_builtin in defined_type_not_builtin_list
505
-
506
- type_domain = NamedType.find_by_name( type_not_builtin.domain )
507
- type_is_builtin = is_utlimate_type_builtin( type_not_builtin )
508
-
509
- case
510
-
511
- # Handle simple defined type refining simple defined type of builtin map to RDFS Datatype
512
- when (!type_not_builtin.instance_of? EXPSM::TypeAggregate and type_is_builtin and !type_domain.instance_of? EXPSM::TypeAggregate)
513
- type_mapped_list.push type_not_builtin
514
- datatype_name = type_not_builtin.name
515
- superdatatype_name = '#' + type_domain.name
516
- res = ERB.new(type_builtin_template)
517
- t = res.result(binding)
518
- file.puts t
519
-
520
- # Handle simple defined type of aggr defined type of builtin map to RDF List
521
- when (!type_not_builtin.instance_of? EXPSM::TypeAggregate and type_domain.instance_of? EXPSM::TypeAggregate and type_is_builtin)
522
- type_mapped_list.push type_not_builtin
523
- list_mapped_type_list.push type_not_builtin
524
- list_name = type_not_builtin.name
525
- superlist_name = '#' + type_domain.name
526
- res = ERB.new(rdflist_template)
527
- t = res.result(binding)
528
- file.puts t
529
-
530
- # Handle aggr defined type of simple defined type of builtin map to RDF List
531
- when (type_not_builtin.instance_of? EXPSM::TypeAggregate and type_domain.instance_of? EXPSM::Type and type_is_builtin)
532
- type_mapped_list.push type_not_builtin
533
- list_mapped_type_list.push type_not_builtin
534
- list_name = type_not_builtin.name
535
- superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
536
- res = ERB.new(rdflist_template)
537
- t = res.result(binding)
538
- file.puts t
539
-
540
- # Handle aggr of entity/select type map to RDF List
541
- when (type_not_builtin.instance_of? EXPSM::TypeAggregate and (type_domain.instance_of? EXPSM::Entity or type_domain.instance_of? EXPSM::TypeSelect))
542
- type_mapped_list.push type_not_builtin
543
- list_mapped_type_list.push type_not_builtin
544
- list_name = type_not_builtin.name
545
- superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
546
- res = ERB.new(rdflist_template)
547
- t = res.result(binding)
548
- file.puts t
549
-
550
- # Handle defined type that are type = type that is a select
551
- when (type_domain.kind_of? EXPSM::TypeSelect)
552
- type_mapped_list.push type_not_builtin
553
- superclass_name = type_not_builtin.domain
554
- class_name = type_not_builtin.name
555
- res = ERB.new(entity_start_template)
556
- t = res.result(binding)
557
- file.puts t
558
-
559
- superclass_name = type_not_builtin.domain
560
- res = ERB.new(supertype_template)
561
- t = res.result(binding)
562
- file.puts t
563
-
564
- res = ERB.new(class_end_template)
565
- t = res.result(binding)
566
- file.puts t
567
-
568
- else
569
- puts 'ERROR : Not mapped = ' + type_not_builtin.name
570
- end
571
- end
572
-
573
-
574
- # Handle EXPRESS SELECT Type mapping to OWL Class hierarchy and RDFS Datatypes
575
-
576
- for select in select_list
577
-
578
- item_name_list = select.selectitems.scan(/\w+/)
579
-
580
- this_select_all_items = get_all_selections( select.selectitems_array )
581
- this_select_type_items = this_select_all_items.find_all{ |a| a.kind_of? EXPSM::Type}
582
-
583
- case
584
-
585
- # Handle case of select items resolving to containing only items that are non-select Type
586
- when this_select_type_items.size == this_select_all_items.size
587
- type_mapped_list.push select
588
- type_union_mapped_list.push select
589
- type_name_list = item_name_list
590
- type_name = select.name
591
- res = ERB.new(datatype_collection_template)
592
- t = res.result(binding)
593
- file.puts t
594
-
595
- # Handle case of select items resolving to containing no item that is a non-select Type
596
- else
597
- type_mapped_list.push select
598
-
599
- res = ERB.new(select_start_template)
600
- t = res.result(binding)
601
- file.puts t
602
- file.puts '<owl:equivalentClass>'
603
-
604
- res = ERB.new(class_collection_template)
605
- t = res.result(binding)
606
- file.puts t
607
- file.puts '</owl:equivalentClass>'
608
-
609
- res = ERB.new(select_end_template)
610
- t = res.result(binding)
611
- file.puts t
612
- if (this_select_type_items.size != 0 and this_select_type_items.size != this_select_all_items.size)
613
- mixed_select_list.push select
614
- end
615
-
616
- end
617
- end
618
-
619
- # Handle EXPRESS Entity mappings to OWL Class hierarchy
620
-
621
- for entity in entity_list
622
-
623
- if definition_hash[entity.name.downcase] != nil
624
- annotation_list[0] = ['rdfs:comment', definition_hash[entity.name.downcase]]
625
- else
626
- annotation_list[0] = ['rdfs:comment', nil]
627
- end
628
-
629
- entity_mapped_list.push entity
630
-
631
- class_name = entity.name
632
- res = ERB.new(entity_start_template)
633
- t = res.result(binding)
634
- file.puts t
635
-
636
- for supertype in entity.supertypes_array
637
- superclass_name = supertype.name
638
- res = ERB.new(supertype_template)
639
- t = res.result(binding)
640
- file.puts t
641
- end
642
-
643
- res = ERB.new(entity_end_template)
644
- t = res.result(binding)
645
- file.puts t
646
-
647
- # Post-process the entity
648
- post_process_entity(entity, post_processed_schema_file, datatype_hash) if post_processed_schema
649
-
650
-
651
- if entity.superexpression != nil
652
- all_superexpression_list.push entity
653
-
654
- # Handle simple case of one ONEOF in supertype expression mapped to disjoint between listed subclasses
655
- case
656
- # when (entity.superexpression.include?('ONEOF') and !entity.superexpression.include?('ANDOR') and !entity.superexpression.include?('TOTAL_OVER') and !entity.superexpression.include?('AND') and !entity.superexpression.include?('ABSTRACT'))
657
-
658
- when (entity.superexpression.include?('ONEOF'))
659
- superexpression_mapped_list.push entity
660
- tempexpression = entity.superexpression
661
- if entity.superexpression.index('ONEOF') != 0
662
- puts 'WARNING: ' + entity.name + ' supertype mapping may be incomplete, only ONEOFs processed'
663
- end
664
- while (tempexpression.include?('ONEOF'))
665
- posoneof = tempexpression.index('ONEOF')
666
- tempexpression = tempexpression[posoneof + 5,tempexpression.length - 5]
667
- posclose = tempexpression.index(')')
668
- oneof_name_list = tempexpression[0,posclose].scan(/\w+/)
669
- while oneof_name_list.size != 0
670
- first_class_name = oneof_name_list[0]
671
- oneof_name_list.delete(first_class_name)
672
- for disjoint_class_name in oneof_name_list
673
- res = ERB.new(disjoint_template)
674
- t = res.result(binding)
675
- file.puts t
676
- end
677
- end
678
- end
679
- else
680
- end
681
-
682
- end
683
-
684
-
685
- end
686
-
687
- # Handle mapping common string attributes to OWL DatatypeProperties of OWL Thing
688
-
689
- for thing_attribute in thing_attributes
690
- owl_property_name = thing_attribute
691
- owl_property_range = 'http://www.w3.org/2001/XMLSchema#string'
692
- owl_property_domain = nil
693
- owl_super_property_name = nil
694
- res = ERB.new(attribute_builtin_template)
695
- t = res.result(binding)
696
- file.puts t
697
- end
698
-
699
- # Handle EXPRESS attributes on an entity-by-entity basis
700
- for entity in entity_list
701
-
702
- class_name = entity.name
703
-
704
- attribute_list = entity.attributes.find_all{ |a| a.kind_of? EXPSM::Explicit and !thing_attributes.include?(a.name)}
705
- thing_attr_list = entity.attributes.find_all{ |a| a.kind_of? EXPSM::Explicit and thing_attributes.include?(a.name)}
706
- inverse_list = entity.attributes.find_all{ |a| a.kind_of? EXPSM::Inverse and !thing_attributes.include?(a.name)}
707
-
708
- thing_attr_mapped_list = thing_attr_mapped_list + thing_attr_list
709
-
710
- all_explicit_list = all_explicit_list + entity.attributes.find_all{ |a| a.kind_of? EXPSM::Explicit}
711
- all_derived_list = all_derived_list + entity.attributes.find_all{ |a| a.kind_of? EXPSM::Derived}
712
-
713
- all_inverse_list = all_inverse_list + inverse_list
714
-
715
- # Handle EXPRESS inverse attribute mapping to OWL inverse property
716
- for attribute in inverse_list
717
- if attribute.reverseAttr != []
718
- inverse_mapped_list.push attribute
719
- owl_property_range = attribute.domain
720
- owl_property_name = entity.name + '.' + attribute.name
721
- owl_property_domain = entity.name
722
- owl_inverted_property_name = attribute.reverseEntity.name + '.' + attribute.reverseAttr.name
723
- res = ERB.new(inverse_entity_template)
724
- t = res.result(binding)
725
- file.puts t
726
- end
727
- end
728
-
729
- # Handle EXPRESS explicit attribute mapping to OWL property
730
- for attribute in attribute_list
731
-
732
- express_attribute_domain = nil
733
- type_is_builtin = false
734
- if !attribute.isBuiltin
735
- express_attribute_domain = NamedType.find_by_name( attribute.domain )
736
- if express_attribute_domain.instance_of? EXPSM::Type
737
- type_is_builtin = is_utlimate_type_builtin( express_attribute_domain )
738
- end
739
- end
740
-
741
- case
742
-
743
- # Handle EXPRESS explicit attributes of LIST of built-in simple type, including redeclaration
744
- when (attribute.isBuiltin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'LIST')
745
- explicit_mapped_list.push attribute
746
- list_mapped_attr_list.push attribute
747
- list_name = entity.name + '.' + attribute.name + '-' + attribute.domain.to_s + '-List'
748
- superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
749
- res = ERB.new(rdflist_template)
750
- t = res.result(binding)
751
- file.puts t
752
- owl_property_name = entity.name + '.' + attribute.name
753
- owl_property_domain = entity.name
754
- owl_property_range = list_name
755
- res = ERB.new(attribute_entity_template)
756
- t = res.result(binding)
757
- file.puts t
758
-
759
- # Handle EXPRESS explicit attributes of ARRAY of built-in simple type, including redeclaration
760
- when (attribute.isBuiltin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'ARRAY')
761
- explicit_mapped_list.push attribute
762
- list_mapped_attr_list.push attribute
763
- list_name = entity.name + '.' + attribute.name + '-' + attribute.domain.to_s + '-Array'
764
- superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
765
- res = ERB.new(rdflist_template)
766
- t = res.result(binding)
767
- file.puts t
768
- owl_property_name = entity.name + '.' + attribute.name
769
- owl_property_domain = entity.name
770
- owl_property_range = list_name
771
- res = ERB.new(attribute_entity_template)
772
- t = res.result(binding)
773
- file.puts t
774
-
775
- # Handle EXPRESS explicit attributes of LIST of TYPE that is built-in simple type, including redeclaration
776
- when (express_attribute_domain.instance_of? EXPSM::Type and type_is_builtin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'LIST')
777
- explicit_mapped_list.push attribute
778
- list_mapped_attr_list.push attribute
779
- list_name = entity.name + '.' + attribute.name + '-' + attribute.domain.to_s + '-List'
780
- superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
781
- res = ERB.new(rdflist_template)
782
- t = res.result(binding)
783
- file.puts t
784
- owl_property_name = entity.name + '.' + attribute.name
785
- owl_property_domain = entity.name
786
- owl_property_range = list_name
787
- res = ERB.new(attribute_entity_template)
788
- t = res.result(binding)
789
- file.puts t
790
-
791
- # Handle EXPRESS explicit attributes of ARRAY of TYPE that is built-in simple type, including redeclaration
792
- when (express_attribute_domain.instance_of? EXPSM::Type and type_is_builtin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'ARRAY')
793
- explicit_mapped_list.push attribute
794
- list_mapped_attr_list.push attribute
795
- list_name = entity.name + '.' + attribute.name + '-' + attribute.domain.to_s + '-Array'
796
- superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
797
- res = ERB.new(rdflist_template)
798
- t = res.result(binding)
799
- file.puts t
800
- owl_property_name = entity.name + '.' + attribute.name
801
- owl_property_domain = entity.name
802
- owl_property_range = list_name
803
- res = ERB.new(attribute_entity_template)
804
- t = res.result(binding)
805
- file.puts t
806
-
807
-
808
- # Handle EXPRESS explicit attributes of built-in simple type, including redeclaration
809
- when (attribute.isBuiltin)
810
- explicit_mapped_list.push attribute
811
- owl_property_range = datatype_hash[attribute.domain]
812
- owl_property_name = entity.name + '.' + attribute.name
813
- owl_property_domain = entity.name
814
- owl_super_property_name = nil
815
- if attribute.redeclare_entity != nil
816
- if attribute.redeclare_oldname == nil
817
- owl_super_property_name = attribute.redeclare_entity + '.' + attribute.name
818
- else
819
- owl_super_property_name = attribute.redeclare_entity + '.' + attribute.redeclare_oldname
820
- end
821
- end
822
- res = ERB.new(attribute_builtin_template)
823
- t = res.result(binding)
824
- file.puts t
825
-
826
- # Handle EXPRESS explicit attribute, not redeclaration, refers to Type that is Type = builtin datatype
827
- when (!attribute.redeclare_entity and express_attribute_domain.instance_of? EXPSM::Type and type_is_builtin)
828
- explicit_mapped_list.push attribute
829
- owl_property_range = attribute.domain
830
- owl_property_name = entity.name + '.' + attribute.name
831
- owl_property_domain = entity.name
832
- res = ERB.new(attribute_typebuiltin_template)
833
- t = res.result(binding)
834
- file.puts t
835
-
836
- # Handle EXPRESS explicit attributes of enum type, ignoring redeclarations
837
- when (express_attribute_domain.kind_of? EXPSM::TypeEnum)
838
- explicit_mapped_list.push attribute
839
- owl_property_name = entity.name + '.' + attribute.name
840
- owl_property_domain = entity.name
841
- owl_property_range = attribute.domain
842
- res = ERB.new(attribute_entity_template)
843
-
844
- # if !type_mapped_list.include?(express_attribute_domain)
845
- # type_mapped_list.push express_attribute_domain
846
- # end
847
- # enumitem_name_list = express_attribute_domain.items.scan(/\w+/)
848
- # res = ERB.new(attribute_enum_template)
849
-
850
- t = res.result(binding)
851
- file.puts t
852
- if attribute.redeclare_entity
853
- puts 'WARNING: ' + entity.name + ' ' + attribute.name + ' Attribute redeclaration for Enumerations not mapped'
854
- end
855
-
856
- # Handle EXPRESS explicit attribute, not redeclaration, and only refer to EXPRESS Select or Entity
857
- when (!attribute.redeclare_entity and (express_attribute_domain.kind_of? EXPSM::Entity or express_attribute_domain.kind_of? EXPSM::TypeSelect))
858
- explicit_mapped_list.push attribute
859
- owl_property_range = attribute.domain
860
- owl_property_name = entity.name + '.' + attribute.name
861
- owl_property_domain = entity.name
862
- res = ERB.new(attribute_entity_template)
863
- t = res.result(binding)
864
- file.puts t
865
-
866
- # Handle EXPRESS explicit attribute, redeclaration, and only refer to EXPRESS Select or Entity
867
- when (attribute.redeclare_entity and (express_attribute_domain.kind_of? EXPSM::Entity or express_attribute_domain.kind_of? EXPSM::TypeSelect))
868
- explicit_mapped_list.push attribute
869
- owl_property_range = attribute.domain
870
- owl_property_name = entity.name + '.' + attribute.name
871
- if attribute.redeclare_oldname == nil
872
- owl_super_property_name = attribute.redeclare_entity + '.' + attribute.name
873
- else
874
- owl_super_property_name = attribute.redeclare_entity + '.' + attribute.redeclare_oldname
875
- end
876
- owl_property_domain = entity.name
877
- res = ERB.new(attribute_redeclare_entity_template)
878
- t = res.result(binding)
879
- file.puts t
880
-
881
- # Handle EXPRESS explicit attribute of EXPRESS Type = A Type name that is a Select
882
- when (express_attribute_domain.kind_of? EXPSM::Type and NamedType.find_by_name( express_attribute_domain.domain ).kind_of? EXPSM::TypeSelect)
883
- explicit_mapped_list.push attribute
884
- owl_property_range = attribute.domain
885
- owl_property_name = entity.name + '.' + attribute.name
886
- owl_property_domain = entity.name
887
- res = ERB.new(attribute_entity_template)
888
- t = res.result(binding)
889
- file.puts t
890
-
891
- # Handle EXPRESS explicit attribute, redeclaration, and only refer to EXPRESS Type = A Type name that is a Select
892
- when (attribute.redeclare_entity and (express_attribute_domain.kind_of? EXPSM::Type and NamedType.find_by_name( express_attribute_domain.domain ).kind_of? EXPSM::TypeSelect))
893
-
894
- explicit_mapped_list.push attribute
895
- owl_property_range = attribute.domain
896
- owl_property_name = entity.name + '.' + attribute.name
897
- if attribute.redeclare_oldname == nil
898
- owl_super_property_name = attribute.redeclare_entity + '.' + attribute.name
899
- else
900
- owl_super_property_name = attribute.redeclare_entity + '.' + attribute.redeclare_oldname
901
- end
902
- owl_property_domain = entity.name
903
- res = ERB.new(attribute_redeclare_entity_template)
904
- t = res.result(binding)
905
- file.puts t
906
-
907
- else
908
- puts 'WARNING: ' + entity.name + ' ' + attribute.name + ' Attribute type not yet mapped'
909
- end
910
-
911
- min_cardinality = 1
912
- max_cardinality = 1
913
-
914
- if attribute.isOptional == true
915
- min_cardinality = 0
916
- end
917
-
918
- if (attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype != 'LIST' and attribute.dimensions[0].aggrtype != 'ARRAY')
919
- if attribute.isOptional == false
920
- min_cardinality = attribute.dimensions[0].lower.to_i
921
- end
922
- if attribute.dimensions[0].upper == '?'
923
- max_cardinality = -1
924
- else
925
- max_cardinality = attribute.dimensions[0].upper.to_i
926
- end
927
- if attribute.rank > 1
928
- puts 'WARNING: ' + owl_property_name + ' n-dimensional aggregate attribute cardinalities not mapped '
929
- max_cardinality = -1
930
- end
931
- end
932
-
933
- if min_cardinality == max_cardinality
934
- res = ERB.new(cardinality_template)
935
- t = res.result(binding)
936
- file.puts t
937
- else
938
- res = ERB.new(min_cardinality_template)
939
- t = res.result(binding)
940
- file.puts t
941
- if max_cardinality != -1
942
- res = ERB.new(max_cardinality_template)
943
- t = res.result(binding)
944
- file.puts t
945
- end
946
- end
947
-
948
-
949
- if (attribute.redeclare_entity and !(express_attribute_domain.kind_of? EXPSM::Entity or express_attribute_domain.kind_of? EXPSM::TypeSelect))
950
- if (attribute.redeclare_entity and !(express_attribute_domain.kind_of? EXPSM::Type and NamedType.find_by_name( express_attribute_domain.domain ).kind_of? EXPSM::TypeSelect))
951
- if (attribute.redeclare_entity and !attribute.isBuiltin)
952
- puts 'WARNING: ' + entity.name + ' ' + attribute.name + ' Attribute redeclaration may need hand editing'
953
- end
954
- end
955
- end
956
-
957
- end
958
-
959
- end
960
-
961
-
962
- res = ERB.new(schema_end_template)
963
- t = res.result(binding)
964
- file.puts t
965
-
966
- puts ' '
967
- puts 'Schema Mapping Summary for : ' + schema.name
968
- all_type_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::DefinedType }
969
-
970
-
971
- puts ' ENTITYs mapped = ' + entity_mapped_list.size.to_s + ' of ' + entity_list.size.to_s
972
- puts ' - ' + superexpression_mapped_list.size.to_s + ' of ' + all_superexpression_list.size.to_s + ' ENTITY SUPERTYPE expressions mapped (only simple ONEOF supported)'
973
- for t in all_superexpression_list - superexpression_mapped_list
974
- puts ' Not mapped: ' + t.name
975
- end
976
- puts ' - ' + inverse_mapped_list.size.to_s + ' of ' + all_inverse_list.size.to_s + ' inverse attributes mapped (inverse of inherited not supported)'
977
- notmapped_list = all_inverse_list - inverse_mapped_list
978
- for t in notmapped_list
979
- puts ' Not mapped: ' + t.entity.name + '.' + t.name
980
- end
981
- puts ' - ' + thing_attr_mapped_list.size.to_s + ' of ' + all_explicit_list.size.to_s + ' explicit attributes mapped with owl:Thing as domain (configurable)'
982
- puts ' - ' + explicit_mapped_list.size.to_s + ' of ' + all_explicit_list.size.to_s + ' explicit attributes mapped'
983
- for t in list_mapped_attr_list
984
- puts ' rdf:List mapped: ' + t.name
985
- end
986
-
987
- notmapped_list = all_explicit_list - explicit_mapped_list - thing_attr_mapped_list
988
- for t in notmapped_list
989
- puts ' Not mapped: ' + t.entity.name + '.' + t.name
990
- end
991
- puts ' - ' + all_derived_list.size.to_s + ' derived attributes not mapped, not supported'
992
- puts ' TYPEs mapped = ' + type_mapped_list.size.to_s + ' of ' + all_type_list.size.to_s
993
- for t in list_mapped_type_list
994
- puts ' rdf:List mapped: ' + t.name
995
- end
996
- for t in mixed_select_list
997
- puts ' Select of entity & type Class mapped: ' + t.name
998
- end
999
- for t in type_union_mapped_list
1000
- puts ' Select RDFS Datatype owl:unionOf mapped: ' + t.name
1001
- end
1002
- notmapped_list = all_type_list - type_mapped_list
1003
- for t in notmapped_list
1004
- puts ' Not mapped: ' + t.name
1005
- end
1006
- puts ' '
1007
- puts 'Wrote post-processed schema to file: ' + post_processed_schema_file_name if post_processed_schema
1008
-
1009
-
1010
- end
1011
-
1012
- res = ERB.new(overall_end_template)
1013
- t = res.result(binding)
1014
- file.puts t
1015
-
1016
- post_processed_schema_file.close if post_processed_schema
1017
-
1018
- end
1
+ require 'erb'
2
+ # EXPRESS to OWL Structural Mapping
3
+ # Version 0.5
4
+ # This function navigates the EXPRESS STEPMod Model Ruby Classes
5
+ # and performs a structural EXPRESS-to-OWL mapping using Ruby ERB templates.
6
+ # The output is in OWL RDF/XML abbreviated syntax.
7
+ # Mapping summary reports constructs where mapping is not sufficient (i.e. may need editing) or uses newer OWL capabilities
8
+ #
9
+ # Configurable items are:
10
+ # If file named definitions.csv is found, definitions of items are read from that CSV.
11
+ # Double quotes around ITEM and DEFINITION column values is required
12
+ # include_dublin_core - If true, import of the Dublin Core OWL is included. Set to true if dc used in annotation_list
13
+ # annotation_list - added to each construct created if found. Annotations are added if not 'nil'.
14
+ # usr_base of namespace for OWL constructs
15
+ # top_class - if not nil, makes every OWL class created a subclass if this class which is added to output
16
+ # thing_attributes - if specified, OWL DatatypeProperty domain is set to OWL Thing and range set to string
17
+ # datatype_hash - sets mappings for EXPRESS builtin to XSD datatypes
18
+ # post_processed_schema - If true, write post-processed schema data (e.g. propety hash) for inclusion in other program or script
19
+ #
20
+ # Mappings are:
21
+ # Entity Types and Subtypes are mapped to OWL Class hierarchy.
22
+ # Entity Type SUPERTYPE OF ONEOF( list-of-EntityTypes ) are mapped to OWL disjoint between Classes
23
+ # Select Types that resolve to all Entity Types are mapped to OWL Class hierarchy.
24
+ # Select Types that resolve to all Type are mapped to RDFS Datatype.
25
+ # Select Types that resolve to mixed Entity Types and Type are mapped to OWL Class hierarchy, so may need cleanup
26
+ # Enumeration Types are mapped to OWL Enumerated Classes
27
+ # Type = builtin are mapped to RDFS Datatypes that subtype XSD datatypes
28
+ # Type of Type of ... that ultimately resolve to builtin are mapped to datatype subtype hierarchy
29
+ # Explicit attrs of Type = builtin are mapped to OWL DatatypeProperties
30
+ # Type = AGGR are mapped to subClassOf rdf:List and type of element not specified
31
+
32
+ # Explicit attrs of 1-D LIST/ARRAY OF builtin/Type = builtin mapped to OWL ObjectProperty and subClassOf rdf:List and cardinality 1
33
+ # Explicit attrs of n-D AGGR mapped to OWL ObjectProperty and subClassOf rdf:List, type of element not specified, and cardinality 1
34
+
35
+ # Inverse attrs are mapped to OWL DatatypeProperties with inverseOf set, except inverse of inherited not mapped
36
+ # BOOLEAN attributes are mapped to OWL DatatypeProperties.
37
+
38
+ # Attribute redeclarations that ref Entity/Select are mapped to ObjectProperty that is subproperty of that it redeclares
39
+ # Attribute redeclarations that ref builting simple types are mapped to DatatypeProperty that is subproperty of that it redeclares
40
+ # Type = type that is a select are mapped to Class subclass of referenced select Class
41
+ # Single Attribute OPTIONAL or not maps to cardinality restriction on Class owning attribute
42
+ # 1D SET/BAG Attribute bound maps to cardinality restriction on Class owning attribute
43
+ # n-dimensional aggregates map to rdf List with no internal structure and type of element not specified
44
+
45
+
46
+ #
47
+ def map_from_express( mapinput )
48
+ puts ' '
49
+ puts 'EXPRESS to OWL Structural Mapping V0.5'
50
+ puts ' '
51
+
52
+ ######### Mapping Configuration Starts Here ##############
53
+
54
+ # Set the base of the URI (i.e. the namespace) for OWL constructs created during the mapping
55
+ uri_base = 'http://www.reeper.org'
56
+
57
+ # Add RDFS andor Dublin Core basic annotations
58
+
59
+ # Set to true if any annotation_list elements use Dublin Core (dc: or dcterms:)
60
+ include_dublin_core = false
61
+
62
+ annotation_list = Array.new
63
+ # rdfs:comment must be position 0 as definition assignment hardcoded there
64
+ #annotation_list[0] = ['rdfs:comment', nil]
65
+ #annotation_list[1] = ['owl:versionInfo', '1']
66
+ #annotation_list[2] = ['dc:creator', 'David Price, TopQuadrant Limited']
67
+ #annotation_list[3] = ['dcterms:created','2010-10-22']
68
+ #annotation_list[4] = ['dc:source', '{ iso standard 10303 part(214) version(2) object(1) automotive-design-schema(1) }']
69
+
70
+ # Read definitions from csv file if found
71
+ definition_hash = Hash.new
72
+ if FileTest.exist?('definitions.csv')
73
+ require 'csv'
74
+ puts '-- Definitions CSV File Found'
75
+ CSV.open('definitions.csv', 'r') do |row|
76
+ definition_hash[row[0].downcase] = row[1]
77
+ end
78
+ end
79
+
80
+ # set to class name (e.g. 'TOP-THING') to make all created OWL Classes subclasses of a topmost class
81
+ top_class = 'AP233-ARM-THING'
82
+
83
+ # add common string attributes to use OWL Thing as domain rather than schema classes
84
+ thing_attributes = []
85
+ #thing_attributes.push 'id'
86
+ #thing_attributes.push 'name'
87
+ #thing_attributes.push 'description'
88
+
89
+ # datatypes for simple and aggregates of simple type
90
+ datatype_hash = Hash.new
91
+ datatype_hash["INTEGER"] = 'http://www.w3.org/2001/XMLSchema#integer'
92
+ datatype_hash["REAL"] = 'http://www.w3.org/2001/XMLSchema#float'
93
+ datatype_hash["NUMBER"] = 'http://www.w3.org/2001/XMLSchema#float'
94
+ datatype_hash["BINARY"] = 'http://www.w3.org/2001/XMLSchema#hexBinary'
95
+ datatype_hash["BOOLEAN"] = 'http://www.w3.org/2001/XMLSchema#boolean'
96
+ datatype_hash["LOGICAL"] = 'http://www.w3.org/2001/XMLSchema#boolean'
97
+ datatype_hash["STRING"] = 'http://www.w3.org/2001/XMLSchema#string'
98
+
99
+ # Write the property_type_hash for inclusion in other scripts or not
100
+ post_processed_schema = false
101
+ post_processed_schema_file_name = 'postprocessed_schema.rb'
102
+ post_processed_schema_file = File.new(post_processed_schema_file_name,'w') if post_processed_schema
103
+
104
+ ######### Mapping Configuration Ends Here ##############
105
+
106
+
107
+ # Template covering the start of the output file
108
+ overall_start_template = %{<rdf:RDF
109
+ xmlns:owl="http://www.w3.org/2002/07/owl#"
110
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
111
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
112
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
113
+ <% if include_dublin_core %>
114
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
115
+ xmlns:dcterms="http://purl.org/dc/terms/"
116
+ <% end %>
117
+ }
118
+
119
+ # Template covering the output file contents for each schema start
120
+ schema_start_template = %{xmlns="<%= uri_base %>/<%= schema.name %>#"
121
+ xml:base="<%= uri_base %>/<%= schema.name %>#" >
122
+
123
+ <owl:Ontology rdf:about='' rdfs:label='<%= schema.name %>' >
124
+ <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
125
+ <% end %>
126
+ <% if include_dublin_core %>
127
+ <owl:imports rdf:resource="http://purl.org/dc/terms/"/>
128
+ <owl:imports rdf:resource="http://purl.org/dc/elements/1.1/"/>
129
+ <% end %>
130
+ </owl:Ontology>
131
+ <% if top_class != nil %>
132
+ <owl:Class rdf:ID='<%= top_class %>' />
133
+ <% end %>
134
+ }
135
+
136
+ # Template covering the output file contents for each entity type start or start of type = type that is a select
137
+ entity_start_template = %{
138
+ <owl:Class rdf:ID='<%= class_name %>' >
139
+ <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
140
+ <% end %>
141
+ }
142
+ # Template covering the output file contents for each entity type end or end of type = type that is a select
143
+ entity_end_template = %{
144
+ <% if top_class != nil %>
145
+ <rdfs:subClassOf rdf:resource='#<%= top_class %>' />
146
+ <% end %>
147
+ </owl:Class>
148
+ }
149
+
150
+ # Template covering the output file contents for end of type = type that is a select
151
+ class_end_template = %{</owl:Class>}
152
+
153
+ # Template covering the output file contents for each select type start
154
+ select_start_template = %{
155
+ <owl:Class rdf:ID='<%= select.name %>' >
156
+ <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
157
+ <% end %>
158
+ }
159
+ # Template covering the output file contents for each select type end
160
+ select_end_template = %{<% if top_class != nil %>
161
+ <rdfs:subClassOf rdf:resource='#<%= top_class %>' />
162
+ <% end %>
163
+ </owl:Class>
164
+ }
165
+
166
+ # Template covering the supertype(s) for each entity type and type = type that is a select
167
+ supertype_template = %{<rdfs:subClassOf rdf:resource='#<%= superclass_name %>' />
168
+ }
169
+
170
+ # Template covering OWL collections of class contents
171
+ class_collection_template = %{<owl:Class><owl:unionOf rdf:parseType="Collection">
172
+ <% item_name_list.each do |name| %>
173
+ <rdf:Description rdf:about='#<%= name %>'/>
174
+ <% end %>
175
+ </owl:unionOf>
176
+ </owl:Class>}
177
+
178
+ # Template covering OWL collections of RDFS datatypes
179
+ datatype_collection_template = %{<rdfs:Datatype rdf:ID='<%= type_name %>'>
180
+ <owl:equivalentClass><rdfs:Datatype><owl:unionOf rdf:parseType="Collection">
181
+ <% type_name_list.each do |name| %>
182
+ <rdf:Description rdf:about='#<%= name %>' />
183
+ <% end %>
184
+ </owl:unionOf>
185
+ </rdfs:Datatype></owl:equivalentClass>
186
+ </rdfs:Datatype>}
187
+
188
+ # Template covering abstract entity types
189
+ abstract_entity_template = %{<rdfs:subClassOf rdf:resource='#<%= supertype.name %>' />
190
+ }
191
+
192
+ # Template covering the output file contents for each defined type of builtin datatype
193
+ type_builtin_template = %{
194
+ <rdfs:Datatype rdf:ID='<%= datatype_name %>'>
195
+ <rdfs:subClassOf rdf:resource='<%= superdatatype_name %>'/>
196
+ </rdfs:Datatype>
197
+ }
198
+
199
+ # Template covering the mappings to rdf list
200
+ rdflist_template = %{<rdfs:Class rdf:ID='<%= list_name %>'>
201
+ <rdfs:subClassOf rdf:resource='<%= superlist_name %>'/>
202
+ </rdfs:Class>}
203
+
204
+ # Template covering the output file contents for each attribute that is an aggregate
205
+ attribute_aggregate_template = %{}
206
+
207
+ # Template covering the output file contents for each attribute that is an aggregate of select of entity
208
+ attribute_aggregate_entity_select_template = %{}
209
+
210
+ # Template covering the output file contents for each attribute that is a select of entity
211
+ attribute_entity_select_template = %{}
212
+
213
+ # Template covering the output file contents for each attribute
214
+ attribute_template = %{}
215
+
216
+ # Template covering the output file contents for each attribute that is builtin datatype
217
+ attribute_builtin_template = %{<owl:DatatypeProperty rdf:ID='<%= owl_property_name %>'>
218
+ <% if owl_property_domain != nil %>
219
+ <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
220
+ <% end %>
221
+ <rdfs:range rdf:resource='<%= owl_property_range %>' />
222
+ <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
223
+ <% end %>
224
+ <% if owl_super_property_name != nil %>
225
+ <rdfs:subPropertyOf rdf:resource='#<%= owl_super_property_name %>' />
226
+ <% end %>
227
+ </owl:DatatypeProperty>
228
+ }
229
+
230
+ # Template covering the output file contents for each attribute that is type that is builtin datatype
231
+ attribute_typebuiltin_template = %{<owl:DatatypeProperty rdf:ID='<%= owl_property_name %>'>
232
+ <% if owl_property_domain != nil %>
233
+ <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
234
+ <% end %>
235
+ <rdfs:range rdf:resource='#<%= owl_property_range %>' />
236
+ <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
237
+ <% end %>
238
+ </owl:DatatypeProperty>
239
+ }
240
+
241
+ # Template covering the output file contents for each attribute that is entity or select type
242
+ attribute_entity_template = %{<owl:ObjectProperty rdf:ID='<%= owl_property_name %>'>
243
+ <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
244
+ <rdfs:range rdf:resource='#<%= owl_property_range %>' />
245
+ <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
246
+ <% end %>
247
+ </owl:ObjectProperty>
248
+ }
249
+
250
+ # Template covering the output file contents for each attribute that is entity or select type
251
+ inverse_entity_template = %{<owl:ObjectProperty rdf:ID='<%= owl_property_name %>'>
252
+ <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
253
+ <rdfs:range rdf:resource='#<%= owl_property_range %>' />
254
+ <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
255
+ <% end %>
256
+ <owl:inverseOf rdf:resource="#<%= owl_inverted_property_name %>"/>
257
+ </owl:ObjectProperty>
258
+ }
259
+
260
+ # Template covering the output file contents for each attribute that is a redeclaration and reference to an entity or select type
261
+ attribute_redeclare_entity_template = %{<owl:ObjectProperty rdf:ID='<%= owl_property_name %>'>
262
+ <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
263
+ <rdfs:range rdf:resource='#<%= owl_property_range %>' />
264
+ <rdfs:subPropertyOf rdf:resource='#<%= owl_super_property_name %>' />
265
+ <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
266
+ <% end %>
267
+ </owl:ObjectProperty>
268
+ }
269
+
270
+
271
+
272
+ # Template covering the output file contents for each attribute that is enum datatype
273
+ class_enum_template = %{<owl:Class rdf:ID='<%= owl_class_name %>'>
274
+ <rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
275
+ <owl:oneOf rdf:parseType="Collection">
276
+ <% enumitem_name_list.each do |name| %>
277
+ <rdf:Description rdf:ID="<%= owl_class_name + '.' + name %>"/>
278
+ <% end %>
279
+ </owl:oneOf>
280
+ </owl:Class>}
281
+
282
+
283
+ # Template covering the output file contents for each attribute that is enum datatype
284
+ attribute_enum_template = %{<owl:DatatypeProperty rdf:ID='<%= owl_property_name %>'>
285
+ <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
286
+ <rdfs:range><owl:DataRange><owl:oneOf><rdf:List>
287
+ <% enumitem_name_list.each do |name| %>
288
+ <rdf:first rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= name %></rdf:first>
289
+ <% if enumitem_name_list[enumitem_name_list.size-1] != name %>
290
+ <rdf:rest><rdf:List>
291
+ <% end %>
292
+ <% if enumitem_name_list[enumitem_name_list.size-1] == name %>
293
+ <rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/> </rdf:List>
294
+ <% end %>
295
+ <% end %>
296
+ <% (1..enumitem_name_list.size-1).each do %>
297
+ </rdf:rest></rdf:List>
298
+ <% end %>
299
+ </owl:oneOf></owl:DataRange></rdfs:range>
300
+ <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
301
+ <% end %>
302
+ </owl:DatatypeProperty>}
303
+
304
+
305
+
306
+ # Template covering min cardinality
307
+ min_cardinality_template = %{<rdf:Description rdf:about='#<%= class_name %>'>
308
+ <rdfs:subClassOf>
309
+ <owl:Restriction>
310
+ <owl:onProperty rdf:resource='#<%= owl_property_name %>'/>
311
+ <owl:minCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger"><%= min_cardinality %></owl:minCardinality>
312
+ </owl:Restriction>
313
+ </rdfs:subClassOf>
314
+ </rdf:Description>}
315
+
316
+
317
+ # Template covering max cardinality
318
+ max_cardinality_template = %{<rdf:Description rdf:about='#<%= class_name %>'>
319
+ <rdfs:subClassOf>
320
+ <owl:Restriction>
321
+ <owl:onProperty rdf:resource='#<%= owl_property_name %>'/>
322
+ <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger"><%= max_cardinality %></owl:maxCardinality>
323
+ </owl:Restriction>
324
+ </rdfs:subClassOf>
325
+ </rdf:Description>}
326
+
327
+ # Template covering cardinality
328
+ cardinality_template = %{<rdf:Description rdf:about='#<%= class_name %>'>
329
+ <rdfs:subClassOf>
330
+ <owl:Restriction>
331
+ <owl:onProperty rdf:resource='#<%= owl_property_name %>'/>
332
+ <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger"><%= min_cardinality %></owl:cardinality>
333
+ </owl:Restriction>
334
+ </rdfs:subClassOf>
335
+ </rdf:Description>}
336
+
337
+ # Template covering the output file contents for each schema end
338
+ disjoint_template = %{
339
+ <rdf:Description rdf:about='#<%= first_class_name %>'>
340
+ <owl:disjointWith rdf:resource="#<%= disjoint_class_name %>"/>
341
+ </rdf:Description>}
342
+
343
+
344
+ # Template covering the output file contents for each schema end
345
+ schema_end_template = %{}
346
+
347
+ # Template covering the end of the output file
348
+ overall_end_template = %{ </rdf:RDF>}
349
+
350
+
351
+ def post_process_entity(entity, post_processed_schema_file, datatype_hash)
352
+ attribute_list = entity.attributes_all_array.find_all{ |a| a.kind_of? EXPSM::Explicit}
353
+
354
+ for attribute in attribute_list
355
+
356
+ express_attribute_domain = nil
357
+ if !attribute.isBuiltin
358
+ express_attribute_domain = NamedType.find_by_name( attribute.domain )
359
+ end
360
+ p28_property_name = entity.name.capitalize + '.' + attribute.name.capitalize
361
+ property_quoted = false
362
+ property_list = false
363
+ property_type = '"' + attribute.domain + '"'
364
+ if attribute.isBuiltin
365
+ property_type = '"' + datatype_hash[attribute.domain] + '"'
366
+ end
367
+ if attribute.isBuiltin and attribute.domain == 'STRING'
368
+ property_quoted = true
369
+ end
370
+ if (!attribute.redeclare_entity and express_attribute_domain.instance_of? EXPSM::Type and express_attribute_domain.isBuiltin and express_attribute_domain == 'STRING')
371
+ property_quoted = true
372
+ property_type = '"' + datatype_hash[express_attribute_domain.domain] + '"'
373
+ end
374
+ if ( attribute.isBuiltin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'LIST')
375
+ property_list = true
376
+ property_type = '"' + datatype_hash[attribute.domain] + '"'
377
+ end
378
+
379
+ if (express_attribute_domain.instance_of? EXPSM::Type and express_attribute_domain.isBuiltin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'LIST')
380
+ property_list = true
381
+ property_type = '"' + datatype_hash[express_attribute_domain.domain] + '"'
382
+ end
383
+
384
+ property_type = property_type.gsub('http://www.w3.org/2001/XMLSchema#','xsd:')
385
+ post_processed_schema_file.puts 'property_range_hash["' + p28_property_name + '"] = [' + property_quoted.to_s + ',' + property_list.to_s + ',' + property_type.to_s + ']'
386
+ end
387
+ end
388
+
389
+
390
+ # A recursive function to return complete set of items, following nested selects, for a select that are not selects themselves
391
+ def get_all_selections( item_list )
392
+ select_items = item_list.find_all{ |a| a.kind_of? EXPSM::TypeSelect}
393
+ if select_items.size == 0
394
+ return item_list
395
+ end
396
+ temp_item_list = item_list
397
+ for select in select_items
398
+ temp_item_list.delete( select )
399
+ temp_item_list = temp_item_list + select.selectitems_array
400
+ end
401
+ final_list = get_all_selections( temp_item_list )
402
+ end
403
+
404
+ # A recursive function to return the ultimate underlying type of a type
405
+ def is_utlimate_type_builtin( the_type )
406
+ return true if the_type.isBuiltin
407
+ base_type = NamedType.find_by_name( the_type.domain )
408
+ case
409
+ when (base_type.instance_of? EXPSM::TypeSelect or base_type.instance_of? EXPSM::Entity)
410
+ return false
411
+ when (base_type.kind_of? EXPSM::Type and base_type.isBuiltin)
412
+ return true
413
+ else
414
+ return is_utlimate_type_builtin( base_type )
415
+ end
416
+ end
417
+
418
+ # Set up list of schemas to process, input may be a repository containing schemas or a single schema
419
+ if mapinput.kind_of? EXPSM::Repository
420
+ schema_list = mapinput.schemas
421
+ elsif mapinput.kind_of? EXPSM::SchemaDefinition
422
+ schema_list = [mapinput]
423
+ else
424
+ puts "ERROR : map_from_express input no Repository instance or Schema instance"
425
+ exit
426
+ end
427
+
428
+
429
+ for schema in schema_list
430
+
431
+ type_mapped_list = []
432
+ entity_mapped_list = []
433
+ explicit_mapped_list = []
434
+ inverse_mapped_list = []
435
+ thing_attr_mapped_list = []
436
+ superexpression_mapped_list = []
437
+ list_mapped_attr_list = []
438
+ list_mapped_type_list = []
439
+ type_union_mapped_list = []
440
+ mixed_select_list = []
441
+ all_explicit_list = []
442
+ all_derived_list = []
443
+ all_inverse_list = []
444
+ all_superexpression_list = []
445
+
446
+ # Set up separate file for each schema
447
+ filename = schema.name.to_s + ".owl"
448
+ file = File.new(filename, "w")
449
+
450
+ # Evaluate and write file start template
451
+ res = ERB.new(overall_start_template)
452
+ t = res.result(binding)
453
+ file.puts t
454
+
455
+ # Evaluate and write schema start template
456
+ res = ERB.new(schema_start_template)
457
+ t = res.result(binding)
458
+ file.puts t
459
+
460
+ select_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::TypeSelect }
461
+ entity_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::Entity }
462
+ defined_type_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::Type }
463
+ enum_type_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::TypeEnum }
464
+ defined_type_not_builtin_list = defined_type_list.find_all{ |e| !e.isBuiltin }
465
+ defined_type_builtin_list = defined_type_list.find_all{ |e| e.isBuiltin }
466
+
467
+ # Handle enumeration type maps to RDFS Datatype string
468
+
469
+ for type_enum in enum_type_list
470
+ type_mapped_list.push type_enum
471
+ owl_class_name = type_enum.name
472
+ enumitem_name_list = type_enum.items.scan(/\w+/)
473
+ res = ERB.new(class_enum_template)
474
+ t = res.result(binding)
475
+ file.puts t
476
+ end
477
+
478
+
479
+ # Handle defined type maps to RDFS Datatype
480
+
481
+ for type_builtin in defined_type_builtin_list
482
+
483
+ # Handle defined type maps to RDFS Datatype
484
+ if !type_builtin.instance_of? EXPSM::TypeAggregate
485
+ type_mapped_list.push type_builtin
486
+ datatype_name = type_builtin.name
487
+ superdatatype_name = datatype_hash[type_builtin.domain]
488
+ res = ERB.new(type_builtin_template)
489
+ t = res.result(binding)
490
+ file.puts t
491
+ # Handle defined type maps to RDF List
492
+ else
493
+ list_mapped_type_list.push type_builtin
494
+ type_mapped_list.push type_builtin
495
+ list_name = type_builtin.name
496
+ superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
497
+ res = ERB.new(rdflist_template)
498
+ t = res.result(binding)
499
+ file.puts t
500
+ end
501
+ end
502
+
503
+
504
+ for type_not_builtin in defined_type_not_builtin_list
505
+
506
+ type_domain = NamedType.find_by_name( type_not_builtin.domain )
507
+ type_is_builtin = is_utlimate_type_builtin( type_not_builtin )
508
+
509
+ case
510
+
511
+ # Handle simple defined type refining simple defined type of builtin map to RDFS Datatype
512
+ when (!type_not_builtin.instance_of? EXPSM::TypeAggregate and type_is_builtin and !type_domain.instance_of? EXPSM::TypeAggregate)
513
+ type_mapped_list.push type_not_builtin
514
+ datatype_name = type_not_builtin.name
515
+ superdatatype_name = '#' + type_domain.name
516
+ res = ERB.new(type_builtin_template)
517
+ t = res.result(binding)
518
+ file.puts t
519
+
520
+ # Handle simple defined type of aggr defined type of builtin map to RDF List
521
+ when (!type_not_builtin.instance_of? EXPSM::TypeAggregate and type_domain.instance_of? EXPSM::TypeAggregate and type_is_builtin)
522
+ type_mapped_list.push type_not_builtin
523
+ list_mapped_type_list.push type_not_builtin
524
+ list_name = type_not_builtin.name
525
+ superlist_name = '#' + type_domain.name
526
+ res = ERB.new(rdflist_template)
527
+ t = res.result(binding)
528
+ file.puts t
529
+
530
+ # Handle aggr defined type of simple defined type of builtin map to RDF List
531
+ when (type_not_builtin.instance_of? EXPSM::TypeAggregate and type_domain.instance_of? EXPSM::Type and type_is_builtin)
532
+ type_mapped_list.push type_not_builtin
533
+ list_mapped_type_list.push type_not_builtin
534
+ list_name = type_not_builtin.name
535
+ superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
536
+ res = ERB.new(rdflist_template)
537
+ t = res.result(binding)
538
+ file.puts t
539
+
540
+ # Handle aggr of entity/select type map to RDF List
541
+ when (type_not_builtin.instance_of? EXPSM::TypeAggregate and (type_domain.instance_of? EXPSM::Entity or type_domain.instance_of? EXPSM::TypeSelect))
542
+ type_mapped_list.push type_not_builtin
543
+ list_mapped_type_list.push type_not_builtin
544
+ list_name = type_not_builtin.name
545
+ superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
546
+ res = ERB.new(rdflist_template)
547
+ t = res.result(binding)
548
+ file.puts t
549
+
550
+ # Handle defined type that are type = type that is a select
551
+ when (type_domain.kind_of? EXPSM::TypeSelect)
552
+ type_mapped_list.push type_not_builtin
553
+ superclass_name = type_not_builtin.domain
554
+ class_name = type_not_builtin.name
555
+ res = ERB.new(entity_start_template)
556
+ t = res.result(binding)
557
+ file.puts t
558
+
559
+ superclass_name = type_not_builtin.domain
560
+ res = ERB.new(supertype_template)
561
+ t = res.result(binding)
562
+ file.puts t
563
+
564
+ res = ERB.new(class_end_template)
565
+ t = res.result(binding)
566
+ file.puts t
567
+
568
+ else
569
+ puts 'ERROR : Not mapped = ' + type_not_builtin.name
570
+ end
571
+ end
572
+
573
+
574
+ # Handle EXPRESS SELECT Type mapping to OWL Class hierarchy and RDFS Datatypes
575
+
576
+ for select in select_list
577
+
578
+ item_name_list = select.selectitems.scan(/\w+/)
579
+
580
+ this_select_all_items = get_all_selections( select.selectitems_array )
581
+ this_select_type_items = this_select_all_items.find_all{ |a| a.kind_of? EXPSM::Type}
582
+
583
+ case
584
+
585
+ # Handle case of select items resolving to containing only items that are non-select Type
586
+ when this_select_type_items.size == this_select_all_items.size
587
+ type_mapped_list.push select
588
+ type_union_mapped_list.push select
589
+ type_name_list = item_name_list
590
+ type_name = select.name
591
+ res = ERB.new(datatype_collection_template)
592
+ t = res.result(binding)
593
+ file.puts t
594
+
595
+ # Handle case of select items resolving to containing no item that is a non-select Type
596
+ else
597
+ type_mapped_list.push select
598
+
599
+ res = ERB.new(select_start_template)
600
+ t = res.result(binding)
601
+ file.puts t
602
+ file.puts '<owl:equivalentClass>'
603
+
604
+ res = ERB.new(class_collection_template)
605
+ t = res.result(binding)
606
+ file.puts t
607
+ file.puts '</owl:equivalentClass>'
608
+
609
+ res = ERB.new(select_end_template)
610
+ t = res.result(binding)
611
+ file.puts t
612
+ if (this_select_type_items.size != 0 and this_select_type_items.size != this_select_all_items.size)
613
+ mixed_select_list.push select
614
+ end
615
+
616
+ end
617
+ end
618
+
619
+ # Handle EXPRESS Entity mappings to OWL Class hierarchy
620
+
621
+ for entity in entity_list
622
+
623
+ if definition_hash[entity.name.downcase] != nil
624
+ annotation_list[0] = ['rdfs:comment', definition_hash[entity.name.downcase]]
625
+ else
626
+ annotation_list[0] = ['rdfs:comment', nil]
627
+ end
628
+
629
+ entity_mapped_list.push entity
630
+
631
+ class_name = entity.name
632
+ res = ERB.new(entity_start_template)
633
+ t = res.result(binding)
634
+ file.puts t
635
+
636
+ for supertype in entity.supertypes_array
637
+ superclass_name = supertype.name
638
+ res = ERB.new(supertype_template)
639
+ t = res.result(binding)
640
+ file.puts t
641
+ end
642
+
643
+ res = ERB.new(entity_end_template)
644
+ t = res.result(binding)
645
+ file.puts t
646
+
647
+ # Post-process the entity
648
+ post_process_entity(entity, post_processed_schema_file, datatype_hash) if post_processed_schema
649
+
650
+
651
+ if entity.superexpression != nil
652
+ all_superexpression_list.push entity
653
+
654
+ # Handle simple case of one ONEOF in supertype expression mapped to disjoint between listed subclasses
655
+ case
656
+ # when (entity.superexpression.include?('ONEOF') and !entity.superexpression.include?('ANDOR') and !entity.superexpression.include?('TOTAL_OVER') and !entity.superexpression.include?('AND') and !entity.superexpression.include?('ABSTRACT'))
657
+
658
+ when (entity.superexpression.include?('ONEOF'))
659
+ superexpression_mapped_list.push entity
660
+ tempexpression = entity.superexpression
661
+ if entity.superexpression.index('ONEOF') != 0
662
+ puts 'WARNING: ' + entity.name + ' supertype mapping may be incomplete, only ONEOFs processed'
663
+ end
664
+ while (tempexpression.include?('ONEOF'))
665
+ posoneof = tempexpression.index('ONEOF')
666
+ tempexpression = tempexpression[posoneof + 5,tempexpression.length - 5]
667
+ posclose = tempexpression.index(')')
668
+ oneof_name_list = tempexpression[0,posclose].scan(/\w+/)
669
+ while oneof_name_list.size != 0
670
+ first_class_name = oneof_name_list[0]
671
+ oneof_name_list.delete(first_class_name)
672
+ for disjoint_class_name in oneof_name_list
673
+ res = ERB.new(disjoint_template)
674
+ t = res.result(binding)
675
+ file.puts t
676
+ end
677
+ end
678
+ end
679
+ else
680
+ end
681
+
682
+ end
683
+
684
+
685
+ end
686
+
687
+ # Handle mapping common string attributes to OWL DatatypeProperties of OWL Thing
688
+
689
+ for thing_attribute in thing_attributes
690
+ owl_property_name = thing_attribute
691
+ owl_property_range = 'http://www.w3.org/2001/XMLSchema#string'
692
+ owl_property_domain = nil
693
+ owl_super_property_name = nil
694
+ res = ERB.new(attribute_builtin_template)
695
+ t = res.result(binding)
696
+ file.puts t
697
+ end
698
+
699
+ # Handle EXPRESS attributes on an entity-by-entity basis
700
+ for entity in entity_list
701
+
702
+ class_name = entity.name
703
+
704
+ attribute_list = entity.attributes.find_all{ |a| a.kind_of? EXPSM::Explicit and !thing_attributes.include?(a.name)}
705
+ thing_attr_list = entity.attributes.find_all{ |a| a.kind_of? EXPSM::Explicit and thing_attributes.include?(a.name)}
706
+ inverse_list = entity.attributes.find_all{ |a| a.kind_of? EXPSM::Inverse and !thing_attributes.include?(a.name)}
707
+
708
+ thing_attr_mapped_list = thing_attr_mapped_list + thing_attr_list
709
+
710
+ all_explicit_list = all_explicit_list + entity.attributes.find_all{ |a| a.kind_of? EXPSM::Explicit}
711
+ all_derived_list = all_derived_list + entity.attributes.find_all{ |a| a.kind_of? EXPSM::Derived}
712
+
713
+ all_inverse_list = all_inverse_list + inverse_list
714
+
715
+ # Handle EXPRESS inverse attribute mapping to OWL inverse property
716
+ for attribute in inverse_list
717
+ if attribute.reverseAttr != []
718
+ inverse_mapped_list.push attribute
719
+ owl_property_range = attribute.domain
720
+ owl_property_name = entity.name + '.' + attribute.name
721
+ owl_property_domain = entity.name
722
+ owl_inverted_property_name = attribute.reverseEntity.name + '.' + attribute.reverseAttr.name
723
+ res = ERB.new(inverse_entity_template)
724
+ t = res.result(binding)
725
+ file.puts t
726
+ end
727
+ end
728
+
729
+ # Handle EXPRESS explicit attribute mapping to OWL property
730
+ for attribute in attribute_list
731
+
732
+ express_attribute_domain = nil
733
+ type_is_builtin = false
734
+ if !attribute.isBuiltin
735
+ express_attribute_domain = NamedType.find_by_name( attribute.domain )
736
+ if express_attribute_domain.instance_of? EXPSM::Type
737
+ type_is_builtin = is_utlimate_type_builtin( express_attribute_domain )
738
+ end
739
+ end
740
+
741
+ case
742
+
743
+ # Handle EXPRESS explicit attributes of LIST of built-in simple type, including redeclaration
744
+ when (attribute.isBuiltin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'LIST')
745
+ explicit_mapped_list.push attribute
746
+ list_mapped_attr_list.push attribute
747
+ list_name = entity.name + '.' + attribute.name + '-' + attribute.domain.to_s + '-List'
748
+ superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
749
+ res = ERB.new(rdflist_template)
750
+ t = res.result(binding)
751
+ file.puts t
752
+ owl_property_name = entity.name + '.' + attribute.name
753
+ owl_property_domain = entity.name
754
+ owl_property_range = list_name
755
+ res = ERB.new(attribute_entity_template)
756
+ t = res.result(binding)
757
+ file.puts t
758
+
759
+ # Handle EXPRESS explicit attributes of ARRAY of built-in simple type, including redeclaration
760
+ when (attribute.isBuiltin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'ARRAY')
761
+ explicit_mapped_list.push attribute
762
+ list_mapped_attr_list.push attribute
763
+ list_name = entity.name + '.' + attribute.name + '-' + attribute.domain.to_s + '-Array'
764
+ superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
765
+ res = ERB.new(rdflist_template)
766
+ t = res.result(binding)
767
+ file.puts t
768
+ owl_property_name = entity.name + '.' + attribute.name
769
+ owl_property_domain = entity.name
770
+ owl_property_range = list_name
771
+ res = ERB.new(attribute_entity_template)
772
+ t = res.result(binding)
773
+ file.puts t
774
+
775
+ # Handle EXPRESS explicit attributes of LIST of TYPE that is built-in simple type, including redeclaration
776
+ when (express_attribute_domain.instance_of? EXPSM::Type and type_is_builtin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'LIST')
777
+ explicit_mapped_list.push attribute
778
+ list_mapped_attr_list.push attribute
779
+ list_name = entity.name + '.' + attribute.name + '-' + attribute.domain.to_s + '-List'
780
+ superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
781
+ res = ERB.new(rdflist_template)
782
+ t = res.result(binding)
783
+ file.puts t
784
+ owl_property_name = entity.name + '.' + attribute.name
785
+ owl_property_domain = entity.name
786
+ owl_property_range = list_name
787
+ res = ERB.new(attribute_entity_template)
788
+ t = res.result(binding)
789
+ file.puts t
790
+
791
+ # Handle EXPRESS explicit attributes of ARRAY of TYPE that is built-in simple type, including redeclaration
792
+ when (express_attribute_domain.instance_of? EXPSM::Type and type_is_builtin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'ARRAY')
793
+ explicit_mapped_list.push attribute
794
+ list_mapped_attr_list.push attribute
795
+ list_name = entity.name + '.' + attribute.name + '-' + attribute.domain.to_s + '-Array'
796
+ superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
797
+ res = ERB.new(rdflist_template)
798
+ t = res.result(binding)
799
+ file.puts t
800
+ owl_property_name = entity.name + '.' + attribute.name
801
+ owl_property_domain = entity.name
802
+ owl_property_range = list_name
803
+ res = ERB.new(attribute_entity_template)
804
+ t = res.result(binding)
805
+ file.puts t
806
+
807
+
808
+ # Handle EXPRESS explicit attributes of built-in simple type, including redeclaration
809
+ when (attribute.isBuiltin)
810
+ explicit_mapped_list.push attribute
811
+ owl_property_range = datatype_hash[attribute.domain]
812
+ owl_property_name = entity.name + '.' + attribute.name
813
+ owl_property_domain = entity.name
814
+ owl_super_property_name = nil
815
+ if attribute.redeclare_entity != nil
816
+ if attribute.redeclare_oldname == nil
817
+ owl_super_property_name = attribute.redeclare_entity + '.' + attribute.name
818
+ else
819
+ owl_super_property_name = attribute.redeclare_entity + '.' + attribute.redeclare_oldname
820
+ end
821
+ end
822
+ res = ERB.new(attribute_builtin_template)
823
+ t = res.result(binding)
824
+ file.puts t
825
+
826
+ # Handle EXPRESS explicit attribute, not redeclaration, refers to Type that is Type = builtin datatype
827
+ when (!attribute.redeclare_entity and express_attribute_domain.instance_of? EXPSM::Type and type_is_builtin)
828
+ explicit_mapped_list.push attribute
829
+ owl_property_range = attribute.domain
830
+ owl_property_name = entity.name + '.' + attribute.name
831
+ owl_property_domain = entity.name
832
+ res = ERB.new(attribute_typebuiltin_template)
833
+ t = res.result(binding)
834
+ file.puts t
835
+
836
+ # Handle EXPRESS explicit attributes of enum type, ignoring redeclarations
837
+ when (express_attribute_domain.kind_of? EXPSM::TypeEnum)
838
+ explicit_mapped_list.push attribute
839
+ owl_property_name = entity.name + '.' + attribute.name
840
+ owl_property_domain = entity.name
841
+ owl_property_range = attribute.domain
842
+ res = ERB.new(attribute_entity_template)
843
+
844
+ # if !type_mapped_list.include?(express_attribute_domain)
845
+ # type_mapped_list.push express_attribute_domain
846
+ # end
847
+ # enumitem_name_list = express_attribute_domain.items.scan(/\w+/)
848
+ # res = ERB.new(attribute_enum_template)
849
+
850
+ t = res.result(binding)
851
+ file.puts t
852
+ if attribute.redeclare_entity
853
+ puts 'WARNING: ' + entity.name + ' ' + attribute.name + ' Attribute redeclaration for Enumerations not mapped'
854
+ end
855
+
856
+ # Handle EXPRESS explicit attribute, not redeclaration, and only refer to EXPRESS Select or Entity
857
+ when (!attribute.redeclare_entity and (express_attribute_domain.kind_of? EXPSM::Entity or express_attribute_domain.kind_of? EXPSM::TypeSelect))
858
+ explicit_mapped_list.push attribute
859
+ owl_property_range = attribute.domain
860
+ owl_property_name = entity.name + '.' + attribute.name
861
+ owl_property_domain = entity.name
862
+ res = ERB.new(attribute_entity_template)
863
+ t = res.result(binding)
864
+ file.puts t
865
+
866
+ # Handle EXPRESS explicit attribute, redeclaration, and only refer to EXPRESS Select or Entity
867
+ when (attribute.redeclare_entity and (express_attribute_domain.kind_of? EXPSM::Entity or express_attribute_domain.kind_of? EXPSM::TypeSelect))
868
+ explicit_mapped_list.push attribute
869
+ owl_property_range = attribute.domain
870
+ owl_property_name = entity.name + '.' + attribute.name
871
+ if attribute.redeclare_oldname == nil
872
+ owl_super_property_name = attribute.redeclare_entity + '.' + attribute.name
873
+ else
874
+ owl_super_property_name = attribute.redeclare_entity + '.' + attribute.redeclare_oldname
875
+ end
876
+ owl_property_domain = entity.name
877
+ res = ERB.new(attribute_redeclare_entity_template)
878
+ t = res.result(binding)
879
+ file.puts t
880
+
881
+ # Handle EXPRESS explicit attribute of EXPRESS Type = A Type name that is a Select
882
+ when (express_attribute_domain.kind_of? EXPSM::Type and NamedType.find_by_name( express_attribute_domain.domain ).kind_of? EXPSM::TypeSelect)
883
+ explicit_mapped_list.push attribute
884
+ owl_property_range = attribute.domain
885
+ owl_property_name = entity.name + '.' + attribute.name
886
+ owl_property_domain = entity.name
887
+ res = ERB.new(attribute_entity_template)
888
+ t = res.result(binding)
889
+ file.puts t
890
+
891
+ # Handle EXPRESS explicit attribute, redeclaration, and only refer to EXPRESS Type = A Type name that is a Select
892
+ when (attribute.redeclare_entity and (express_attribute_domain.kind_of? EXPSM::Type and NamedType.find_by_name( express_attribute_domain.domain ).kind_of? EXPSM::TypeSelect))
893
+
894
+ explicit_mapped_list.push attribute
895
+ owl_property_range = attribute.domain
896
+ owl_property_name = entity.name + '.' + attribute.name
897
+ if attribute.redeclare_oldname == nil
898
+ owl_super_property_name = attribute.redeclare_entity + '.' + attribute.name
899
+ else
900
+ owl_super_property_name = attribute.redeclare_entity + '.' + attribute.redeclare_oldname
901
+ end
902
+ owl_property_domain = entity.name
903
+ res = ERB.new(attribute_redeclare_entity_template)
904
+ t = res.result(binding)
905
+ file.puts t
906
+
907
+ else
908
+ puts 'WARNING: ' + entity.name + ' ' + attribute.name + ' Attribute type not yet mapped'
909
+ end
910
+
911
+ min_cardinality = 1
912
+ max_cardinality = 1
913
+
914
+ if attribute.isOptional == true
915
+ min_cardinality = 0
916
+ end
917
+
918
+ if (attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype != 'LIST' and attribute.dimensions[0].aggrtype != 'ARRAY')
919
+ if attribute.isOptional == false
920
+ min_cardinality = attribute.dimensions[0].lower.to_i
921
+ end
922
+ if attribute.dimensions[0].upper == '?'
923
+ max_cardinality = -1
924
+ else
925
+ max_cardinality = attribute.dimensions[0].upper.to_i
926
+ end
927
+ if attribute.rank > 1
928
+ puts 'WARNING: ' + owl_property_name + ' n-dimensional aggregate attribute cardinalities not mapped '
929
+ max_cardinality = -1
930
+ end
931
+ end
932
+
933
+ if min_cardinality == max_cardinality
934
+ res = ERB.new(cardinality_template)
935
+ t = res.result(binding)
936
+ file.puts t
937
+ else
938
+ res = ERB.new(min_cardinality_template)
939
+ t = res.result(binding)
940
+ file.puts t
941
+ if max_cardinality != -1
942
+ res = ERB.new(max_cardinality_template)
943
+ t = res.result(binding)
944
+ file.puts t
945
+ end
946
+ end
947
+
948
+
949
+ if (attribute.redeclare_entity and !(express_attribute_domain.kind_of? EXPSM::Entity or express_attribute_domain.kind_of? EXPSM::TypeSelect))
950
+ if (attribute.redeclare_entity and !(express_attribute_domain.kind_of? EXPSM::Type and NamedType.find_by_name( express_attribute_domain.domain ).kind_of? EXPSM::TypeSelect))
951
+ if (attribute.redeclare_entity and !attribute.isBuiltin)
952
+ puts 'WARNING: ' + entity.name + ' ' + attribute.name + ' Attribute redeclaration may need hand editing'
953
+ end
954
+ end
955
+ end
956
+
957
+ end
958
+
959
+ end
960
+
961
+
962
+ res = ERB.new(schema_end_template)
963
+ t = res.result(binding)
964
+ file.puts t
965
+
966
+ puts ' '
967
+ puts 'Schema Mapping Summary for : ' + schema.name
968
+ all_type_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::DefinedType }
969
+
970
+
971
+ puts ' ENTITYs mapped = ' + entity_mapped_list.size.to_s + ' of ' + entity_list.size.to_s
972
+ puts ' - ' + superexpression_mapped_list.size.to_s + ' of ' + all_superexpression_list.size.to_s + ' ENTITY SUPERTYPE expressions mapped (only simple ONEOF supported)'
973
+ for t in all_superexpression_list - superexpression_mapped_list
974
+ puts ' Not mapped: ' + t.name
975
+ end
976
+ puts ' - ' + inverse_mapped_list.size.to_s + ' of ' + all_inverse_list.size.to_s + ' inverse attributes mapped (inverse of inherited not supported)'
977
+ notmapped_list = all_inverse_list - inverse_mapped_list
978
+ for t in notmapped_list
979
+ puts ' Not mapped: ' + t.entity.name + '.' + t.name
980
+ end
981
+ puts ' - ' + thing_attr_mapped_list.size.to_s + ' of ' + all_explicit_list.size.to_s + ' explicit attributes mapped with owl:Thing as domain (configurable)'
982
+ puts ' - ' + explicit_mapped_list.size.to_s + ' of ' + all_explicit_list.size.to_s + ' explicit attributes mapped'
983
+ for t in list_mapped_attr_list
984
+ puts ' rdf:List mapped: ' + t.name
985
+ end
986
+
987
+ notmapped_list = all_explicit_list - explicit_mapped_list - thing_attr_mapped_list
988
+ for t in notmapped_list
989
+ puts ' Not mapped: ' + t.entity.name + '.' + t.name
990
+ end
991
+ puts ' - ' + all_derived_list.size.to_s + ' derived attributes not mapped, not supported'
992
+ puts ' TYPEs mapped = ' + type_mapped_list.size.to_s + ' of ' + all_type_list.size.to_s
993
+ for t in list_mapped_type_list
994
+ puts ' rdf:List mapped: ' + t.name
995
+ end
996
+ for t in mixed_select_list
997
+ puts ' Select of entity & type Class mapped: ' + t.name
998
+ end
999
+ for t in type_union_mapped_list
1000
+ puts ' Select RDFS Datatype owl:unionOf mapped: ' + t.name
1001
+ end
1002
+ notmapped_list = all_type_list - type_mapped_list
1003
+ for t in notmapped_list
1004
+ puts ' Not mapped: ' + t.name
1005
+ end
1006
+ puts ' '
1007
+ puts 'Wrote post-processed schema to file: ' + post_processed_schema_file_name if post_processed_schema
1008
+
1009
+
1010
+ end
1011
+
1012
+ res = ERB.new(overall_end_template)
1013
+ t = res.result(binding)
1014
+ file.puts t
1015
+
1016
+ post_processed_schema_file.close if post_processed_schema
1017
+
1018
+ end