3.1.4.7.1 BinXml Templates

BinXml encoding supports a way to use a template of a BinXml fragment and apply it to a set of values. A BinXml template describes the format and contents of an event independent of the values contained in a specific instance of the event being described. It contains property names and placeholders for the event properties.

The primary advantage of this is that the values (set of data) can remain in native form and only need to be converted to text if the BinXml encoding is actually rendered into XML text.

A BinXml encoding of an XML fragment that uses templates and a set of substitution values is referred to as a Template Instance. A Template Definition is a BinXml fragment that contains substitution tokens, and the Template Instance Data refers to the set of values.

Continuing the example from BinXml (section 3.1.4.7) with a possible sample Template Definition, note the following:

  • This example uses two substitution tokens, %1 and %2, that are replaced by specific event values at rendering time.

  • These tokens map to substitution identifiers in the BinXML template.

  • The substitution identifiers are 0-based, whereas the substitution tokens are 1-based.

  • The Text column of the following table shows the XML representation of the various fields.

  • The Binary column of the following table shows the binary representation of those fields encoded in BinXML.

    Text

    Binary

    <SomeEvent>

    01 SomeEvent 02

    <PropA> %1 </PropA>

    01 PropA 02 05 0D 00 04

    <PropB> %3 </PropB>

    01 PropB 02 05 0D 01 04

    </SomeEvent>

    04 00

Where the substitution token is 0D, and is followed by a substitution identifier (00 or 01 in the example).

This template definition can be combined with raw UINT8 values { 0x63, 0x65 } to form a Template Instance such as the following example. The ordering of the values is significant: the first value encountered maps to the first substitution identifier; the second value maps to the second substitution identifier, and so on. In the following example, the value 0x63 replaces the identifier 00 at rendering time, and the 0x65 replaces identifier 01.

Text

Binary

0C

<SomeEvent>

01 SomeEvent 02

<PropA> %1 </PropA>

01 PropA 02 05 0D 00 04

<PropB> %2 </PropB>

01 PropB 02 05 0D 01 04

</SomeEvent>

04 00

0 01 04 01 04

63 65 00

Note The beginning Template Instance token (0x0C) and the trailing end of fragment or document token (EOFToken, 0x00) for the Template Instance immediately following the Template Definition is information about the type and length of the values that make up the Template Instance data. This is called the Value Spec of the Template Instance. In this example, there are 2 values, each of UINT8 integer type ( 04 ) and each of length 1.

If the BinXml in the preceding example is rendered as XML text, it looks identical to the first example, as follows.

 <SomeEvent> 
 <PropA> 99 </PropA> 
 <PropB> 101 </PropB>   
 </SomeEvent>
            

Substitutions can occur in attribute values as well as any other place where XML character data is allowed (for example, in element content). Within these regions, there are no restrictions on the number of substitutions that can exist.