Setting binary attribute with the contents of a FileDocument
I want to be able to export the data in questionnaires to an XML. Sometimes an user also uploads an attachment. This must therefore be included in the XML. Therefore, an attachment element has been included in the XSD with xs: base64Binary as datatype. See also the domain model. XSD element attachment <xs:element name="Bijlage" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="Name"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:maxLength value="400" /> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="Contents" type="xs:base64Binary" /> <xs:element name="Size" type="xs:long" /> </xs:sequence> </xs:complexType> </xs:element> The issue is that I cannot select the attribute "Contents (binary)". This should be done in a microflow that should transfer the value of the uploaded FileDocument to the attribute "Contents" for the XML. Does anyone have an idea how I can set a binary attribute in this case with the contents of a FileDocument? [note: making the XML entities to be persistent or non-persistent doesn't seem to matter]
I believe attributes of type ‘Binary’ are only supported in persistable entities.
Do you use an export mapping to generate your XML? because you can select the ‘contents’ there
You should use the Base64EncodeFile from CommunityCommons, where the attachment is your input and and the returned string from the java action should go in your XML as Bijlage.Contents.
Hi Lennart, Sjors,
Thanks for your replies. The respective binary attribute can indeed be replaced by a string. Together with the relevant Java action, I can set a value which can be analyzed by the receiving party. The disadvantage however seems to be efficiency, especially with an application in which large files can be sent several times a day. In this case, an export mapping can help, and also circumvents the problem of not being able to select the binary attribute. I'm going to check both options, thanks!