Welcome to mirror list, hosted at ThFree Co, Russian Federation.

xmpp_codec.spec « tools - github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bf224780fd750f15ced97c725a49b94342241fac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
{last,
 #elem{name = <<"query">>,
       xmlns = <<"jabber:iq:last">>,
       result = {last, '$seconds', '$text'},
       attrs = [#attr{name = <<"seconds">>,
                      default = undefined,
                      enc = {enc_int, []},
                      dec = {dec_int, [0, infinity]}}],
       cdata = #cdata{label = '$text'}}}.

{version_name,
 #elem{name = <<"name">>,
       xmlns = <<"jabber:iq:version">>,
       result = '$cdata',
       cdata = #cdata{label = '$cdata', required = true}}}.

{version_ver,
 #elem{name = <<"version">>,
       xmlns = <<"jabber:iq:version">>,
       result = '$cdata',
       cdata = #cdata{label = '$cdata', required = true}}}.

{version_os,
 #elem{name = <<"os">>,
       xmlns = <<"jabber:iq:version">>,
       result = '$cdata',
       cdata = #cdata{label = '$cdata', required = true}}}.

{version,
 #elem{name = <<"query">>,
       xmlns = <<"jabber:iq:version">>,
       result = {version, '$name', '$ver', '$os'},
       refs = [#ref{name = version_name,
                    label = '$name',
                    min = 0, max = 1},
               #ref{name = version_ver,
                    label = '$ver',
                    min = 0, max = 1},
               #ref{name = version_os,
                    label = '$os',
                    min = 0, max = 1}]}}.

{roster_group,
 #elem{name = <<"group">>,
       xmlns = <<"jabber:iq:roster">>,
       result = '$cdata',
       cdata = #cdata{required = true, label = '$cdata'}}}.

{roster_item,
 #elem{name = <<"item">>,
       xmlns = <<"jabber:iq:roster">>,
       result = {roster_item, '$jid', '$name',
                 '$groups', '$subscription', '$ask'},
       attrs = [#attr{name = <<"jid">>,
                      required = true,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}},
                #attr{name = <<"name">>},
                #attr{name = <<"subscription">>,
                      default = none,
                      enc = {enc_enum, []},
                      dec = {dec_enum, [[none,to,from,both,remove]]}},
                #attr{name = <<"ask">>,
                      default = undefined,
                      enc = {enc_enum, []},
                      dec = {dec_enum, [[subscribe]]}}],
       refs = [#ref{name = roster_group, label = '$groups'}]}}.

{roster,
 #elem{name = <<"query">>,
       xmlns = <<"jabber:iq:roster">>,
       result = {roster, '$items', '$ver'},
       attrs = [#attr{name = <<"ver">>}],
       refs = [#ref{name = roster_item, label = '$items'}]}}.

{privacy_message, #elem{name = <<"message">>, xmlns = <<"jabber:iq:privacy">>,
                        result = message}}.
{privacy_iq, #elem{name = <<"iq">>, xmlns = <<"jabber:iq:privacy">>,
                   result = iq}}.
{privacy_presence_in, #elem{name = <<"presence-in">>,
                            xmlns = <<"jabber:iq:privacy">>,
                            result = 'presence-in'}}.
{privacy_presence_out, #elem{name = <<"presence-out">>,
                             xmlns = <<"jabber:iq:privacy">>,
                             result = 'presence-out'}}.

{privacy_item,
 #elem{name = <<"item">>,
       xmlns = <<"jabber:iq:privacy">>,
       result = {privacy_item, '$order', '$action', '$type',
                 '$value', '$kinds'},
       attrs = [#attr{name = <<"action">>,
                      required = true,
                      dec = {dec_enum, [[allow, deny]]},
                      enc = {enc_enum, []}},
                #attr{name = <<"order">>,
                      required = true,
                      dec = {dec_int, [0, infinity]},
                      enc = {enc_int, []}},
                #attr{name = <<"type">>,
                      dec = {dec_enum, [[group, jid, subscription]]},
                      enc = {enc_enum, []}},
                #attr{name = <<"value">>}],
       refs = [#ref{name = privacy_message,
                    label = '$kinds'},
               #ref{name = privacy_iq,
                    label = '$kinds'},
               #ref{name = privacy_presence_in,
                    label = '$kinds'},
               #ref{name = privacy_presence_out,
                    label = '$kinds'}]}}.

{privacy_list,
 #elem{name = <<"list">>,
       xmlns = <<"jabber:iq:privacy">>,
       result = {privacy_list, '$name', '$items'},
       attrs = [#attr{name = <<"name">>,
                      required = true}],
       refs = [#ref{name = privacy_item,
                    label = '$items'}]}}.

{privacy_default_list,
 #elem{name = <<"default">>,
       xmlns = <<"jabber:iq:privacy">>,
       result = '$name',
       attrs = [#attr{name = <<"name">>,
                      default = none}]}}.

{privacy_active_list,
 #elem{name = <<"active">>,
       xmlns = <<"jabber:iq:privacy">>,
       result = '$name',
       attrs = [#attr{name = <<"name">>,
                      default = none}]}}.

{privacy,
 #elem{name = <<"query">>,
       xmlns = <<"jabber:iq:privacy">>,
       result = {privacy, '$lists', '$default', '$active'},
       refs = [#ref{name = privacy_list,
                    label = '$lists'},
               #ref{name = privacy_default_list,
                    min = 0, max = 1,
                    label = '$default'},
               #ref{name = privacy_active_list,
                    min = 0, max = 1,
                    label = '$active'}]}}.

{block_item,
 #elem{name = <<"item">>,
       xmlns = <<"urn:xmpp:blocking">>,
       result = '$jid',
       attrs = [#attr{name = <<"jid">>,
                      required = true,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}}]}}.

{block,
 #elem{name = <<"block">>,
       xmlns = <<"urn:xmpp:blocking">>,
       result = {block, '$items'},
       refs = [#ref{name = block_item,
                    label = '$items'}]}}.

{unblock,
 #elem{name = <<"unblock">>,
       xmlns = <<"urn:xmpp:blocking">>,
       result = {unblock, '$items'},
       refs = [#ref{name = block_item,
                    label = '$items'}]}}.

{block_list,
 #elem{name = <<"blocklist">>,
       xmlns = <<"urn:xmpp:blocking">>,
       result = {block_list}}}.

{disco_identity,
 #elem{name = <<"identity">>,
       xmlns = <<"http://jabber.org/protocol/disco#info">>,
       result = {identity, '$category', '$type', '$lang', '$name'},
       attrs = [#attr{name = <<"category">>,
                      required = true},
                #attr{name = <<"type">>,
                      required = true},
                #attr{name = <<"xml:lang">>,
                      label = '$lang'},
                #attr{name = <<"name">>}]}}.

{disco_feature,
 #elem{name = <<"feature">>,
       xmlns = <<"http://jabber.org/protocol/disco#info">>,
       result = '$var',
       attrs = [#attr{name = <<"var">>,
                      required = true}]}}.

{disco_info,
 #elem{name = <<"query">>,
       xmlns = <<"http://jabber.org/protocol/disco#info">>,
       result = {disco_info, '$node', '$identity', '$feature', '$xdata'},
       attrs = [#attr{name = <<"node">>}],
       refs = [#ref{name = disco_identity,
                    label = '$identity'},
               #ref{name = disco_feature,
                    label = '$feature'},
               #ref{name = xdata,
                    label = '$xdata'}]}}.

{disco_item,
 #elem{name = <<"item">>,
       xmlns = <<"http://jabber.org/protocol/disco#items">>,
       result = {disco_item, '$jid', '$name', '$node'},
       attrs = [#attr{name = <<"jid">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []},
                      required = true},
                #attr{name = <<"name">>},
                #attr{name = <<"node">>}]}}.
{disco_items,
 #elem{name = <<"query">>,
       xmlns = <<"http://jabber.org/protocol/disco#items">>,
       result = {disco_items, '$node', '$items'},
       attrs = [#attr{name = <<"node">>}],
       refs = [#ref{name = disco_item,
                    label = '$items'}]}}.

{private,
 #elem{name = <<"query">>,
       xmlns = <<"jabber:iq:private">>,
       result = {private, '$_els'}}}.

{conference_nick,
 #elem{name = <<"nick">>,
       xmlns = <<"storage:bookmarks">>,
       result = '$cdata'}}.

{conference_password,
 #elem{name = <<"password">>,
       xmlns = <<"storage:bookmarks">>,
       result = '$cdata'}}.

{bookmark_conference,
 #elem{name = <<"conference">>,
       xmlns = <<"storage:bookmarks">>,
       result = {bookmark_conference, '$name', '$jid',
                 '$autojoin', '$nick', '$password'},
       attrs = [#attr{name = <<"name">>,
                      required = true},
                #attr{name = <<"jid">>,
                      required = true,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}},
                #attr{name = <<"autojoin">>,
                      default = false,
                      dec = {dec_bool, []},
                      enc = {enc_bool, []}}],
       refs = [#ref{name = conference_nick,
                    label = '$nick',
                    min = 0, max = 1},
               #ref{name = conference_password,
                    label = '$password',
                    min = 0, max = 1}]}}.

