如何指定使用JAXB注释的模式约束? [英] How do I specify a pattern constraint using JAXB annotations?

查看:185
本文介绍了如何指定使用JAXB注释的模式约束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用JAX-WS和JAXB一个SOAP应用程序。我想指定的一个字段的模式约束(荷兰后期code, \\ D {4} [A-Z] {2} )。这是非常容易使用 XSD做:模式,但我找不到相当于JAXB注释。我该如何实现这一目标?

I'm developing a SOAP application using JAX-WS and JAXB. I'd like to specify a pattern constraint for one of the fields (a Dutch postcode, \d{4}[A-Z]{2}). That's very easy to do using xsd:pattern, but I can't find the equivalent JAXB annotation. How do I achieve this?

推荐答案

您不能。这个想法是结合使用JAXB标注与运行时验证对抗模式,使用 javax.xml.validation.Schema ,可插入编组的Unmarshaller

You can't. The idea is to use JAXB annotations in combination with runtime validation against the schema, using javax.xml.validation.Schema, which can be plugged into the Marshaller and Unmarshaller.

这篇关于如何指定使用JAXB注释的模式约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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