包括XS:限制(S)在MOXY生成的Java类的注释(S) [英] including xs:restriction(s) as annotation(s) in moxy generated java classes

查看:214
本文介绍了包括XS:限制(S)在MOXY生成的Java类的注释(S)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些新的 XSD模式版本更新为此我需要生成相应的Java类。在过去,我的理解是,其中使用的EclipseLink的莫西JAXB实现,我总是生成的类可以看到,如果该架构包含< XS:限制/> 模式,如< XS:模式值=[A-ZA-Z]/> ,则相应的Java类将与生成的 @Pattern (正则表达式=[A-ZA-Z],邮件=...)在其中的注释。

I have some new xsd schema version updates for which I need to generate corresponding java classes. In the past, I understand that the classes where always generated using EclipseLink's Moxy JAXB implementation and I can see that if the schemas contained <xs:restriction/> patterns such as <xs:pattern value="[a-zA-Z]"/>, then the corresponding java classes would be generated with @Pattern(regexp="[a-zA-Z]", message= "...") annotations in them.

当我使用莫西在我的设置来生成这些Java类,这些类产生不错,但没有在他们@Pattern注释。我不是太熟悉,JAXB,我想知道我可能会丢失,以便从模式自动导出这些注释和插入的Java类本身。

When I use Moxy in my setup to generate these java classes, the classes are generated okay but without the @Pattern annotations in them. I am not too familiar with JAXB and I am wondering what I may be missing to allow for these annotations to be derived from the schemas and inserted into the java classes themselves automatically.

我也不太知道这是因为我没有使用莫西(目前使用的版本2.1.2的EclipseLink的)或者允许被自动创建这些注释,不管是previously另一个工具的新版本不够用于插入这些注释到类。

I am not too sure if this is because I am not using a new enough version of Moxy (currently using 2.1.2 version of EclipseLink) which allows for these annotations to be automatically created or, whether previously another tool was used for inserting these annotations into the classes.

在这个问题上的任何帮助将非常AP preciated。

Any help on this matter would be much appreciated.

问候,
PM。

Regards, PM.

推荐答案

注意:我是的 的EclipseLink JAXB(莫西) 领导和的 JAXB(JSR-222) 专家小组。

Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.

生成的类

的EclipseLink JAXB(莫西)包括从 JAXB参考实现 。目前,XJC工具没有内置的机制来产生 Bean验证(JSR- 303) 标注在模型中。

EclipseLink JAXB (MOXy) includes the XML Schema to Java Compiler (XJC) from the JAXB reference implementation. Currently the XJC tool does not have a built in mechanism to generate Bean Validation (JSR-303) annotations in the model.

XJC扩展

我还没有试过以下扩展自己,但看起来它可能就是你在找什么。由于XJC是非常可扩展可能有其他的插件可用。

I have not tried the following extension myself but it looks like it may do what you are looking for. As XJC is very extensible there may be other plug-ins available as well.

  • http://code.google.com/p/krasa-jaxb-tools/

的EclipseLink的当前版本

Current Versions of EclipseLink

我也不太知道这是因为我没有使用新的足够
  莫西(目前使用的版本2.1.2的EclipseLink的)版本

I am not too sure if this is because I am not using a new enough version of Moxy (currently using 2.1.2 version of EclipseLink)

目前的版本是2.4.1的EclipseLink,可以从下面的链接获得。它包含了新的扩展功能,如 JSON结合

The current version is EclipseLink 2.4.1 and can be obtained from the link below. It contains new extensions such as JSON binding.

  • http://www.eclipse.org/eclipselink/downloads/

这篇关于包括XS:限制(S)在MOXY生成的Java类的注释(S)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