{bookmark_url,
 #elem{name = <<"url">>,
       xmlns = <<"storage:bookmarks">>,
       result = {bookmark_url, '$name', '$url'},
       attrs = [#attr{name = <<"name">>,
                      required = true},
                #attr{name = <<"url">>,
                      required = true}]}}.

{bookmarks_storage,
 #elem{name = <<"storage">>,
       xmlns = <<"storage:bookmarks">>,
       result = {bookmark_storage, '$conference', '$url'},
       refs = [#ref{name = bookmark_conference,
                    label = '$conference'},
               #ref{name = bookmark_url,
                    label = '$url'}]}}.

{stat_error,
 #elem{name = <<"error">>,
       xmlns = <<"http://jabber.org/protocol/stats">>,
       result = {'$code', '$cdata'},
       attrs = [#attr{name = <<"code">>,
                      required = true,
                      enc = {enc_int, []},
                      dec = {dec_int, []}}]}}.

{stat,
 #elem{name = <<"stat">>,
       xmlns = <<"http://jabber.org/protocol/stats">>,
       result = {stat, '$name', '$units', '$value', '$error'},
       attrs = [#attr{name = <<"name">>,
                      required = true},
                #attr{name = <<"units">>},
                #attr{name = <<"value">>}],
       refs = [#ref{name = stat_error,
                    label = '$error'}]}}.

{stats,
 #elem{name = <<"query">>,
       xmlns = <<"http://jabber.org/protocol/stats">>,
       result = {stats, '$stat'},
       refs = [#ref{name = stat,
                    label = '$stat'}]}}.

{iq,
 #elem{name = <<"iq">>,
       xmlns = <<"jabber:client">>,
       result = {iq, '$id', '$type', '$lang', '$from', '$to',
                 '$error', '$_els'},
       attrs = [#attr{name = <<"id">>,
                      required = true},
                #attr{name = <<"type">>,
                      required = true,
                      enc = {enc_enum, []},
                      dec = {dec_enum, [[get, set, result, error]]}},
                #attr{name = <<"from">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}},
                #attr{name = <<"to">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}},
                #attr{name = <<"xml:lang">>,
                      label = '$lang'}],
       refs = [#ref{name = error, min = 0, max = 1, label = '$error'}]}}.

{message_subject,
 #elem{name = <<"subject">>,
       xmlns = <<"jabber:client">>,
       result = {text, '$lang', '$data'},
       cdata = #cdata{label = '$data'},
       attrs = [#attr{name = <<"xml:lang">>, label = '$lang'}]}}.

{message_body,
 #elem{name = <<"body">>,
       xmlns = <<"jabber:client">>,
       result = {text, '$lang', '$data'},
       cdata = #cdata{label = '$data'},
       attrs = [#attr{name = <<"xml:lang">>, label = '$lang'}]}}.

{message_thread,
 #elem{name = <<"thread">>,
       xmlns = <<"jabber:client">>,
       result = '$cdata'}}.

{message,
 #elem{name = <<"message">>,
       xmlns = <<"jabber:client">>,
       result = {message, '$id', '$type', '$lang', '$from', '$to',
                 '$subject', '$body', '$thread', '$error', '$_els'},
       attrs = [#attr{name = <<"id">>},
                #attr{name = <<"type">>,
                      default = normal,
                      enc = {enc_enum, []},
                      dec = {dec_enum, [[chat, normal, groupchat,
                                         headline, error]]}},
                #attr{name = <<"from">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}},
                #attr{name = <<"to">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}},
                #attr{name = <<"xml:lang">>,
                      label = '$lang'}],
       refs = [#ref{name = error, min = 0, max = 1, label = '$error'},
               #ref{name = message_subject, label = '$subject'},
               #ref{name = message_thread, min = 0, max = 1, label = '$thread'},
               #ref{name = message_body, label = '$body'}]}}.

{presence_show,
 #elem{name = <<"show">>,
       xmlns = <<"jabber:client">>,
       result = '$cdata',
       cdata = #cdata{enc = {enc_enum, []},
                      dec = {dec_enum, [[away, chat, dnd, xa]]}}}}.

{presence_status,
 #elem{name = <<"status">>,
       xmlns = <<"jabber:client">>,
       result = {text, '$lang', '$data'},
       cdata = #cdata{label = '$data'},
       attrs = [#attr{name = <<"xml:lang">>,
                      label = '$lang'}]}}.

{presence_priority,
 #elem{name = <<"priority">>,
       xmlns = <<"jabber:client">>,
       result = '$cdata',
       cdata = #cdata{enc = {enc_int, []},
                      dec = {dec_int, []}}}}.

{presence,
 #elem{name = <<"presence">>,
       xmlns = <<"jabber:client">>,
       result = {presence, '$id', '$type', '$lang', '$from', '$to',
                 '$show', '$status', '$priority', '$error', '$_els'},
       attrs = [#attr{name = <<"id">>},
                #attr{name = <<"type">>,
                      enc = {enc_enum, []},
                      dec = {dec_enum, [[unavailable, subscribe, subscribed,
                                         unsubscribe, unsubscribed,
                                         probe, error]]}},
                #attr{name = <<"from">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}},
                #attr{name = <<"to">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}},
                #attr{name = <<"xml:lang">>,
                      label = '$lang'}],
       refs = [#ref{name = error, min = 0, max = 1, label = '$error'},
               #ref{name = presence_show, min = 0, max = 1, label = '$show'},
               #ref{name = presence_status, label = '$status'},
               #ref{name = presence_priority, min = 0, max = 1,
                    label = '$priority'}]}}.

{error_bad_request,
 #elem{name = <<"bad-request">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'bad-request'}}.
{error_conflict,
 #elem{name = <<"conflict">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'conflict'}}.
{error_feature_not_implemented,
 #elem{name = <<"feature-not-implemented">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'feature-not-implemented'}}.
{error_forbidden,
 #elem{name = <<"forbidden">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'forbidden'}}.
{error_gone,
 #elem{name = <<"gone">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       cdata = #cdata{label = '$uri'},
       result = {'gone', '$uri'}}}.
{error_internal_server_error,
 #elem{name = <<"internal-server-error">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'internal-server-error'}}.
{error_item_not_found,
 #elem{name = <<"item-not-found">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'item-not-found'}}.
{error_jid_malformed,
 #elem{name = <<"jid-malformed">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'jid-malformed'}}.
{error_not_acceptable,
 #elem{name = <<"not-acceptable">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'not-acceptable'}}.
{error_not_allowed,
 #elem{name = <<"not-allowed">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'not-allowed'}}.
{error_not_authorized,
 #elem{name = <<"not-authorized">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'not-authorized'}}.
{error_policy_violation,
 #elem{name = <<"policy-violation">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'policy-violation'}}.
{error_recipient_unavailable,
 #elem{name = <<"recipient-unavailable">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'recipient-unavailable'}}.
{error_redirect,
 #elem{name = <<"redirect">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       cdata = #cdata{label = '$uri'},
       result = {'redirect', '$uri'}}}.
{error_registration_required,
 #elem{name = <<"registration-required">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'registration-required'}}.
{error_remote_server_not_found,
 #elem{name = <<"remote-server-not-found">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'remote-server-not-found'}}.
{error_remote_server_timeout,
 #elem{name = <<"remote-server-timeout">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'remote-server-timeout'}}.
{error_resource_constraint,
 #elem{name = <<"resource-constraint">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'resource-constraint'}}.
{error_service_unavailable,
 #elem{name = <<"service-unavailable">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'service-unavailable'}}.
{error_subscription_required,
 #elem{name = <<"subscription-required">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'subscription-required'}}.
{error_undefined_condition,
 #elem{name = <<"undefined-condition">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'undefined-condition'}}.
{error_unexpected_request,
 #elem{name = <<"unexpected-request">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       result = 'unexpected-request'}}.

{error_text,
 #elem{name = <<"text">>,
       result = {text, '$lang', '$data'},
       cdata = #cdata{label = '$data'},
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>,
       attrs = [#attr{name = <<"xml:lang">>,
                      label = '$lang'}]}}.

{error,
 #elem{name = <<"error">>,
       xmlns = <<"jabber:client">>,
       result = {error, '$type', '$by', '$reason', '$text'},
       attrs = [#attr{name = <<"type">>,
                      label = '$type',
                      required = true,
                      dec = {dec_enum, [[auth, cancel, continue,
                                         modify, wait]]},
                      enc = {enc_enum, []}},
                #attr{name = <<"by">>}],
       refs = [#ref{name = error_text,
                    min = 0, max = 1, label = '$text'},
               #ref{name = error_bad_request,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_conflict,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_feature_not_implemented,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_forbidden,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_gone,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_internal_server_error,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_item_not_found,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_jid_malformed,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_not_acceptable,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_not_allowed,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_not_authorized,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_policy_violation,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_recipient_unavailable,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_redirect,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_registration_required,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_remote_server_not_found,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_remote_server_timeout,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_resource_constraint,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_service_unavailable,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_subscription_required,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_undefined_condition,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = error_unexpected_request,
                    min = 0, max = 1, label = '$reason'}]}}.

{bind_jid,
 #elem{name = <<"jid">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-bind">>,
       result = '$cdata',
       cdata = #cdata{dec = {dec_jid, []},
                      enc = {enc_jid, []}}}}.

{bind_resource,
 #elem{name = <<"resource">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-bind">>,
       result = '$cdata',
       cdata = #cdata{dec = {resourceprep, []},
                      enc = {resourceprep, []}}}}.

{bind, #elem{name = <<"bind">>,
             xmlns = <<"urn:ietf:params:xml:ns:xmpp-bind">>,
             result = {bind, '$jid', '$resource'},
             refs = [#ref{name = bind_jid,
                          label = '$jid',
                          min = 0, max = 1},
                     #ref{name = bind_resource,
                          min = 0, max = 1,
                          label = '$resource'}]}}.

{sasl_auth,
 #elem{name = <<"auth">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>,
       cdata = #cdata{label = '$text',
                      dec = {base64, decode, []},
                      enc = {base64, encode, []}},
       result = {sasl_auth, '$mechanism', '$text'},
       attrs = [#attr{name = <<"mechanism">>,
                      required = true}]}}.

{sasl_abort,
 #elem{name = <<"abort">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>,
       result = {sasl_abort}}}.

{sasl_challenge,
 #elem{name = <<"challenge">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>,
       cdata = #cdata{label = '$text',
                      dec = {base64, decode, []},
                      enc = {base64, encode, []}},
       result = {sasl_challenge, '$text'}}}.

