Xtext - 检查字符串是否为 URL

Xtext - 检查字符串是否为 URL

问题描述:

我对 Xtext 完全陌生,所以在此先感谢您的帮助.

I'm completely new to Xtext so thanks in advance for your help.

我有以下几点:

terminal PATTERN_SRC : STRING '.png';
Pattern: name='pattern:' value=PATTERN_SRC;

我希望用户像这样编码:

I want the user to code it like this:

pattern: (URL to image ending with .png / .jpg / .gif)

目前我正在检查它,但这不起作用.

Currently I'm checking it like this but this does not work.

有什么好的方法可以解决这个问题吗?提前致谢!

Is there a nice way to solve this? Thanks in advance!

个人评论:

不要使用功能name.这是用于计算资源中元素的唯一名称的保留关键字.

Don't use the feature name. This is a reserved keyword for calculating unique names of an element in a resource.

STRING 是这样的:Sometext".所以你想要的是 "somefile.png"你描述的是"somefile".png您可以只使用 STRING 并实施验证规则以确保您的网址有效.

STRING is like this: "Sometext". So what you want is "somefile.png" What you described is "somefile".png You could just use STRING and implement a validation rule to ensure your URL is valid.