CS158a
Chris Pollett
May 3, 2023
(tag, length, value)where tag is usually an 8-bit field -- although multi-byte fields can be supported, length is how many bytes in value, and value contains the actual data.
message Person { required string name = 1; required int32 id = 2; optional string email = 3; enum PhoneType { MOBILE = 0; HOME = 1; WORK = 2; } message PhoneNumber { required string number = 1; optional PhoneType type = 2 [default = HOME]; } required PhoneNumber phone = 4; }
<?xml version="1.0"?> <employee> <name>John Doe</name> <title>Head Bottle Washer</title> <id>123456789</id> <hiredate> <day>5</day> <month>June</month> <year>1986</year> </hiredate> </employee>
<?xml version="1.0"?> <schema xmlns="http://www.w3.org/2001/XMLSchema"> <element name="employee"> <complexType> <sequence> <element name="name" type="string"/> <element name="title" type="string"/> <element name="id" type="string"/> <element name="hiredate"> <complexType> <sequence> <element name="day" type="integer"/> <element name="month" type="string"/> <element name="year" type="integer"/> </sequence> </complexType> </element> </sequence> </complexType> </element> </schema>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:emp="http://www.example.com/employee" >
<emp:title>Head Bottle Washer</emp:title>