{sasl_response,
 #elem{name = <<"response">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>,
       cdata = #cdata{label = '$text',
                      dec = {base64, decode, []},
                      enc = {base64, encode, []}},
       result = {sasl_response, '$text'}}}.

{sasl_success,
 #elem{name = <<"success">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>,
       cdata = #cdata{label = '$text',
                      dec = {base64, decode, []},
                      enc = {base64, encode, []}},
       result = {sasl_success, '$text'}}}.

{sasl_failure_text,
 #elem{name = <<"text">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>,
       result = {text, '$lang', '$data'},
       cdata = #cdata{label = '$data'},
       attrs = [#attr{name = <<"xml:lang">>,
                      label = '$lang'}]}}.

{sasl_failure_aborted,
 #elem{name = <<"aborted">>,
       result = 'aborted',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}}.
{sasl_failure_account_disabled,
 #elem{name = <<"account-disabled">>,
       result = 'account-disabled',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}}.
{sasl_failure_credentials_expired,
 #elem{name = <<"credentials-expired">>,
       result = 'credentials-expired',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}}.
{sasl_failure_encryption_required,
 #elem{name = <<"encryption-required">>,
       result = 'encryption-required',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}}.
{sasl_failure_incorrect_encoding,
 #elem{name = <<"incorrect-encoding">>,
       result = 'incorrect-encoding',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}}.
{sasl_failure_invalid_authzid,
 #elem{name = <<"invalid-authzid">>,
       result = 'invalid-authzid',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}}.
{sasl_failure_invalid_mechanism,
 #elem{name = <<"invalid-mechanism">>,
       result = 'invalid-mechanism',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}}.
{sasl_failure_malformed_request,
 #elem{name = <<"malformed-request">>,
       result = 'malformed-request',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}}.
{sasl_failure_mechanism_too_weak,
 #elem{name = <<"mechanism-too-weak">>,
       result = 'mechanism-too-weak',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}}.
{sasl_failure_not_authorized,
 #elem{name = <<"not-authorized">>,
       result = 'not-authorized',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}}.
{sasl_failure_temporary_auth_failure,
 #elem{name = <<"temporary-auth-failure">>,
       result = 'temporary-auth-failure',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}}.

{sasl_failure,
 #elem{name = <<"failure">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>,
       result = {sasl_failure, '$reason', '$text'},
       refs = [#ref{name = sasl_failure_text,
                    label = '$text'},
               #ref{name = sasl_failure_aborted,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = sasl_failure_account_disabled,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = sasl_failure_credentials_expired,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = sasl_failure_encryption_required,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = sasl_failure_incorrect_encoding,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = sasl_failure_invalid_authzid,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = sasl_failure_invalid_mechanism,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = sasl_failure_malformed_request,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = sasl_failure_mechanism_too_weak,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = sasl_failure_not_authorized,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = sasl_failure_temporary_auth_failure,
                    min = 0, max = 1, label = '$reason'}]}}.

{sasl_mechanism,
 #elem{name = <<"mechanism">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>,
       result = '$cdata'}}.

{sasl_mechanisms,
 #elem{name = <<"mechanisms">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>,
       result = {sasl_mechanisms, '$list'},
       refs = [#ref{name = sasl_mechanism,
                    label = '$list'}]}}.

{starttls_required,
 #elem{name = <<"required">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-tls">>,
       result = true}}.

{starttls,
 #elem{name = <<"starttls">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-tls">>,
       result = {starttls, '$required'},
       refs = [#ref{name = starttls_required,
                    label = '$required',
                    min = 0, max = 1,
                    default = false}]}}.

{starttls_proceed,
 #elem{name = <<"proceed">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-tls">>,
       result = {starttls_proceed}}}.

{starttls_failure,
 #elem{name = <<"failure">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-tls">>,
       result = {starttls_failure}}}.

{compress_failure_setup_failed,
 #elem{name = <<"setup-failed">>,
       xmlns = <<"http://jabber.org/protocol/compress">>,
       result = 'setup-failed'}}.
{compress_failure_processing_failed,
 #elem{name = <<"processing-failed">>,
       xmlns = <<"http://jabber.org/protocol/compress">>,
       result = 'processing-failed'}}.
{compress_failure_unsupported_method,
 #elem{name = <<"unsupported-method">>,
       xmlns = <<"http://jabber.org/protocol/compress">>,
       result = 'unsupported-method'}}.

{compress_failure,
 #elem{name = <<"failure">>,
       xmlns = <<"http://jabber.org/protocol/compress">>,
       result = {compress_failure, '$reason'},
       refs = [#ref{name = compress_failure_setup_failed,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = compress_failure_processing_failed,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = compress_failure_unsupported_method,
                    min = 0, max = 1, label = '$reason'}]}}.

{compress_method,
 #elem{name = <<"method">>,
       xmlns = <<"http://jabber.org/protocol/compress">>,
       result = '$cdata'}}.

{compress,
 #elem{name = <<"compress">>,
       xmlns = <<"http://jabber.org/protocol/compress">>,
       result = {compress, '$methods'},
       refs = [#ref{name = compress_method,
                    label = '$methods'}]}}.

{compressed,
 #elem{name = <<"compressed">>,
       xmlns = <<"http://jabber.org/protocol/compress">>,
       result = {compressed}}}.

{compression_method,
 #elem{name = <<"method">>,
       xmlns = <<"http://jabber.org/features/compress">>,
       result = '$cdata'}}.

{compression,
 #elem{name = <<"compression">>,
       xmlns = <<"http://jabber.org/features/compress">>,
       result = {compression, '$methods'},
       refs = [#ref{name = compression_method, label = '$methods'}]}}.
 
{stream_features,
 #elem{name = <<"stream:features">>,
       xmlns = <<"http://etherx.jabber.org/streams">>,
       result = {stream_features, '$_els'}}}.

{p1_push,
 #elem{name = <<"push">>,
       result = {p1_push},
       xmlns = <<"p1:push">>}}.

{p1_rebind,
 #elem{name = <<"rebind">>,
       result = {p1_rebind},
       xmlns = <<"p1:rebind">>}}.

{p1_ack,
 #elem{name = <<"ack">>,
       result = {p1_ack},
       xmlns = <<"p1:ack">>}}.

{caps,
 #elem{name = <<"c">>,
       xmlns = <<"http://jabber.org/protocol/caps">>,
       result = {caps, '$hash', '$node', '$ver'},
       attrs = [#attr{name = <<"hash">>},
                #attr{name = <<"node">>},
                #attr{name = <<"ver">>,
                      enc = {base64, encode, []},
                      dec = {base64, decode, []}}]}}.

{feature_register,
 #elem{name = <<"register">>,
       xmlns = <<"http://jabber.org/features/iq-register">>,
       result = {feature_register}}}.

