在 XSD 中定义一个字节数组列表
Define in XSD a list of byte arrays
在我的 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
生成的 class 中显示为 protected AttachmentList attachmentList;
, AttachmentList
包含 protected ByteArray documents;
最后是 ByteArray
class 包含 protected List<Byte> byteArrayElement;
,这也是不正确的。如何在 XSD
中正确定义字节数组列表?
byte[]
的正确类型是 xs:base64Binary
。
这意味着字段 List<byte[]> attachmentList
的 XSD 应该只是:
<xs:element name="attachmentList" type="xs:base64Binary" minOccurs="0" maxOccurs="unbounded"/>
在我的 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
生成的 class 中显示为 protected AttachmentList attachmentList;
, AttachmentList
包含 protected ByteArray documents;
最后是 ByteArray
class 包含 protected List<Byte> byteArrayElement;
,这也是不正确的。如何在 XSD
中正确定义字节数组列表?
byte[]
的正确类型是 xs:base64Binary
。
这意味着字段 List<byte[]> attachmentList
的 XSD 应该只是:
<xs:element name="attachmentList" type="xs:base64Binary" minOccurs="0" maxOccurs="unbounded"/>