Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[smila-dev] XML and attachments

Hi folks,

 

I have seen there is now support for transporting attachments in JSON and BON. I was wondering if we should add this to XML as well to stay lossless between the formats.

 

To keep it simple I would make the following suggestion which is a change to the XML record format.

 

<Attachment key=’name’>${base64}</Attachment>

 

However, it is still somewhat compatible with the old format because:

·         From the reading perspective it wanst possible to parse <Attachment/> tags anyhow

·         From the writing perspective we could allow an option to either just write the old 2.0 style, i.e. just the attachment names as a hint or write them out incl. the binary content encoded as base64. It should also be possible to filter which of the attachment shall be parsed as base64 and which not.

 

API suggestion:

 

  enum AttachmentWriteStyle {

    BASE64, HINT, OMIT

  };

 

  /**

   * Serialize2.

   *

   * @param record

   *          the record to be serialized

   * @param attachmentNamesAsBase64

   *          the attachment names to be base64 encoded in the XML output. If an attachment name is included in both

   *          lists then this one wins.

   * @param attachmentNamesAsHint

   *          for those attachment only their names are written (2.0 style)

   * @param remainderStyle

   *          controls how the attachmets are written that are not included in either of the arrays.

   */

  void serialize2(Record record, String[] attachmentNamesAsBase64, String[] attachmentNamesAsHint,

    AttachmentWriteStyle remainderStyle) {

  }

 

  /**

   * Serialize2.

   *

   * @param record the record to be serialized

   * @param attachmentNames the attachment names

   * @param namedStyle the style how the name attachments are to be written

   * @param remainderStyle controls how the attachmets are written that are not included in attachmentNames[]

   */

  void serialize2(Record record, String[] attachmentNames, AttachmentWriteStyle namedStyle, AttachmentWriteStyle remainderStyle) {

  }

 

Of course for each there will be the diff. kinds of outputs (string, byte[] , stream) for each of these.

 

I was 1st wondering if there is actually another need for this at all apart from staying compatible, and I think there is, namely logging.

 

Well, tell me what you think and if you had other plans regarding this.

 

Also, I would propose to increase the record version to 2.1 then, or does this justify a jump to 3.0?

 

Thomas Menzel @ brox IT-Solutions GmbH

 



Taglocity Tags: smila

Back to the top