{register_registered,
 #elem{name = <<"registered">>,
       xmlns = <<"jabber:iq:register">>,
       result = true}}.
{register_remove,
 #elem{name = <<"remove">>,
       xmlns = <<"jabber:iq:register">>,
       result = true}}.
{register_instructions,
 #elem{name = <<"instructions">>,
       xmlns = <<"jabber:iq:register">>,
       result = '$cdata'}}.
{register_username,
 #elem{name = <<"username">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.
{register_nick,
 #elem{name = <<"nick">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.
{register_password,
 #elem{name = <<"password">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.
{register_name,
 #elem{name = <<"name">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.
{register_first,
 #elem{name = <<"first">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.
{register_last,
 #elem{name = <<"last">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.
{register_email,
 #elem{name = <<"email">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.
{register_address,
 #elem{name = <<"address">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.
{register_city,
 #elem{name = <<"city">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.
{register_state,
 #elem{name = <<"state">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.
{register_zip,
 #elem{name = <<"zip">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.
{register_phone,
 #elem{name = <<"phone">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.
{register_url,
 #elem{name = <<"url">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.
{register_date,
 #elem{name = <<"date">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.
{register_misc,
 #elem{name = <<"misc">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.
{register_text,
 #elem{name = <<"text">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.
{register_key,
 #elem{name = <<"key">>,
       xmlns = <<"jabber:iq:register">>,
       cdata = #cdata{default = none},
       result = '$cdata'}}.

{register,
 #elem{name = <<"query">>,
       xmlns = <<"jabber:iq:register">>,
       result = {register, '$registered', '$remove', '$instructions',
                 '$username', '$nick', '$password', '$name',
                 '$first', '$last', '$email', '$address',
                 '$city', '$state', '$zip', '$phone', '$url',
                 '$date', '$misc', '$text', '$key'},
       refs = [#ref{name = register_registered, min = 0, max = 1,
                    default = false, label = '$registered'},
               #ref{name = register_remove, min = 0, max = 1,
                    default = false, label = '$remove'},
               #ref{name = register_instructions, min = 0, max = 1,
                    label = '$instructions'},
               #ref{name = register_username, min = 0, max = 1,
                    label = '$username'},
               #ref{name = register_nick, min = 0, max = 1,
                    label = '$nick'},
               #ref{name = register_password, min = 0, max = 1,
                    label = '$password'},
               #ref{name = register_name, min = 0, max = 1,
                    label = '$name'},
               #ref{name = register_first, min = 0, max = 1,
                    label = '$first'},
               #ref{name = register_last, min = 0, max = 1,
                    label = '$last'},
               #ref{name = register_email, min = 0, max = 1,
                    label = '$email'},
               #ref{name = register_address, min = 0, max = 1,
                    label = '$address'},
               #ref{name = register_city, min = 0, max = 1,
                    label = '$city'},
               #ref{name = register_state, min = 0, max = 1,
                    label = '$state'},
               #ref{name = register_zip, min = 0, max = 1,
                    label = '$zip'},
               #ref{name = register_phone, min = 0, max = 1,
                    label = '$phone'},
               #ref{name = register_url, min = 0, max = 1,
                    label = '$url'},
               #ref{name = register_date, min = 0, max = 1,
                    label = '$date'},
               #ref{name = register_misc, min = 0, max = 1,
                    label = '$misc'},
               #ref{name = register_text, min = 0, max = 1,
                    label = '$text'},
               #ref{name = register_key, min = 0, max = 1,
                    label = '$key'}]}}.

{session,
 #elem{name = <<"session">>,
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-session">>,
       result = {session}}}.

{ping,
 #elem{name = <<"ping">>,
       xmlns = <<"urn:xmpp:ping">>,
       result = {ping}}}.

{time_utc,
 #elem{name = <<"utc">>,
       xmlns = <<"urn:xmpp:time">>,
       result = '$cdata',
       cdata = #cdata{dec = {dec_utc, []},
                      enc = {enc_utc, []}}}}.

{time_tzo,
 #elem{name = <<"tzo">>,
       xmlns = <<"urn:xmpp:time">>,
       result = '$cdata',
       cdata = #cdata{dec = {dec_tzo, []},
                      enc = {enc_tzo, []}}}}.

{time,
 #elem{name = <<"time">>,
       xmlns = <<"urn:xmpp:time">>,
       result = {time, '$tzo', '$utc'},
       refs = [#ref{name = time_tzo,
                    label = '$tzo',
                    min = 0, max = 1},
               #ref{name = time_utc,
                    label = '$utc',
                    min = 0, max = 1}]}}.

{stream_error_text,
 #elem{name = <<"text">>,
       result = {text, '$lang', '$data'},
       cdata = #cdata{label = '$data'},
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>,
       attrs = [#attr{name = <<"xml:lang">>,
                      label = '$lang'}]}}.

{stream_error_bad_format,
 #elem{name = <<"bad-format">>,
       result = 'bad-format',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.       
{stream_error_bad_namespace_prefix,
 #elem{name = <<"bad-namespace-prefix">>,
       result = 'bad-namespace-prefix',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_conflict,
 #elem{name = <<"conflict">>,
       result = 'conflict',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_connection_timeout,
 #elem{name = <<"connection-timeout">>,
       result = 'connection-timeout',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_host_gone,
 #elem{name = <<"host-gone">>,
       result = 'host-gone',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_host_unknown,
 #elem{name = <<"host-unknown">>,
       result = 'host-unknown',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_improper_addressing,
 #elem{name = <<"improper-addressing">>,
       result = 'improper-addressing',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_internal_server_error,
 #elem{name = <<"internal-server-error">>,
       result = 'internal-server-error',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_invalid_from,
 #elem{name = <<"invalid-from">>,
       result = 'invalid-from',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_invalid_id,
 #elem{name = <<"invalid-id">>,
       result = 'invalid-id',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_invalid_namespace,
 #elem{name = <<"invalid-namespace">>,
       result = 'invalid-namespace',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_invalid_xml,
 #elem{name = <<"invalid-xml">>,
       result = 'invalid-xml',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_not_authorized,
 #elem{name = <<"not-authorized">>,
       result = 'not-authorized',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_not_well_formed,
 #elem{name = <<"not-well-formed">>,
       result = 'not-well-formed',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_policy_violation,
 #elem{name = <<"policy-violation">>,
       result = 'policy-violation',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_remote_connection_failed,
 #elem{name = <<"remote-connection-failed">>,
       result = 'remote-connection-failed',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_reset,
 #elem{name = <<"reset">>,
       result = 'reset',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_resource_constraint,
 #elem{name = <<"resource-constraint">>,
       result = 'resource-constraint',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_restricted_xml,
 #elem{name = <<"restricted-xml">>,
       result = 'restricted-xml',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_see_other_host,
 #elem{name = <<"see-other-host">>,
       cdata = #cdata{required = true, label = '$host'},
       result = {'see-other-host', '$host'},
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_system_shutdown,
 #elem{name = <<"system-shutdown">>,
       result = 'system-shutdown',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_undefined_condition,
 #elem{name = <<"undefined-condition">>,
       result = 'undefined-condition',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_unsupported_encoding,
 #elem{name = <<"unsupported-encoding">>,
       result = 'unsupported-encoding',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_unsupported_stanza_type,
 #elem{name = <<"unsupported-stanza-type">>,
       result = 'unsupported-stanza-type',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.
{stream_error_unsupported_version,
 #elem{name = <<"unsupported-version">>,
       result = 'unsupported-version',
       xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}}.

{stream_error,
 #elem{name = <<"stream:error">>,
       xmlns = <<"http://etherx.jabber.org/streams">>,
       result = {stream_error, '$reason', '$text'},
       refs = [#ref{name = stream_error_text,
                    label = '$text',
                    min = 0, max = 1},
               #ref{name = stream_error_bad_format,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_bad_namespace_prefix,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_conflict,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_connection_timeout,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_host_gone,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_host_unknown,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_improper_addressing,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_internal_server_error,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_invalid_from,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_invalid_id,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_invalid_namespace,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_invalid_xml,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_not_authorized,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_not_well_formed,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_policy_violation,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_remote_connection_failed,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_reset,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_resource_constraint,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_restricted_xml,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_see_other_host,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_system_shutdown,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_undefined_condition,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_unsupported_encoding,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_unsupported_stanza_type,
                    min = 0, max = 1, label = '$reason'},
               #ref{name = stream_error_unsupported_version,
                    min = 0, max = 1, label = '$reason'}
              ]}}.

