久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在從 Java JAXB 注釋類生成的模式中生成 XSD 限制

Generation of XSD restrictions in a schema generated from Java JAXB annotated classes(在從 Java JAXB 注釋類生成的模式中生成 XSD 限制)
本文介紹了在從 Java JAXB 注釋類生成的模式中生成 XSD 限制的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

MOXy BeanValidation 讓我能夠向我的 JAXB 添加驗證類.

MOXy BeanValidation gives me the ability to add validation to my JAXB classes.

使用 MOXy 的Bean 驗證插件",我可以根據 restrictions/在生成的 JAXB 類中進行 Bean 驗證來自現有架構的方面.

Using MOXy's "Bean Validation Plugin" I can have Bean Validation in generated JAXB classes based on restrictions/facets from a prexisting Schema.

但是有什么方法可以生成模式 restrictions/facets基于 Bean Validation 注釋來自 JAXB 注釋的 java 類?

However is there any way of generating a schema with restrictions/facetsbased on Bean Validation annotations from a JAXB annotated java class?

XJC 在模式優先"生成 java 時有一個方便的插件架構,但是是否有任何等效的java 優先"方法來增強生成的 XSD 并附加限制,甚至添加 XML 注釋?在 MOXy 還是 JAXB-RI 中?

XJC has a handy plugin architecture when doing 'schema first' generating java, but is there any equivalent 'java first' way to enhance the generated XSD with additional restrictions, or even to add XML comments ? Either in MOXy or JAXB-RI?

MOXy 在中間映射中非常靈活,這可以在模式生成期間使用嗎?

MOXy is extremely flexible with meet in the middle mappings, can this be used during schema generation?

jaxb-facets 項目 似乎可以滿足我的要求,但實施者必須分叉整個新的 JAXB-RI 來獲取它,而且它似乎不會很快被采用.(查看這個 Java JIRA)

The jaxb-facets project seems to do what I want but the implementer had to fork an entire new JAXB-RI to get it in and it seems that it won't be adopted any time soon.(See this Java JIRA)

我嘗試了@m0mus 指定的分辨率,但必須使用 sonatype 存儲庫中的 2.7.0-SNAPSHOT 版本.我還有幾個問題;1. 我必須用@XmlElement 注釋java 字段以使構面出現在xsd 中.@XmlAttribute, @XmlAccessorType(XmlAccessType.FIELD) 沒有區別.@Pattern 不起作用;我不得不在 Pattern.List 中使用單個 Pattern;

I tried the resolution specified by @m0mus but had to use the 2.7.0-SNAPSHOT versions from the sonatype repository. I still had a couple of problems; 1. I had to annotate the java fields with @XmlElement to get the facets to appear in the xsd. @XmlAttribute, @XmlAccessorType(XmlAccessType.FIELD) made no difference. @Pattern did not work; I had to work around with a single Pattern in Pattern.List;

@XmlElement
@Pattern.List(value = { @Pattern(regexp="[0-9]*") })
public String phoneNumber2;

有關詳細信息,請參閱 EclipseLink 論壇

For more info see the EclipseLink Forum

推薦答案

我認為它就在那里.MOXy 使用自己的 SchemaGen 實現從 Java 類生成 XSD 文件的過程.SchemaGen 已擴展為基于 Java 類上的 BV 注釋自動生成 XSD 限制和方面.由于模式生成過程是在創建 JAXBContext 時進行的,因此可以通過在 JAXBContext 上設置以下屬性(在 JAXBContextProperties 中找到)來打開/關閉 BV 增強功能:

I think it is there. MOXy uses its own SchemaGen implementation for the process of generating XSD files from Java classes. SchemaGen was extended to automatically generate XSD Restrictions and Facets based on BV annotations found on Java classes. Since the schema generation process takes place upon creation of JAXBContext, the BV enhancement feature can be turned on/off by setting the following property (found in JAXBContextProperties) on JAXBContext:

/**
 * Property for disabling/enabling generation of XML Facets during schemagen.
 * The mapped value must be of type Boolean.
 * If it's true, then facets will be generated, based on the BV annotations.
 * If false, the BV annotations processing will be skipped during schemagen
 * and no facets will be generated.
 *
 * @since 2.6
 */
public static final String GENERATE_FACETS = "eclipselink.generate.facets";

SchemaGen 可識別 BV API 提供的注釋,包括 @Pattern.List.如果 SchemaGen 遇到同時使用 @NotNull 和 @XmlElement(nillable = true) 注釋的字段,它將引發 BeanValidationException.notNullAndNillable().

SchemaGen recognizes annotations provided by the BV API, including @Pattern.List. If SchemaGen encounters a field annotated with both @NotNull and @XmlElement(nillable = true), it will raise the BeanValidationException.notNullAndNillable().

示例:

Map props = new HashMap( );
props.put("eclipselink.beanvalidation.facets", true);
JAXBContext jc = JAXBContext.newInstance(classes, properties);
SchemaOutputResolver sor = new MSOR();
jc.generateSchema(sor);

這篇關于在從 Java JAXB 注釋類生成的模式中生成 XSD 限制的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 在线天堂免费中文字幕视频 | 韩国主播午夜大尺度福利 | 欧美日韩精品久久久免费观看 | 亚洲五码久久 | 天天综合国产 | 欧美不卡一区二区三区 | 国产精品乱码一区二区三区 | 亚洲欧洲激情 | 亚洲成人三级 | 精品无码久久久久国产 | www亚洲免费国内精品 | 亚洲啊v在线 | 国产亚洲精品91 | 一级片aaa| 欧美福利在线 | 亚洲精品一二区 | 国产一级免费视频 | 欧美成人在线影院 | 中文日韩在线 | 亚洲三区在线 | 欧美久久精品一级黑人c片 91免费在线视频 | 免费视频久久 | 精品一区二区久久久久久久网站 | 国产精品国产精品国产专区不蜜 | 99精品在线观看 | 午夜午夜精品一区二区三区文 | 美女视频网站久久 | 欧美区日韩区 | 亚洲免费网站 | 国产日韩欧美在线观看 | 日韩电影在线 | 狠狠躁18三区二区一区 | 精品国产一区二区在线 | 一区二区视频 | 国产精品中文在线 | 黄色免费在线观看网址 | 黄色网址在线免费播放 | 欧美激情第一区 | 国产最新网址 | caoporn免费 | 黄色在线免费观看 |