You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OCL at0运算符语法错误:Timespan适配及OCL语法参考求助

Answers to Your MDriven & OCL Questions

Hey there! Let's work through your issues step by step:

1. Does at0 support the Timespan type?

Nope, that's exactly why you're seeing a syntax error. The at0 operator in MDriven's OCL implementation is a collection-focused operator—it’s designed to pull the first element from sequences, sets, or bags. Since Timespan is a single value type (not a collection), applying at0 to it doesn’t make logical sense, hence the syntax error.

2. How to create a specific Timespan duration in OCL?

MDriven’s OCL dialect has a dedicated Duration class with static methods to build Timespan values cleanly. Here are the most practical approaches:

  • To create a 10-hour Timespan (matching your use case):
    Duration.hours(10)
    
  • For more precise, combined durations, you can chain methods:
    Duration.days(1).hours(2).minutes(30).seconds(15)
    
  • If you need to assign this directly to your Employee instance’s HoursWorked property, your expression would look like:
    Employee.allInstances()->first().HoursWorked := Duration.hours(10)
    

For the most accurate, MDriven-specific OCL syntax and expressions, stick to the MDriven OCL Reference Wiki. It covers every supported operator, type handling (including Timespan/Duration), collection operations, and MDriven-specific extensions—way more aligned with your timesheet project than generic OCL resources. If you want to dive into standard OCL fundamentals, the OMG OCL Specification is also a solid baseline, but the MDriven wiki will be your go-to for day-to-day work.

内容的提问来源于stack exchange,提问作者Gustaf

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 07:26:35