{vcard_HOME, #elem{name = <<"HOME">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_WORK, #elem{name = <<"WORK">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_VOICE, #elem{name = <<"VOICE">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_FAX, #elem{name = <<"FAX">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_PAGER, #elem{name = <<"PAGER">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_MSG, #elem{name = <<"MSG">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_CELL, #elem{name = <<"CELL">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_VIDEO, #elem{name = <<"VIDEO">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_BBS, #elem{name = <<"BBS">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_MODEM, #elem{name = <<"MODEM">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_ISDN, #elem{name = <<"ISDN">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_PCS, #elem{name = <<"PCS">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_POSTAL, #elem{name = <<"POSTAL">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_PARCEL, #elem{name = <<"PARCEL">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_DOM, #elem{name = <<"DOM">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_INTL, #elem{name = <<"INTL">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_PREF, #elem{name = <<"PREF">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_INTERNET, #elem{name = <<"INTERNET">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_X400, #elem{name = <<"X400">>, xmlns = <<"vcard-temp">>, result = true}}.
{vcard_FAMILY, #elem{name = <<"FAMILY">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_GIVEN, #elem{name = <<"GIVEN">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_MIDDLE, #elem{name = <<"MIDDLE">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_PREFIX, #elem{name = <<"PREFIX">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_SUFFIX, #elem{name = <<"SUFFIX">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_POBOX, #elem{name = <<"POBOX">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_EXTADD, #elem{name = <<"EXTADD">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_STREET, #elem{name = <<"STREET">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_LOCALITY, #elem{name = <<"LOCALITY">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_REGION, #elem{name = <<"REGION">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_PCODE, #elem{name = <<"PCODE">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_CTRY, #elem{name = <<"CTRY">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_LINE, #elem{name = <<"LINE">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_NUMBER, #elem{name = <<"NUMBER">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_USERID, #elem{name = <<"USERID">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_LAT, #elem{name = <<"LAT">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_LON, #elem{name = <<"LON">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_ORGNAME, #elem{name = <<"ORGNAME">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_ORGUNIT, #elem{name = <<"ORGUNIT">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_PHONETIC, #elem{name = <<"PHONETIC">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_CRED, #elem{name = <<"CRED">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_VERSION, #elem{name = <<"VERSION">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_FN, #elem{name = <<"FN">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_NICKNAME, #elem{name = <<"NICKNAME">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_BDAY, #elem{name = <<"BDAY">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_JABBERID, #elem{name = <<"JABBERID">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_MAILER, #elem{name = <<"MAILER">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_TZ, #elem{name = <<"TZ">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_TITLE, #elem{name = <<"TITLE">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_ROLE, #elem{name = <<"ROLE">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_KEYWORD, #elem{name = <<"KEYWORD">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_NOTE, #elem{name = <<"NOTE">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_PRODID, #elem{name = <<"PRODID">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_REV, #elem{name = <<"REV">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_SORT_STRING, #elem{name = <<"SORT-STRING">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_UID, #elem{name = <<"UID">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_URL, #elem{name = <<"URL">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_DESC, #elem{name = <<"DESC">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_TYPE, #elem{name = <<"TYPE">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_EXTVAL, #elem{name = <<"EXTVAL">>, xmlns = <<"vcard-temp">>, result = '$cdata'}}.
{vcard_PUBLIC, #elem{name = <<"PUBLIC">>, xmlns = <<"vcard-temp">>, result = public}}.
{vcard_PRIVATE, #elem{name = <<"PRIVATE">>, xmlns = <<"vcard-temp">>, result = private}}.
{vcard_CONFIDENTIAL, #elem{name = <<"CONFIDENTIAL">>, xmlns = <<"vcard-temp">>, result = confidential}}.

{vcard_N,
 #elem{name = <<"N">>,
       xmlns = <<"vcard-temp">>,
       result = {vcard_name, '$family', '$given', '$middle',
                 '$prefix', '$suffix'},
       refs = [#ref{name = vcard_FAMILY, min = 0, max = 1, label = '$family'},
               #ref{name = vcard_GIVEN, min = 0, max = 1, label = '$given'},
               #ref{name = vcard_MIDDLE, min = 0, max = 1, label = '$middle'},
               #ref{name = vcard_PREFIX, min = 0, max = 1, label = '$prefix'},
               #ref{name = vcard_SUFFIX, min = 0, max = 1, label = '$suffix'}]}}.

{vcard_ADR,
 #elem{name = <<"ADR">>,
       xmlns = <<"vcard-temp">>,
       result = {vcard_adr, '$home', '$work', '$postal', '$parcel',
                '$dom', '$intl', '$pref', '$pobox', '$extadd', '$street',
                '$locality', '$region', '$pcode', '$ctry'},
       refs = [#ref{name = vcard_HOME, default = false,
                    min = 0, max = 1, label = '$home'},
               #ref{name = vcard_WORK, default = false,
                    min = 0, max = 1, label = '$work'},
               #ref{name = vcard_POSTAL, default = false,
                    min = 0, max = 1, label = '$postal'},
               #ref{name = vcard_PARCEL, default = false,
                    min = 0, max = 1, label = '$parcel'},
               #ref{name = vcard_DOM, default = false,
                    min = 0, max = 1, label = '$dom'},
               #ref{name = vcard_INTL, default = false,
                    min = 0, max = 1, label = '$intl'},
               #ref{name = vcard_PREF, default = false,
                    min = 0, max = 1, label = '$pref'},
               #ref{name = vcard_POBOX, min = 0, max = 1, label = '$pobox'},
               #ref{name = vcard_EXTADD, min = 0, max = 1, label = '$extadd'},
               #ref{name = vcard_STREET, min = 0, max = 1, label = '$street'},
               #ref{name = vcard_LOCALITY, min = 0, max = 1, label = '$locality'},
               #ref{name = vcard_REGION, min = 0, max = 1, label = '$region'},
               #ref{name = vcard_PCODE, min = 0, max = 1, label = '$pcode'},
               #ref{name = vcard_CTRY, min = 0, max = 1, label = '$ctry'}]}}.

{vcard_LABEL,
 #elem{name = <<"LABEL">>,
       xmlns = <<"vcard-temp">>,
       result = {vcard_label, '$home', '$work', '$postal', '$parcel',
                '$dom', '$intl', '$pref', '$line'},
       refs = [#ref{name = vcard_HOME, default = false,
                    min = 0, max = 1, label = '$home'},
               #ref{name = vcard_WORK, default = false,
                    min = 0, max = 1, label = '$work'},
               #ref{name = vcard_POSTAL, default = false,
                    min = 0, max = 1, label = '$postal'},
               #ref{name = vcard_PARCEL, default = false,
                    min = 0, max = 1, label = '$parcel'},
               #ref{name = vcard_DOM, default = false,
                    min = 0, max = 1, label = '$dom'},
               #ref{name = vcard_INTL, default = false,
                    min = 0, max = 1, label = '$intl'},
               #ref{name = vcard_PREF, default = false,
                    min = 0, max = 1, label = '$pref'},
               #ref{name = vcard_LINE, label = '$line'}]}}.

{vcard_TEL,
 #elem{name = <<"TEL">>,
       xmlns = <<"vcard-temp">>,
       result = {vcard_tel, '$home', '$work', '$voice', '$fax',
                 '$pager', '$msg', '$cell', '$video', '$bbs',
                 '$modem', '$isdn', '$pcs', '$pref', '$number'},
       refs = [#ref{name = vcard_HOME, default = false,
                    min = 0, max = 1, label = '$home'},
               #ref{name = vcard_WORK, default = false,
                    min = 0, max = 1, label = '$work'},
               #ref{name = vcard_VOICE, default = false,
                    min = 0, max = 1, label = '$voice'},
               #ref{name = vcard_FAX, default = false,
                    min = 0, max = 1, label = '$fax'},
               #ref{name = vcard_PAGER, default = false,
                    min = 0, max = 1, label = '$pager'},
               #ref{name = vcard_MSG, default = false,
                    min = 0, max = 1, label = '$msg'},
               #ref{name = vcard_CELL, default = false,
                    min = 0, max = 1, label = '$cell'},
               #ref{name = vcard_VIDEO, default = false,
                    min = 0, max = 1, label = '$video'},
               #ref{name = vcard_BBS, default = false,
                    min = 0, max = 1, label = '$bbs'},
               #ref{name = vcard_MODEM, default = false,
                    min = 0, max = 1, label = '$modem'},
               #ref{name = vcard_ISDN, default = false,
                    min = 0, max = 1, label = '$isdn'},
               #ref{name = vcard_PCS, default = false,
                    min = 0, max = 1, label = '$pcs'},
               #ref{name = vcard_PREF, default = false,
                    min = 0, max = 1, label = '$pref'},
               #ref{name = vcard_NUMBER,
                    min = 0, max = 1, label = '$number'}]}}.

{vcard_EMAIL,
 #elem{name = <<"EMAIL">>,
       xmlns = <<"vcard-temp">>,
       result = {vcard_email, '$home', '$work',
                '$internet', '$pref', '$x400', '$userid'},
       refs = [#ref{name = vcard_HOME, default = false,
                    min = 0, max = 1, label = '$home'},
               #ref{name = vcard_WORK, default = false,
                    min = 0, max = 1, label = '$work'},
               #ref{name = vcard_INTERNET, default = false,
                    min = 0, max = 1, label = '$internet'},
               #ref{name = vcard_PREF, default = false,
                    min = 0, max = 1, label = '$pref'},
               #ref{name = vcard_X400, default = false,
                    min = 0, max = 1, label = '$x400'},
               #ref{name = vcard_USERID,
                    min = 0, max = 1, label = '$userid'}]}}.

{vcard_GEO,
 #elem{name = <<"GEO">>,
       xmlns = <<"vcard-temp">>,
       result = {vcard_geo, '$lat', '$lon'},
       refs = [#ref{name = vcard_LAT, min = 0, max = 1, label = '$lat'},
               #ref{name = vcard_LON, min = 0, max = 1, label = '$lon'}]}}.

{vcard_BINVAL,
 #elem{name = <<"BINVAL">>,
       xmlns = <<"vcard-temp">>,
       cdata = #cdata{dec = {base64, decode, []},
                      enc = {base64, encode, []}},
       result = '$cdata'}}.

