java - 在 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
类包含protected List<Byte> byteArrayElement;
,这也是不正确的。XSD
我应该如何在字节数组列表中正确定义?
解决方案
a 的正确类型byte[]
是xs:base64Binary
.
这意味着字段的 XSDList<byte[]> attachmentList
应该是:
<xs:element name="attachmentList" type="xs:base64Binary" minOccurs="0" maxOccurs="unbounded"/>
推荐阅读
- php - 从 Linux 主机连接 Mysql PDO/MySqli
- c# - 用c#websocket获取数据
- node.js - 在flutter中初始化firestore函数时遇到问题
- java - Recyclerview 仅显示一项
- ios - 使用命令“xcodebuild archive \”进行归档过程时出现“ARCHIVE FAILED”错误
- c# - Firebase Admin .SDK 请求权限
- javascript - 如何更新嵌套对象中的数据
- sql-server - Visual Studio中哪个更好的本地数据库或带有ClickOnce的sql server数据库?
- django - Python 3 错误:包 'openpyxl' 需要不同的 Python:3.5.3 不在 '>=3.6,'
- php - 如何将多维json转换为php数组?