2012-09-03 48 views
3

標題可能說了一切,我想知道是否可以告訴cxf-codegen插件添加例如xsd-patterns作爲@Pattern註釋。模式驗證很好,所有的,但有時我只想檢查一個單一的元素,而不是無數的XML線。有沒有辦法將JSR303註釋添加到cxf生成的類中?

爲此我在想,如果有一個小竅門/選項/骯髒的黑客那裏,這將有助於我打開

<xs:simpleType name="string2000"> 
    <xs:restriction base="xs:string"> 
     <xs:maxLength value="2000"/> 
     <xs:minLength value="1"/> 
     <xs:pattern value="[\p{IsBasicLatin}\p{IsLatin-1Supplement}-[ \t\r\n]][\p{IsBasicLatin}\p{IsLatin-1Supplement}-[\t\r\n]]*"/> 
    </xs:restriction> 
</xs:simpleType> 

@Pattern(regexp = "\\p{IsBasicLatin}\\p{IsLatin-1Supplement}-[ \\t\\r\\n]][\\p{IsBasicLatin}\\p{IsLatin-1Supplement}-[\\t\\r\\n]]*") 
@Size(min = 1, max = 2000) 

因爲手動添加它是一個不走這個量的XML,它會讓事情變得更容易。

回答

相關問題