{vcard_LOGO,
 #elem{name = <<"LOGO">>,
       xmlns = <<"vcard-temp">>,
       result = {vcard_logo, '$type', '$binval', '$extval'},
       refs = [#ref{name = vcard_TYPE, min = 0, max = 1, label = '$type'},
               #ref{name = vcard_BINVAL, min = 0, max = 1, label = '$binval'},
               #ref{name = vcard_EXTVAL, min = 0, max = 1, label = '$extval'}]}}.

{vcard_PHOTO,
 #elem{name = <<"PHOTO">>,
       xmlns = <<"vcard-temp">>,
       result = {vcard_photo, '$type', '$binval', '$extval'},
       refs = [#ref{name = vcard_TYPE, min = 0, max = 1, label = '$type'},
               #ref{name = vcard_BINVAL, min = 0, max = 1, label = '$binval'},
               #ref{name = vcard_EXTVAL, min = 0, max = 1, label = '$extval'}]}}.

{vcard_ORG,
 #elem{name = <<"ORG">>,
       xmlns = <<"vcard-temp">>,
       result = {vcard_org, '$name', '$units'},
       refs = [#ref{name = vcard_ORGNAME,
                    label = '$name',
                    min = 0, max = 1},
               #ref{name = vcard_ORGUNIT,
                    label = '$units'}]}}.

{vcard_SOUND,
 #elem{name = <<"SOUND">>,
       xmlns = <<"vcard-temp">>,
       result = {vcard_sound, '$phonetic', '$binval', '$extval'},
       refs = [#ref{name = vcard_BINVAL, min = 0, max = 1, label = '$binval'},
               #ref{name = vcard_EXTVAL, min = 0, max = 1, label = '$extval'},
               #ref{name = vcard_PHONETIC, min = 0, max = 1, label = '$phonetic'}]}}.

{vcard_KEY,
 #elem{name = <<"KEY">>,
       xmlns = <<"vcard-temp">>,
       result = {vcard_key, '$type', '$cred'},
       refs = [#ref{name = vcard_TYPE, min = 0, max = 1, label = '$type'},
               #ref{name = vcard_CRED, min = 0, max = 1, label = '$cred'}]}}.

{vcard_CATEGORIES,
 #elem{name = <<"CATEGORIES">>,
       xmlns = <<"vcard-temp">>,
       result = '$keywords',
       refs = [#ref{name = vcard_KEYWORD, label = '$keywords'}]}}.

{vcard_CLASS,
 #elem{name = <<"CLASS">>,
       xmlns = <<"vcard-temp">>,
       result = '$class',
       refs = [#ref{name = vcard_PUBLIC, min = 0, max = 1, label = '$class'},
               #ref{name = vcard_PRIVATE, min = 0, max = 1, label = '$class'},
               #ref{name = vcard_CONFIDENTIAL, min = 0, max = 1, label = '$class'}]}}.

%% {vcard_AGENT,
%%  #elem{name = <<"AGENT">>,
%%        xmlns = <<"vcard-temp">>,
%%        result = {vcard_agent, '$vcard', '$extval'},
%%        refs = [#ref{name = vcard, min = 0, max = 1, label = '$vcard'},
%%                #ref{name = vcard_EXTVAL, min = 0, max = 1, label = '$extval'}]}}.

{vcard,
 #elem{name = <<"vCard">>,
       xmlns = <<"vcard-temp">>,
       result = {vcard, '$version', '$fn', '$n', '$nickname', '$photo',
                 '$bday', '$adr', '$label', '$tel', '$email', '$jabberid',
                 '$mailer', '$tz', '$geo', '$title', '$role', '$logo',
                 '$org', '$categories', '$note', '$prodid', %% '$agent',
                 '$rev', '$sort_string', '$sound', '$uid', '$url', '$class',
                 '$key', '$desc'},
       refs = [#ref{name = vcard_N, min = 0, max = 1, label = '$n'},
               #ref{name = vcard_ADR, label = '$adr'},
               #ref{name = vcard_LABEL, label = '$label'},
               #ref{name = vcard_TEL, label = '$tel'},
               #ref{name = vcard_EMAIL, label = '$email'},
               #ref{name = vcard_GEO, min = 0, max = 1, label = '$geo'},
               #ref{name = vcard_LOGO, min = 0, max = 1, label = '$logo'},
               #ref{name = vcard_PHOTO, min = 0, max = 1, label = '$photo'},
               #ref{name = vcard_ORG, min = 0, max = 1, label = '$org'},
               #ref{name = vcard_SOUND, min = 0, max = 1, label = '$sound'},
               #ref{name = vcard_KEY, min = 0, max = 1, label = '$key'},
               #ref{name = vcard_VERSION, min = 0, max = 1, label = '$version'},
               #ref{name = vcard_FN, min = 0, max = 1, label = '$fn'},
               #ref{name = vcard_NICKNAME, min = 0, max = 1, label = '$nickname'},
               #ref{name = vcard_BDAY, min = 0, max = 1, label = '$bday'},
               #ref{name = vcard_JABBERID, min = 0, max = 1, label = '$jabberid'},
               #ref{name = vcard_MAILER, min = 0, max = 1, label = '$mailer'},
               #ref{name = vcard_TZ, min = 0, max = 1, label = '$tz'},
               #ref{name = vcard_TITLE, min = 0, max = 1, label = '$title'},
               #ref{name = vcard_ROLE, min = 0, max = 1, label = '$role'},
               #ref{name = vcard_NOTE, min = 0, max = 1, label = '$note'},
               #ref{name = vcard_PRODID, min = 0, max = 1, label = '$prodid'},
               #ref{name = vcard_REV, min = 0, max = 1, label = '$rev'},
               %%#ref{name = vcard_AGENT, min = 0, max = 1, label = '$agent'},
               #ref{name = vcard_SORT_STRING, min = 0, max = 1,
                    label = '$sort_string'},
               #ref{name = vcard_UID, min = 0, max = 1, label = '$uid'},
               #ref{name = vcard_URL, min = 0, max = 1, label = '$url'},
               #ref{name = vcard_DESC, min = 0, max = 1, label = '$desc'},
               #ref{name = vcard_CATEGORIES, default = [], min = 0, max = 1,
                    label = '$categories'},
               #ref{name = vcard_CLASS, min = 0, max = 1, label = '$class'}]}}.

{xdata_field_required,
 #elem{name = <<"required">>,
       xmlns = <<"jabber:x:data">>,
       result = true}}.

{xdata_field_desc,
 #elem{name = <<"desc">>, xmlns = <<"jabber:x:data">>, result = '$cdata'}}.

{xdata_field_value,
 #elem{name = <<"value">>, xmlns = <<"jabber:x:data">>, result = '$cdata'}}.

{xdata_field_option,
 #elem{name = <<"option">>,
       xmlns = <<"jabber:x:data">>,
       result = '$value',
       refs = [#ref{name = xdata_field_value,
                    label = '$value',
                    min = 1, max = 1}]}}.

{xdata_field,
 #elem{name = <<"field">>,
       xmlns = <<"jabber:x:data">>,
       result = {xdata_field, '$label', '$type', '$var',
                 '$required', '$desc', '$values', '$options'},
       attrs = [#attr{name = <<"label">>},
                #attr{name = <<"type">>,
                      enc = {enc_enum, []},
                      dec = {dec_enum, [['boolean',
                                         'fixed',
                                         'hidden',
                                         'jid-multi',
                                         'jid-single',
                                         'list-multi',
                                         'list-single',
                                         'text-multi',
                                         'text-private',
                                         'text-single']]}},
                #attr{name = <<"var">>}],
       refs = [#ref{name = xdata_field_required,
                    label = '$required',
                    default = false,
                    min = 0, max = 1},
               #ref{name = xdata_field_desc,
                    label = '$desc',
                    min = 0, max = 1},
               #ref{name = xdata_field_value,
                    label = '$values'},
               #ref{name = xdata_field_option,
                    label = '$options'}]}}.

{xdata_instructions,  #elem{name = <<"instructions">>,
                            xmlns = <<"jabber:x:data">>,
                            result = '$cdata'}}.
{xdata_title, #elem{name = <<"title">>,
                    xmlns = <<"jabber:x:data">>,
                    result = '$cdata'}}.
{xdata_reported, #elem{name = <<"reported">>,
                       xmlns = <<"jabber:x:data">>,
                       result = '$fields',
                       refs = [#ref{name = xdata_field,
                                    label = '$fields'}]}}.
{xdata_item,  #elem{name = <<"item">>,
                    xmlns = <<"jabber:x:data">>,
                    result = '$fields',
                    refs = [#ref{name = xdata_field,
                                 label = '$fields'}]}}.

