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

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

问题描述

我正在使用 JAX-WS 和 JAXB 开发 SOAP 应用程序.我想为其中一个字段指定模式约束(荷兰邮政编码,\d{4}[A-Z]{2}).使用 xsd:pattern 很容易做到这一点,但我找不到等效的 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,可以插入 Marshaller解组器.

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天全站免登陆