Re: [web-nfc] Do we want to add support for writing sub records? (#357)

Short answer: yes.

Long answer below.

The informative section 4.3.C. of the NFC Forum RTD spec says this is possible, but also that it's _defined by the application_, together with the use of ID as context or other internal referencing method. IOW they don't exclude that NDEF message format could be used in a recursive manner to describe message _trees_.

The Web NFC API being such an "application", we could make the private decision to support parsing and constructing message trees that since it may be convenient for developers.

I think we should reformulate the algo for [`toRecords()`](https://w3c.github.io/web-nfc/#dom-ndefrecord-torecords) to specify since I am not convinced that `toRecords()` should only operate recursively on external records (step 3.1. in the [convert payload](https://w3c.github.io/web-nfc/#dfn-convert-ndefrecord-payloaddata-bytes) steps). According to the RTD at least we can side any number of records and messages, only that we need to encompass them with the right payload length field into the containing record. FWIW "Sp" is well known type so the algo would not work on it (would fail in step 3.1). I understand we just piggyback-invoke the algo to cover the recursivity, but then we should either get rid of the check on TNF (which we don't want since we need to check on [proper ABNF](https://w3c.github.io/web-nfc/#dfn-external-type)), or otherwise reformulate the algo for [`toRecords()`](https://w3c.github.io/web-nfc/#dom-ndefrecord-torecords).

IMHO the API can already express defining a message tree by simply assigning `data` of [NDEFRecord](https://w3c.github.io/web-nfc/#the-ndefrecord-interface) to an [NDEFMessage](https://w3c.github.io/web-nfc/#the-ndefmessage-interface) object for instance.

However, we may want to validate that input (e.g. allow trees only on TNF=1 "Sp" and TNF=4). We could also do that in the [create Web NFC message](https://w3c.github.io/web-nfc/#dfn-create-web-nfc-message) steps and then we don't need Web IDL changes, just algorithm and implementation changes. 

-- 
GitHub Notification of comment by zolkis
Please view or discuss this issue at https://github.com/w3c/web-nfc/issues/357#issuecomment-535069146 using your GitHub account

Received on Wednesday, 25 September 2019 15:09:44 UTC