{xdata,
 #elem{name = <<"x">>,
       xmlns = <<"jabber:x:data">>,
       result = {xdata, '$type', '$instructions', '$title',
                 '$reported', '$items', '$fields'},
       attrs = [#attr{name = <<"type">>,
                      required = true,
                      dec = {dec_enum, [[cancel, form, result, submit]]},
                      enc = {enc_enum, []}}],
       refs = [#ref{name = xdata_instructions,
                    label = '$instructions'},
               #ref{name = xdata_title,
                    label = '$title',
                    min = 0, max = 1},
               #ref{name = xdata_reported,
                    label = '$reported',
                    min = 0, max = 1},
               #ref{name = xdata_item,
                    label = '$items'},
               #ref{name = xdata_field,
                    label = '$fields'}]}}.

{pubsub_subscription,
 #elem{name = <<"subscription">>,
       xmlns = <<"http://jabber.org/protocol/pubsub">>,
       result = {pubsub_subscription, '$jid', '$node', '$subid',
                 '$type'},
       attrs = [#attr{name = <<"jid">>,
                      required = true,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}},
                #attr{name = <<"node">>},
                #attr{name = <<"subid">>},
                #attr{name = <<"subscription">>,
                      label = '$type',
                      dec = {dec_enum, [[none, pending, subscribed,
                                         unconfigured]]},
                      enc = {enc_enum, []}}]}}.

{pubsub_affiliation,
 #elem{name = <<"affiliation">>,
       xmlns = <<"http://jabber.org/protocol/pubsub">>,
       result = {pubsub_affiliation, '$node', '$type'},
       attrs = [#attr{name = <<"node">>,
                      required = true},
                #attr{name = <<"affiliation">>,
                      label = '$type',
                      required = true,
                      dec = {dec_enum, [[member, none, outcast, owner,
                                         publisher, 'publish-only']]},
                      enc = {enc_enum, []}}]}}.

{pubsub_item,
 #elem{name = <<"item">>,
       xmlns = <<"http://jabber.org/protocol/pubsub">>,
       result = {pubsub_item, '$id', '$_els'},
       attrs = [#attr{name = <<"id">>}]}}.

{pubsub_items,
 #elem{name = <<"items">>,
       xmlns = <<"http://jabber.org/protocol/pubsub">>,
       result = {pubsub_items, '$node', '$max_items',
                 '$subid', '$items'},
       attrs = [#attr{name = <<"max_items">>,
                      dec = {dec_int, [0, infinity]},
                      enc = {enc_int, []}},
                #attr{name = <<"node">>,
                      required = true},
                #attr{name = <<"subid">>}],
       refs = [#ref{name = pubsub_item, label = '$items'}]}}.

{pubsub_event_retract,
 #elem{name = <<"retract">>,
       xmlns = <<"http://jabber.org/protocol/pubsub#event">>,
       result = '$id',
       attrs = [#attr{name = <<"id">>, required = true}]}}.

{pubsub_event_item,
 #elem{name = <<"item">>,
       xmlns = <<"http://jabber.org/protocol/pubsub#event">>,
       result = {pubsub_event_item, '$id', '$node', '$publisher'},
       attrs = [#attr{name = <<"id">>},
                #attr{name = <<"node">>},
                #attr{name = <<"publisher">>}]}}.

{pubsub_event_items,
 #elem{name = <<"items">>,
       xmlns = <<"http://jabber.org/protocol/pubsub#event">>,
       result = {pubsub_event_items, '$node', '$retract', '$items'},
       attrs = [#attr{name = <<"node">>,
                      required = true}],
       refs = [#ref{name = pubsub_event_retract, label = '$retract'},
               #ref{name = pubsub_event_item, label = '$items'}]}}.

{pubsub_event,
 #elem{name = <<"event">>,
       xmlns = <<"http://jabber.org/protocol/pubsub#event">>,
       result = {pubsub_event, '$items'},
       refs = [#ref{name = pubsub_event_items, label = '$items'}]}}.

{pubsub_subscriptions,
 #elem{name = <<"subscriptions">>,
       xmlns = <<"http://jabber.org/protocol/pubsub">>,
       result = {'$node', '$subscriptions'},
       attrs = [#attr{name = <<"node">>,
                      default = none}],
       refs = [#ref{name = pubsub_subscription, label = '$subscriptions'}]}}.

{pubsub_affiliations,
 #elem{name = <<"affiliations">>,
       xmlns = <<"http://jabber.org/protocol/pubsub">>,
       result = '$affiliations',
       refs = [#ref{name = pubsub_affiliation, label = '$affiliations'}]}}.

{pubsub_subscribe,
 #elem{name = <<"subscribe">>,
       xmlns = <<"http://jabber.org/protocol/pubsub">>,
       result = {pubsub_subscribe, '$node', '$jid'},
       attrs = [#attr{name = <<"node">>},
                #attr{name = <<"jid">>,
                      required = true,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}}]}}.

{pubsub_unsubscribe,
 #elem{name = <<"unsubscribe">>,
       xmlns = <<"http://jabber.org/protocol/pubsub">>,
       result = {pubsub_unsubscribe, '$node', '$jid', '$subid'},
       attrs = [#attr{name = <<"node">>},
                #attr{name = <<"subid">>},
                #attr{name = <<"jid">>,
                      required = true,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}}]}}.

{pubsub_publish,
 #elem{name = <<"publish">>,
       xmlns = <<"http://jabber.org/protocol/pubsub">>,
       result = {pubsub_publish, '$node', '$items'},
       attrs = [#attr{name = <<"node">>,
                      required = true}],
       refs = [#ref{name = pubsub_item, label = '$items'}]}}.

{pubsub_options,
 #elem{name = <<"options">>,
       xmlns = <<"http://jabber.org/protocol/pubsub">>,
       result = {pubsub_options, '$node', '$jid', '$subid', '$xdata'},
       attrs = [#attr{name = <<"node">>},
                #attr{name = <<"subid">>},
                #attr{name = <<"jid">>,
                      required = true,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}}],
       refs = [#ref{name = xdata, min = 0, max = 1,
                    label = '$xdata'}]}}.

{pubsub_retract,
 #elem{name = <<"retract">>,
       xmlns = <<"http://jabber.org/protocol/pubsub">>,
       result = {pubsub_retract, '$node', '$notify', '$items'},
       attrs = [#attr{name = <<"node">>,
                      required = true},
                #attr{name = <<"notify">>,
                      default = false,
                      dec = {dec_bool, []},
                      enc = {enc_bool, []}}],
       refs = [#ref{name = pubsub_item, label = '$items'}]}}.

{pubsub,
 #elem{name = <<"pubsub">>,
       xmlns = <<"http://jabber.org/protocol/pubsub">>,
       result = {pubsub, '$subscriptions', '$affiliations', '$publish',
                 '$subscribe', '$unsubscribe', '$options', '$items',
                 '$retract'},
       refs = [#ref{name = pubsub_subscriptions, label = '$subscriptions',
                    min = 0, max = 1},
               #ref{name = pubsub_affiliations, label = '$affiliations',
                    min = 0, max = 1},
               #ref{name = pubsub_subscribe, label = '$subscribe',
                    min = 0, max = 1},
               #ref{name = pubsub_unsubscribe, label = '$unsubscribe',
                    min = 0, max = 1},
               #ref{name = pubsub_options, label = '$options',
                    min = 0, max = 1},
               #ref{name = pubsub_items, label = '$items',
                    min = 0, max = 1},
               #ref{name = pubsub_retract, label = '$retract',
                    min = 0, max = 1},
               #ref{name = pubsub_publish, label = '$publish',
                    min = 0, max = 1}]}}.

{shim_header,
 #elem{name = <<"header">>,
       xmlns = <<"http://jabber.org/protocol/shim">>,
       result = {'$name', '$cdata'},
       attrs = [#attr{name = <<"name">>,
                      required = true}]}}.
       
{shim_headers,
 #elem{name = <<"headers">>,
       xmlns = <<"http://jabber.org/protocol/shim">>,
       result = {shim, '$headers'},
       refs = [#ref{name = shim_header, label = '$headers'}]}}.

{delay,
 #elem{name = <<"delay">>,
       xmlns = <<"urn:xmpp:delay">>,
       result = {delay, '$stamp', '$from'},
       attrs = [#attr{name = <<"stamp">>,
                      required = true,
                      dec = {dec_utc, []},
                      enc = {enc_utc, []}},
                #attr{name = <<"from">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}}]}}.

{legacy_delay,
 #elem{name = <<"x">>,
       xmlns = <<"jabber:x:delay">>,
       result = {legacy_delay, '$stamp', '$from'},
       attrs = [#attr{name = <<"stamp">>,
                      required = true},
                #attr{name = <<"from">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}}]}}.

{bytestreams_streamhost,
 #elem{name = <<"streamhost">>,
       xmlns = <<"http://jabber.org/protocol/bytestreams">>,
       result = {streamhost, '$jid', '$host', '$port'},
       attrs = [#attr{name = <<"jid">>,
                      required = true,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}},
                #attr{name = <<"host">>,
                      required = true},
                #attr{name = <<"port">>,
                      default = 1080,
                      dec = {dec_int, [0, 65535]},
                      enc = {enc_int, []}}]}}.

