3.1.4.7.2 Optional Substitutions

Another feature of BinXml templates is that substitutions can be specified such that the enclosing element or attribute MUST be omitted from rendered XML text (or other processing) if the value identified by the substitution is NULL in the Template Instance data. If this type of rendering from the BinXml is wanted, the substitution needs to be specified by using an optional substitution token. The optional substitution token is 0x0E, as compared to the normal substitution token 0x0D.

The server MAY determine whether to use the optional substitution token based on the event definition.<9>

The following table contains an example where %1 and %2 represent the optional substitution tokens.

Text

Binary

0C

<SomeEvent>

01 SomeEvent 02

<PropA> %1 </PropA>

01 PropA 02 05 0E 00 04

<PropB> %2 </PropB>

01 PropB 02 05 0E 01 04

</SomeEvent>

04 00

02 00 00 01 04

65 00

This tells any processor of the encoded BinXml to use the following XML representation.

 <SomeEvent>
 <PropB> 101 </PropB>   
 </SomeEvent>

Note The preceding Value Spec for the optional element PropA specifies that the substitution value is NULL (see Type System (section 3.1.4.7.3)), and this is how the BinXml processor knows to omit this element.

The optional substitution applies only to the element or attribute immediately enclosing it.

Note If an element contains an optional substitution, and that substitution value is NULL, the element cannot appear in rendered XML, even if that element has attributes containing content, other (nonNULL) substitution values, and so on.