如何解决在XSD中定义字节数组列表
在我的DTO中,我有一个变量List<byte[]> attachmentList
,我想在XSD中对其建模。到目前为止,我有:
<xs:element name="attachmentList" type="AttachmentList">
</xs:element>
<!-- more code goes here -->
<!-- List of ByteArrays -->
<xs:complexType name="AttachmentList">
<xs:sequence>
<xs:element name="documents" type="ByteArray" nillable="true">
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ByteArray">
<xs:sequence>
<xs:element maxOccurs="unbounded" name="byteArrayElement" type="xs:byte"/>
</xs:sequence>
</xs:complexType>
不幸的是,在JAXB
生成的类中,它随后显示为protected AttachmentList attachmentList;
,AttachmentList
包含protected ByteArray documents;
,最后ByteArray
类包含{ {1}},这也是不正确的。我应该如何在protected List<Byte> byteArrayElement;
中正确定义一个字节数组列表?
解决方法
byte[]
的正确类型是xs:base64Binary
。
这意味着字段List<byte[]> attachmentList
的XSD应该简单地是:
<xs:element name="attachmentList" type="xs:base64Binary" minOccurs="0" maxOccurs="unbounded"/>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。