{bytestreams_streamhost_used,
 #elem{name = <<"streamhost-used">>,
       xmlns = <<"http://jabber.org/protocol/bytestreams">>,
       result = '$jid',
       attrs = [#attr{name = <<"jid">>,
                      required = true,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}}]}}.

{bytestreams_activate,
 #elem{name = <<"activate">>,
       xmlns = <<"http://jabber.org/protocol/bytestreams">>,
       cdata = #cdata{enc = {enc_jid, []}, dec = {dec_jid, []}},
       result = '$cdata'}}.

{bytestreams,
 #elem{name = <<"query">>,
       xmlns = <<"http://jabber.org/protocol/bytestreams">>,
       result = {bytestreams, '$hosts', '$used', '$activate',
                 '$dstaddr', '$mode', '$sid'},
       attrs = [#attr{name = <<"dstaddr">>},
                #attr{name = <<"sid">>},
                #attr{name = <<"mode">>,
                      default = tcp,
                      dec = {dec_enum, [[tcp, udp]]},
                      enc = {enc_enum, []}}],
       refs = [#ref{name = bytestreams_streamhost, label = '$hosts'},
               #ref{name = bytestreams_streamhost_used,
                    min = 0, max = 1, label = '$used'},
               #ref{name = bytestreams_activate,
                    min = 0, max = 1, label = '$activate'}]}}.

{muc_history,
 #elem{name = <<"history">>,
       xmlns = <<"http://jabber.org/protocol/muc">>,
       result = {muc_history, '$maxchars', '$maxstanzas',
                 '$seconds', '$since'},
       attrs = [#attr{name = <<"maxchars">>,
                      dec = {dec_int, [0, infinity]},
                      enc = {enc_int, []}},
                #attr{name = <<"maxstanzas">>,
                      dec = {dec_int, [0, infinity]},
                      enc = {enc_int, []}},
                #attr{name = <<"seconds">>,
                      dec = {dec_int, [0, infinity]},
                      enc = {enc_int, []}},
                #attr{name = <<"since">>,
                      dec = {dec_utc, []},
                      enc = {enc_utc, []}}]}}.

{muc_user_reason,
 #elem{name = <<"reason">>,
       xmlns = <<"http://jabber.org/protocol/muc#user">>,
       result = '$cdata'}}.

{muc_user_decline,
 #elem{name = <<"decline">>,
       xmlns = <<"http://jabber.org/protocol/muc#user">>,
       result = {muc_decline, '$reason', '$from', '$to'},
       attrs = [#attr{name = <<"to">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}},
                #attr{name = <<"from">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}}],
       refs = [#ref{name = muc_user_reason, min = 0,
                    max = 1, label = '$reason'}]}}.

{muc_user_destroy,
 #elem{name = <<"destroy">>,
       xmlns = <<"http://jabber.org/protocol/muc#user">>,
       result = {muc_user_destroy, '$reason', '$jid'},
       attrs = [#attr{name = <<"jid">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}}],
       refs = [#ref{name = muc_user_reason, min = 0,
                    max = 1, label = '$reason'}]}}.

{muc_user_invite,
 #elem{name = <<"invite">>,
       xmlns = <<"http://jabber.org/protocol/muc#user">>,
       result = {muc_invite, '$reason', '$from', '$to'},
       attrs = [#attr{name = <<"to">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}},
                #attr{name = <<"from">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}}],
       refs = [#ref{name = muc_user_reason, min = 0,
                    max = 1, label = '$reason'}]}}.

{muc_user_actor,
 #elem{name = <<"actor">>,
       xmlns = <<"http://jabber.org/protocol/muc#user">>,
       result = {muc_actor, '$jid', '$nick'},
       attrs = [#attr{name = <<"jid">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}},
                #attr{name = <<"nick">>}]}}.

{muc_user_continue,
 #elem{name = <<"continue">>,
       xmlns = <<"http://jabber.org/protocol/muc#user">>,
       result = '$thread',
       attrs = [#attr{name = <<"thread">>}]}}.

{muc_user_status,
 #elem{name = <<"status">>,
       xmlns = <<"http://jabber.org/protocol/muc#user">>,
       result = '$code',
       attrs = [#attr{name = <<"code">>,
                      dec = {dec_int, [100, 999]},
                      enc = {enc_int, []}}]}}.

{muc_user_item,
 #elem{name = <<"item">>,
       xmlns = <<"http://jabber.org/protocol/muc#user">>,
       result = {muc_item, '$actor', '$continue', '$reason',
                 '$affiliation', '$role', '$jid', '$nick'},
       refs = [#ref{name = muc_user_actor,
                    min = 0, max = 1, label = '$actor'},
               #ref{name = muc_user_continue,
                    min = 0, max = 1, label = '$continue'},
               #ref{name = muc_user_reason,
                    min = 0, max = 1, label = '$reason'}],
       attrs = [#attr{name = <<"affiliation">>,
                      dec = {dec_enum, [[admin, member, none,
                                         outcast, owner]]},
                      enc = {enc_enum, []}},
                #attr{name = <<"role">>,
                      dec = {dec_enum, [[moderator, none,
                                         participant, visitor]]},
                      enc = {enc_enum, []}},
                #attr{name = <<"jid">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}},
                #attr{name = <<"nick">>}]}}.

{muc_user,
 #elem{name = <<"x">>,
       xmlns = <<"http://jabber.org/protocol/muc#user">>,
       result = {muc_user, '$decline', '$destroy', '$invites',
                 '$items', '$status_codes', '$password'},
       attrs = [#attr{name = <<"password">>}],
       refs = [#ref{name = muc_user_decline, min = 0,
                    max = 1, label = '$decline'},
               #ref{name = muc_user_destroy, min = 0, max = 1,
                    label = '$destroy'},
               #ref{name = muc_user_invite, label = '$invites'},
               #ref{name = muc_user_item, label = '$items'},
               #ref{name = muc_user_status, label = '$status_codes'}]}}.

{muc_owner_password,
 #elem{name = <<"password">>,
       xmlns = <<"http://jabber.org/protocol/muc#owner">>,
       result = '$cdata'}}.

{muc_owner_reason,
 #elem{name = <<"reason">>,
       xmlns = <<"http://jabber.org/protocol/muc#owner">>,
       result = '$cdata'}}.

{muc_owner_destroy,
 #elem{name = <<"destroy">>,
       xmlns = <<"http://jabber.org/protocol/muc#owner">>,
       result = {muc_owner_destroy, '$jid', '$reason', '$password'},
       attrs = [#attr{name = <<"jid">>,
                      dec = {dec_jid, []},
                      enc = {enc_jid, []}}],
       refs = [#ref{name = muc_owner_password, min = 0, max = 1,
                    label = '$password'},
               #ref{name = muc_owner_reason, min = 0, max = 1,
                    label = '$reason'}]}}.

{muc_owner,
 #elem{name = <<"query">>,
       xmlns = <<"http://jabber.org/protocol/muc#owner">>,
       result = {muc_owner, '$destroy', '$config'},
       refs = [#ref{name = muc_owner_destroy, min = 0, max = 1,
                    label = '$destroy'},
               #ref{name = xdata, min = 0, max = 1, label = '$config'}]}}.

{muc,
 #elem{name = <<"x">>,
       xmlns = <<"http://jabber.org/protocol/muc">>,
       result = {muc, '$history', '$password'},
       attrs = [#attr{name = <<"password">>}],
       refs = [#ref{name = muc_history, min = 0, max = 1,
                    label = '$history'}]}}.

dec_tzo(Val) ->
    [H1, M1] = str:tokens(Val, <<":">>),
    H = erlang:binary_to_integer(H1),
    M = erlang:binary_to_integer(M1),
    if H >= -12, H =< 12, M >= 0, M < 60  ->
            {H, M}
    end.

enc_tzo({H, M}) ->
    Sign = if H >= 0 ->
                   <<>>;
              true ->
                   <<"-">>
           end,
    list_to_binary([Sign, io_lib:format("~2..0w:~2..0w", [H, M])]).

dec_utc(Val) ->
    {_, _, _} = jlib:datetime_string_to_timestamp(Val).

enc_utc(Val) ->
    jlib:now_to_utc_string(Val).

dec_jid(Val) ->
    case jlib:string_to_jid(Val) of
        error ->
            erlang:error(badarg);
        J ->
            J
    end.

enc_jid(J) ->            
    jlib:jid_to_string(J).

resourceprep(R) ->
    case jlib:resourceprep(R) of
        error ->
            erlang:error(badarg);
        R1 ->
            R1
    end.

dec_bool(<<"false">>) -> false;
dec_bool(<<"true">>) -> true.

enc_bool(false) -> <<"false">>;
enc_bool(true) -> <<"true">>.

%% Local Variables:
%% mode: erlang
%% End:
%% vim: set filetype=erlang tabstop=8: