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 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624
|
<html>
<head>
<title>Using DocBook Lite</title>
<style>
body {
background-color: wheat;
font-family: sans-serif;
}
.section {
margin: 0.5em;
padding: 0.5em;
background-color: wheat;
}
.contents {
margin: 0.5em;
padding: 0.5em;
background-color: silver;
}
</style>
</head>
<body>
<h1 class="doctitle">Using DocBook Lite</h1>
<div class="contents">
<h2 class="ctitle">Contents</h2>
<a href="#section-1">1. Introduction</a>
<br>
<a href="#section-2">2. XML</a>
<br>
<a href="#section-3">3. For best results...</a>
<br>
<a href="#section-4">4. The Physical Structure of a Book</a>
<br>
<a href="#section-5">5. The Logical Structure of a Book</a>
<br>
<a href="#section-6">6. Block elements</a>
<br>
<a href="#section-7">7. Inline elements</a>
<br>
<a href="#section-8">8. Tables</a>
<br>
<a href="#section-9">9. Indexterms</a>
<br>
<a href="#section-10">10. Out-of-flow Text</a>
<br>
<a href="#section-11">11. Reference Pages</a>
<br>
<a href="#section-12">12. See Also...</a>
<br>
</div>
<a name="section-1"></a>
<div class="section">
<h2 class="stitle">1. Introduction</h2>
<p>
This document describes the use of DocBook Lite, a document type
definition (DTD) that defines and shapes the markup of O'Reilly
books. The DTD declares a set of elements (containers of content) and
entities (stand-ins for content). Its notation restricts the kinds of
elements and data that each element can hold. For example, a
<tt><chapter></tt> can contain a
<tt><para></tt> (paragraph), but cannot contain a
<tt><book></tt>.
</p>
<p>
DocBook Lite is an application of the XML markup language rules. XML
doesn't require that you use a DTD, but we find that enforcing
structure is vital to our ability to produce and repurpose books
efficiently. Originally, we used the full DocBook application
maintained by <a href="http://www.oasis-open.org/">the OASIS
SGML/XML standards group</a>, but have since refined it to a small
subset with its own DTD. It has a few additions for some types of
books, but mostly the markup should be compatible with the full
DocBook.
</p>
</div>
<a name="section-2"></a>
<div class="section">
<h2 class="stitle">2. XML</h2>
<p>
The eXtensible Markup Language (XML) is a
specification for how markup should work in a document. Using codes
embedded in text, it defines structure and properties for the parts of
a document. The basic philosophy of XML is that every unique part of a
document should be clearly labelled and its position should be
unambiguous. If a document satisfies the minimal rules of XML, it is
said to be well-formed. A document that is not
well-formed has syntax or other kinds of errors that need to be fixed
before the document can be processed.
</p>
<p>
The rules for a well-formed XML document differ from those of
HTML pages. HTML is less strict with syntax, and most browser will not
complain about poor style or errors. However, XML is much less
forgiving, so be warned.
</p>
<p>
DocBook Lite adds another level of control to the document. It
restricts the kinds of elements and structures that make up a
book. Specially tailored to O'Reilly's style, the DTD ensures that the
book has maximum quality and information value by the time it reaches
production. A document that conforms to our DTD is described as
valid. A document that is not valid has
incorrect markup that needs to be fixed before it can be accurately
processed by our tools.
</p>
<p>
To test the validity of a document, you need to use a program called a
validator. Sometimes this is built-in to the
text editor you're using. For example, Arbortext's Adept editor has a
validation option. Other editors may not include a validating parser
because it's assumed that any document you open is already valid, and
you won't make any mistakes because the editor won't let you (it
constrains your actions). There are also stand-alone validators that
read a document and list errors for you. We use nsgmls to validate
books.
</p>
<p>
<tt>nsgmls</tt> is written and maintained by James Clark
and is available for free from <a href="http://www.jclark.com/sp/nsgmls.htm">his web page</a>.
</p>
</div>
<a name="section-3"></a>
<div class="section">
<h2 class="stitle">3. For best results...</h2>
<p>
Just because you're using XML doesn't mean the document is marked up
as well as it can be. Even a valid document can have mistakes and
problems that lower the quality of the book and slow down
production. For example, you may use the wrong element name, which
will pass the DTD test but not make sense to a human. The following
code fragment shows the correct markup for a term-definition
list:
</p>
<div class="programlisting">
<pre><variablelist>
<varlistentry>
<term>monkey</term>
<listitem><para>A cute, furry mammal that climbs in trees.</para></listitem>
</varlistentry>
<varlistentry>
<term>koala</term>
<listitem><para>A cute, furry mammal that climbs in trees.</para></listitem>
</varlistentry>
</variablelist></pre>
</div>
<p>
Sometimes, people choose to do this with another kind of list:
</p>
<div class="programlisting">
<pre><itemizedlist>
<listitem><para>Monkey - A cute, furry mammal that climbs in trees.</para></listitem>
<listitem><para>Koala - A cute, furry mammal that climbs in trees.</para></listitem>
</itemizedlist></pre>
</div>
<p>
It's easier to type it the second way, but then you lose some
information, like the fact that it's supposed to be a mapping of terms
to definitions. Although you may think you're saving time with this
shortcut, it will add delays later when production staff have to
transform the list into its proper markup.
</p>
<p>
Another common mistake authors make is to assume that
presentational markup is just as good as
semantic markup. In other words, saying how
something looks is as good as saying what it is. This is contrary to
the philosophy of XML, and also will cause problems for your book
later on. For example, consider the inline markup for a Web address,
or URL. In print, a URL appears in italic like this:
</p>
<p>
For more information, you <em>really</em> ought to
check out the W3C's website at
<em>http://www.w3.org/</em>.
</p>
<p>
The correct way to mark up this passage is like this:
</p>
<div class="programlisting">
<pre><para>For more information, you <emphasis>really</emphasis>
ought to check out the W3C's website at <systemitem
class="url">http://www.w3.org/</systemitem>.</para></pre>
</div>
<p>
This is called semantic markup because the
"really" and the URL are labelled according to their meaning, not
their appearance. The next snippet shows the incorrect, presentational
markup:
</p>
<div class="programlisting">
<pre>For more information, you <emphasis>really</emphasis>
ought to check out the W3C's website at
<emphasis>http://www.w3.org/</emphasis>.</pre>
</div>
<p>
The author thought that because <tt><emphasis></tt>
causes its contents to be formatted in italic, it's okay to label
everything that comes out in italic as a
<tt><emphasis></tt>. So what? Well, it becomes a
problem when you want to <em>repurpose</em> the document
in HTML. Instead of the URL coming out as a hyperlink, it's merely
formatted in italic. When everything is marked up presentationally,
it's impossible to reuse the content in a different context.
</p>
</div>
<a name="section-4"></a>
<div class="section">
<h2 class="stitle">4. The Physical Structure of a Book</h2>
<p>
By physical structure, we mean the files and
directories used to contain the pieces of an XML document. An O'Reilly
book typically is stored in a single directory. Each chapter, preface,
and appendix exists in a separate file, and there is a
"master" file which contains the top (root) element for
the book. The following table lists the kinds of files and their name
conventions:
</p>
<table border="1">
<h4 class="exampletitle">Table 1. File naming conventions</h4>
<tr>
<th>element</th>
<th>filename</th>
<th>purpose</th>
</tr>
<tr>
<td><tt><book></tt></td>
<td>book.xml</td>
<td>
<p>
Contains the DOCTYPE declaration, declares local entities
in the internal subset, holds metadata, contains file reference
entities to chapters and other external elements.
</p>
</td>
</tr>
<tr>
<td><tt><copyrightpg></tt></td>
<td>copy.xml</td>
<td>
<p>
Contains the copyright page with legal info.
</p>
</td>
</tr>
<tr>
<td><tt><preface></tt></td>
<td>ch00.xml</td>
<td>
<p>
Contains the preface.
</p>
</td>
</tr>
<tr>
<td><tt><chapter></tt></td>
<td>
<p>
ch<i>xx</i>.xml, where
<i>xx</i> is the number of the chapter (e.g. 01,
04, 11)
</p>
</td>
<td>
<p>
Contains a chapter.
</p>
</td>
</tr>
<tr>
<td><tt><appendix></tt></td>
<td>
<p>
app<i>x</i>.xml, where
<i>x</i> is the letter of the appendix (e.g. a, b,
c)
</p>
</td>
<td>
<p>
Contains an appendix.
</p>
</td>
</tr>
<tr>
<td><tt><bibliography></tt></td>
<td>biblio.xml</td>
<td>
<p>
A chapter-level section containing bibliographic citations.
</p>
</td>
</tr>
<tr>
<td><tt><glossary></tt></td>
<td>gloss.xml</td>
<td>
<p>
A chapter-level section containing glossary definitions.
</p>
</td>
</tr>
<tr>
<td><tt><part></tt></td>
<td>
<p>
part<i>x</i>.xml, where
<i>x</i> is the number of the part (e.g. 1, 2,
3)
</p>
</td>
<td>
<p>
Contains a part (the first page only).
</p>
</td>
</tr>
<tr>
<td><tt><colophon></tt></td>
<td>colo.xml</td>
<td>
<p>
A section at the end of the book describing details of the
book's production.
</p>
</td>
</tr>
</table>
<p>
So a typical directory listing for a book would look something like
this:
</p>
<div class="screen">
<pre>$> ls /work/java/java.qref/xml
appa.xml ch01.xml ch06.xml part1.xml
appb.xml ch02.xml ch07.xml part2.xml
appc.xml ch03.xml ch08.xml
book.xml ch04.xml colo.xml
ch00.xml ch05.xml copy.xml</pre>
</div>
<p>
There is one master file for the book (<i>book.xml</i>);
three files for appendixes A, B, and C; one file for the preface;
eight files for chapters 1-8; two files for parts I and II; and a file
each for the copyright page and colophon. Note that the part files do
not contain the chapters, even though the
<tt><part></tt> elements logically contain
<tt><chapter></tt>s.
</p>
</div>
<a name="section-5"></a>
<div class="section">
<h2 class="stitle">5. The Logical Structure of a Book</h2>
<p>
Logical structure is defined by the book's
markup once the files have been assembled, which is how the parser
sees the document. The hierarchy of the book (chapters, sections,
sub-sections, etc.) is constructed using elements called
divisions. A division is a container that
usually has a <tt><title></tt> and contains other
divisions or block elements. We will look at top-level containers
(<tt><book></tt>, <tt><chapter></tt>,
<tt><preface></tt>,
<tt><appendix></tt>, and
<tt><part></tt>), and intermediate-level divisions
(<tt><sect1></tt>, <tt><sect2></tt>,
<tt><sect3></tt>, <tt><sect4></tt>,
<tt><simplesect></tt>, and
<tt><partinfo></tt>).
</p>
<a name="section-1.1"></a>
<div class="ssection">
<h3 class="sstitle">5.1. ID Attributes</h3>
<p>
To facilitate cross references, you should use IDs in major
hierarchical elements such as sections, chapters, and appendixes.
For example, a chapter might have an ID like this:
</p>
<div class="programlisting">
<pre><chapter id="intro-chapter"></pre>
</div>
<p>
Technically, the only requirement for an ID attribute is that it be
unique, since in XML no two elements can have the same ID attribute.
However, we ask that you use attribute names that are easy to read
and indicate the type of element and its subject. For example,
<tt>id="shapes-section"</tt> is better than
<tt>id="A6-4.2"</tt>.
</p>
<p>
When the book is in production, and the order of elements is
solidified, we will sometimes run a program that inserts ID attributes
where they were previously missing, or to replace those that make
sense only to the author. These generated IDs follow a pattern that
helps production staff trace links to their targets, even if the
target ID is missing or misspelled. The following table lists these
ID patterns:
</p>
<table border="1">
<h4 class="exampletitle">Table 1. Autogenerated ID Attributes</h4>
<tr>
<th>element</th>
<th>pattern</th>
<th>example</th>
</tr>
<tr>
<td>appendix</td>
<td><i>prefix</i>-APP-<i>letter</i></td>
<td>MONKEYS-APP-B</td>
</tr>
<tr>
<td>chapter</td>
<td><i>prefix</i>-CH-<i>num</i></td>
<td>MONKEYS-CH-3</td>
</tr>
<tr>
<td>preface</td>
<td><i>prefix</i>-PREF</td>
<td>MONKEYS-PREF</td>
</tr>
<tr>
<td>part</td>
<td><i>prefix</i>-PART-<i>num</i></td>
<td>MONKEYS-PART-2</td>
</tr>
<tr>
<td>sect1 (A-head or section)</td>
<td><i>prefix</i>-<i>CH/APP</i>-<i>num/letter</i>-SECT-<i>num</i></td>
<td>MONKEYS-CH-3-SECT-2</td>
</tr>
<tr>
<td>sect2 (B-head or sub section)</td>
<td><i>prefix</i>-<i>CH/APP</i>-<i>num/letter</i>-SECT-<i>num</i>.<i>num</i></td>
<td>MONKEYS-CH-3-SECT-2.4</td>
</tr>
<tr>
<td>figure</td>
<td><i>prefix</i>-<i>CH/APP</i>-<i>num/letter</i>-FIG-<i>num</i></td>
<td>MONKEYS-PREF-FIG-24</td>
</tr>
<tr>
<td>table</td>
<td><i>prefix</i>-<i>CH/APP</i>-<i>num/letter</i>-TABLE-<i>num</i></td>
<td>MONKEYS-APP-C-TABLE-11</td>
</tr>
<tr>
<td>example</td>
<td><i>prefix</i>-<i>CH/APP</i>-<i>num/letter</i>-EX-<i>num</i></td>
<td>MONKEYS-CH-12-EX-8</td>
</tr>
<tr>
<td>indexterm</td>
<td><i>prefix</i>-<i>terms</i></td>
<td>MONKEYS-perilous-furballs</td>
</tr>
</table>
<p>
The <i>prefix</i> is a short code you pick to
represent your book in <tt>id</tt>s. It's not required, but
we use it to eliminate any confusion when handling files separately,
since there is nothing within each file to indicate which book it came
from.
</p>
<p>
The number for any element type starts at 1. For elements inside
chapters or appendixes, the numbering is starts within the
chapter/appendix and continues to increment until the very end. An
exception is for sections, whose numbering resets to 1 with each
parent section or chapter.
</p>
</div>
<a name="section-1.2"></a>
<div class="ssection">
<h3 class="sstitle">5.2. The master book file</h3>
<p>
This file is the root of the whole book. Therefore, it contains the
important XML declaration at the top, as well as a directive to
declare the DTD. You would modify the second string value to the
actual location of the DTD on your system. Next are entity
declarations. These can only reside inside the square brackets. First
are the entities that point to the files in your book. Then follow any
special entities you want to define. The
<tt><bookinfo></tt> element will later be filled with
metadata, but for now it can be left empty. Finally, the entity
references for book files are listed in order at the bottom.
</p>
<div class="example">
<h4 class="exampletitle">Example 1. Contents of <i>book.xml</i>
</h4>
<div class="programlisting">
<pre><!DOCTYPE book PUBLIC
"-//ORA//DBLITE 1.1//EN" "/usr/local/prod/sgml/dblite/new.dtd"
[
<!-- Declare external entities -->
<!ENTITY ch00 SYSTEM "ch00.xml">
<!ENTITY ch01 SYSTEM "ch01.xml">
<!ENTITY ch02 SYSTEM "ch02.xml">
<!ENTITY ch03 SYSTEM "ch03.xml">
<!ENTITY ch04 SYSTEM "ch04.xml">
<!ENTITY ch05 SYSTEM "ch05.xml">
<!ENTITY ch06 SYSTEM "ch06.xml">
<!ENTITY ch07 SYSTEM "ch07.xml">
<!ENTITY ch08 SYSTEM "ch08.xml">
<!ENTITY ch09 SYSTEM "ch09.xml">
<!ENTITY part1 SYSTEM "part1.xml">
<!ENTITY part2 SYSTEM "part2.xml">
<!ENTITY appa SYSTEM "appa.xml">
<!ENTITY appb SYSTEM "appb.xml">
<!ENTITY appc SYSTEM "appc.xml">
<!ENTITY copy SYSTEM "copy.xml">
<!ENTITY colo SYSTEM "colo.xml">
<!-- Declare text entities -->
<!ENTITY ascii "<acronym>ASCII</acronym>">
<!ENTITY html "<acronym>HTML</acronym>">
<!ENTITY sgml "<acronym>SGML</acronym>">
<!ENTITY xml "<acronym>XML</acronym>">
<!ENTITY w3url "http://www.w3.org/">
]>
<book>
<title>Learning &xml;</title>
<bookinfo>
<!-- Marketing information and metadata,
to be filled out in production. -->
</bookinfo>
<!-- External entity refs -->
&ch00;
&copy;
&part1;
&part2;
&colo;
</book></pre>
</div>
</div>
<p>
In this example, none of the external entity references for chapters
and appendixes appear in <i>book.xml</i>. We will see
later that the chapters and appendixes are references only inside the
files for the parts in which they belong, to maintain the proper
hierarchy.
</p>
</div>
<a name="section-1.3"></a>
<div class="ssection">
<h3 class="sstitle">5.3. The preface</h3>
<p>
The preface is contained entirely within one file called
<i>ch00.xml</i>. It looks like this:
</p>
<div class="example">
<h4 class="exampletitle">Example 1. Contents of <i>ch00.xml</i>
</h4>
<div class="programlisting">
<pre><preface id="XML-PREF">
<title>Preface</title>
<!-- preamble (no A-head) -->
<simplesect>
<para>Welcome to &xml;. Put on your geek hat, twirl the
propeller, and get ready for a wacky ride!</para>
<para>Blah blah blah blah blah...</para>
</simplesect>
<!-- the first section (A-head) -->
<sect1 id="XML-PREF-SECT-1">
<title>Why &xml;?</title>
<para>&xml; is a markup language development kit. Blah blah
blah...</para>
<para>Blah blah blah blah blah...</para>
</sect1>
<!-- the second section -->
<sect1 id="XML-PREF-SECT-2">
<title>What's inside</title>
<para><xref linkend="XML-PART-1"/> starts off with an
introduction to some basic &xml; areas that any author ought to be
familiar with. Blah blah blah...</para>
</sect1>
<!-- Other sections... -->
</preface></pre>
</div>
</div>
</div>
<a name="section-1.4"></a>
<div class="ssection">
<h3 class="sstitle">5.4. Part Pages</h3>
<p>
A <tt><part></tt> is an element that contains chapters
or appendixes, dividing the book into major categories. At O'Reilly,
we separate chapters into different files by convention, so the part
is spread across several files. The front page of the part doesn't
belong in any particular chapter, so it gets its own file:
</p>
<div class="example">
<h4 class="exampletitle">Example 1. Contents of <i>part1.xml</i>
</h4>
<div class="programlisting">
<pre><part id="XML-PART-1">
<title>Basic Concepts</title>
<partintro>
<para>In this part of the book, we focus on easy material.
Blah blah blah...</para>
</partintro>
<!-- External entity references -->
&ch01;
&ch02;
&ch03;
&ch04;
</part></pre>
</div>
</div>
<p>
No entity declarations are necessary because they were made in the
<i>book.xml</i> file and carried over. The
<tt><partinfo></tt> is an intermediate-level division
that contains all elements between the
<tt><title></tt> and the chapter-level children of the
<tt><part></tt>.
</p>
</div>
<a name="section-1.5"></a>
<div class="ssection">
<h3 class="sstitle">5.5. The Chapter</h3>
<p>
Chapters follow the same basic pattern as a preface:
</p>
<div class="example">
<h4 class="exampletitle">Example 1. Contents of ch01.xml</h4>
<div class="programlisting">
<pre><chapter id="XML-CH-1">
<title>&xml; Basics</title>
<!-- preamble (no A-head) -->
<simplesect>
<para>In this chapter, we cover the
fundamentals of markup and document structure. Blah blah blah...</para>
<para>Blah blah blah blah blah...</para>
</simplesect>
<!-- the first section (A-head) -->
<sect1 id="XML-CH-1-SECT-1">
<title>What is Markup?</title>
<para>There's a lot of stuff you can
do with markup. Blah blah blah...</para>
<para>Blah blah blah blah blah...</para>
</sect1>
<!-- the second section -->
<sect1 id="XML-CH-1-SECT-2">
<title>A historical perspective</title>
<para>It's useful to see how &xml;
fits in the long line of markup languages. Blah blah blah...</para>
<!-- a sub-section -->
<sect2 id="XML-CH-1-SECT-2.1>
<title>The earliest days</title>
<para>Back in the olden days of
digital text, work was very hard. We had to flip knife switches
to program computers and &ascii;
was the only character set in town. Blah blah blah...</para>
<para>Blah blah blah blah blah...</para>
<!-- a sub-sub-section -->
<sect3 id="XML-CH-1-SECT-2.1.1>
<title>How I had to walk to work barefoot, uphill
both ways</title>
<para>Blah blah blah blah blah...</para>
<figure id="XML-CH-1-FIG-1">
<title>Picture of my blistered feet</title>
<graphic fileref="figs/soretoes.gif"/>
</figure>
</sect3>
</sect2>
</sect1>
<!-- Other sections... -->
</chapter></pre>
</div>
</div>
<p>
The hierarchy of sections is important. A
<tt><sect1></tt> contains
<tt><sect2></tt>s, which can contain
<tt><sect3></tt>s, etc. Also important: we now require
that elements after the chapter <tt><title></tt>, but
before the first <tt><sect1></tt>, be enclosed in a
<tt><simplesect></tt>.
</p>
<p>
Appendixes are pretty much the same as chapters, except that they are
contained in an <tt><appendix></tt> element instead of
a <tt><chapter></tt>, and the <tt>id</tt>
format is different.
</p>
</div>
<a name="section-1.6"></a>
<div class="ssection">
<h3 class="sstitle">5.6. Glossary</h3>
<p>
A glossary is a collection of definitions for terms used in the
book. A <tt><glossary></tt> element surrounds the
whole thing, and is usually at the same level as a chapter. Each
definition is contained in a <tt><glossentry></tt>
element with one <tt><glossentry></tt>,
containing the term being defined, and an optional (if there is a
see-also, for example) <tt><glossdef></tt>, containing
the definition. It can also contain any number of
<tt><glosssee></tt> and
<tt><glossseealso></tt> elements, which redirect the
reader's attention to another term. Stylistically, a
<tt><glossentry></tt> should not contain both a
<tt><glossdef></tt> and
<tt><glosssee></tt>, but a
<tt><glossdef></tt> and
<tt><glossseealso></tt> are okay.
</p>
<p>
A glossary looks like this:
</p>
<div class="example">
<h4 class="exampletitle">Example 1. Contents of gloss.xml</h4>
<div class="programlisting">
<pre><glossary id="the-glossary">
<!-- SECTION: XML-SPECIFIC TERMS -->
<glossdiv>
<title>XML Terms</title>
<glossentry>
<glossterm>absolute location term</glossterm>
<glossdef>
<para>A term that completely identifies the location of a
resource via XPointer. A unique ID attribute assigned to an
element can be used as an absolute location
term.</para>
</glossdef>
<glossseealso>relative location term</glossseealso>
<glossseealso>XPath</glossseealso>
<glossseealso>XPointer</glossseealso>
</glossentry>
<glossentry>
<glossterm>actuation</glossterm>
<glossdef>
<para>How a link in a document is triggered. For example, a
link to an imported graphic automatically includes a graphic
in the document, and a link to a URL resource requires a
signal from a human.</para>
</glossdef>
</glossentry>
</glossdiv>
<!-- SECTION: OTHER TERMS -->
<glossdiv>
<title>Other Terms</title>
<glossentry>
<glossterm>albatross<glossterm>
<glosssee>birds</glosssee>
</glossentry>
</glossdiv>
</glossary></pre>
</div>
</div>
</div>
<a name="section-1.7"></a>
<div class="ssection">
<h3 class="sstitle">5.7. Bibliography</h3>
<p>Coming soon...</p>
</div>
</div>
<a name="section-6"></a>
<div class="section">
<h2 class="stitle">6. Block elements</h2>
<p>
A block element is any element that starts a
new line when formatted and contains inline elements. We have seen
three already: <tt><para></tt>,
<tt><title></tt>, and
<tt><figure></tt>. Following is a table of block
elements with examples:
</p>
<table border="1">
<h4 class="exampletitle">Table 1. Common block elements</h4>
<tr>
<th>element</th>
<th>purpose</th>
<th>example</th>
</tr>
<tr>
<td><tt><para></tt></td>
<td>Paragraph.</td>
<td>
<div class="programlisting">
<pre><para>The quick, brown fox jumped over the lazy
dog. The quick, brown fox jumped over the lazy dog.
The quick, brown fox jumped over the lazy dog.</para></pre>
</div>
</td>
</tr>
<tr>
<td><tt><title></tt></td>
<td>Title.</td>
<td>
<div class="programlisting">
<pre><title>The Benefits of Laughter</title></pre>
</div>
</td>
</tr>
<tr>
<td><tt><remark></tt></td>
<td>
<p>
Comment that is not meant for the audience, and outside of the
flow of text. Usually, a communication between the author, editor,
reviewers, copyeditors, etc.
</p>
</td>
<td>
<div class="programlisting">
<pre><remark>This section is too short
and needs more examples. [Ellen]</remark></pre>
</div>
</td>
</tr>
<tr>
<td><tt><blockquote></tt></td>
<td>Quotation.</td>
<td>
<div class="programlisting">
<pre><blockquote>
<para>"They who can give up essential
liberty to purchase a little temporary
safety, deserve neither liberty nor safety,"
spat Ben Franklin.</para>
<para>"Yes," replied Mark Twain, "but
loyalty to petrified opinion never broke a
chain or freed a human soul."</para>
</blockquote></pre>
</div>
</td>
</tr>
<tr>
<td><tt><itemizedlist></tt></td>
<td>
<p>A list of items where order doesn't matter.</p>
</td>
<td>
<div class="programlisting">
<pre><itemizedlist>
<listitem><para>dogsled</para></listitem>
<listitem><para>hang-glider</para></listitem>
<listitem><para>roller blades</para></listitem>
</itemizedlist></pre>
</div>
</td>
</tr>
<tr>
<td><tt><orderedlist></tt></td>
<td>
<p>
A list of items where order is important.
</p>
</td>
<td>
<div class="programlisting">
<pre><orderedlist>
<listitem><para>Get a bowl.</para></listitem>
<listitem><para>Pour the cereal.</para></listitem>
<listitem><para>Add the milk.</para></listitem>
<listitem><para>Eat.</para></listitem>
</orderedlist></pre>
</div>
</td>
</tr>
<tr>
<td><tt><variablelist></tt></td>
<td>
<p>
A list that contains terms and their definitions.
</p>
</td>
<td>
<div class="programlisting">
<pre><variablelist>
<varlistentry><term>Snickers</term>
<listitem><para>Peanuts in nougat
covered in chocolate.</para></listitem></varlistentry>
<varlistentry><term>Payday</term>
<listitem><para>A peanut cluster cemented with caramel and
delicious sticky stuff.</para></listitem></varlistentry>
</variablelist></pre>
</div>
</td>
</tr>
<tr>
<td><tt><programlisting></tt></td>
<td>
<p>
A piece of computer code or example markup where whitespace and
other formatting must be preserved.
</p>
</td>
<td>
<div class="programlisting">
<pre><programlisting>public void init(ServletConfig config)
throws ServletException {
super.init(config);
String greeting = getInitParameter("greeting");
}</programlisting></pre>
</div>
</td>
</tr>
<tr>
<td><tt><screen></tt></td>
<td>
<p>
A representation of data displayed on a computer
screen. (Whitespace and other formatting are preserved.)
</p>
</td>
<td>
<div class="programlisting">
<pre><screen>&gt; ls -l
total 6860
-r--r--r-- 1 eray ora 2570 Mar 27 19:38 BOOKFILES
-rw-rw-r-- 1 eray ora 13283 Mar 27 19:38 BOOKIDS
-rw-rw-r-- 1 sierra ora 2692 Mar 28 14:43 Makefile
drwxrwxr-x 2 jwizda ora 512 Aug 10 14:22 RCS/
-rw-rw-r-- 1 jwizda ora 39 Jul 26 17:39 README</screen></pre>
</div>
</td>
</tr>
<tr>
<td><tt><literallayout></tt></td>
<td>
<p>
Traditional text with special linebreaks to be preserved.
</p>
</td>
<td>
<div class="programlisting">
<pre><literallayout>to be yourself, in a world that
tries, night and day, to make you
just like everybody else, is to fight
the greatest battle there ever is
to fight, and never stop fighting
e. e. cummings</literallayout></pre>
</div>
</td>
</tr>
<tr>
<td><tt><figure></tt></td>
<td>
<p>
A graphic with a title.
</p>
</td>
<td>
<div class="programlisting">
<pre><figure id="FOO-APP-E-FIG-19">
<title>The garden variety eggplant</title>
<graphic fileref="figs/eggplant.eps"/>
</figure></pre>
</div>
</td>
</tr>
<tr>
<td><tt><example></tt></td>
<td>
<p>Anything that serves as an example and requires a
title. (Use an <informalexample> if you don't need a
title.)
</p>
</td>
<td>
<div class="programlisting">
<pre><example id="BAZ-CH-14-EX-5">
<title>Contents of the file
<filename>blather.cfg</filename></title>
<programlisting>CATS = -c/usr/local/prod/sgml/CATALOG
DSLCAT = -c/usr/local/sp/dsssl/catalog
DECL = /usr/local/sp/pubtext/xml.dcl
SRCHURL = xsrch.htm
STYLE = dbwrap.dsl
VALOPTS = -sv -wxml</programlisting>
</example></pre>
</div>
</td>
</tr>
</table>
</div>
<a name="section-7"></a>
<div class="section">
<h2 class="stitle">7. Inline elements</h2>
<p>
In contrast to block elements, inline elements
do not force a line break, but coexist peacefully with their siblings
inside a block element. There are two basic types: those that contain
data, and those that don't. The first group is used to label one or
more words as a special kind of object, or deserving of special
processing. Those in the second group function as markers in the text,
anchoring a cross reference or marking some other kind of positional
data. The following table lists inline elements and their
function.
</p>
<table border="1">
<h4 class="exampletitle">Table 1. Inline Elements</h4>
<tr>
<th>element</th>
<th>purpose</th>
<th>example</th>
</tr>
<tr>
<td><tt><abbrev></tt></td>
<td>An abbreviated term.</td>
<td>
<div class="programlisting">
<pre>She's in <abbrev>bldg</abbrev 42.></pre>
</div>
</td>
</tr>
<tr>
<td><tt><accel></tt></td>
<td>A shortcut.</td>
<td>
<div class="programlisting">
<pre>Type <accel>Ctl-s</accel> to search for
a term.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><acronym></tt></td>
<td>
<p>
Mark text as being an acronym.
</p>
</td>
<td>
<div class="programlisting">
<pre><acronym>ASCII</acronym></pre>
</div>
</td>
</tr>
<tr>
<td><tt><action></tt></td>
<td>
<p>
A user interface action like a mouse click.
</p>
</td>
<td>
<div class="programlisting">
<pre>Click <action>mouse
button-3</action> for a pop-up menu.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><application></tt></td>
<td>
<p>
The name of a computer software program.</p>
</td>
<td>
<div class="programlisting">
<pre>We can convert any document written in
<application<Microsoft Word</application>.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><citation></tt></td>
<td>
<p>
The source of a quote or piece of information.
</p>
</td>
<td>
<div class="programlisting">
<pre><citation>Bill Gates</citation>
once said <quote>256 kB of RAM ought to be good enough
for anybody.</quote></pre>
</div>
</td>
</tr>
<tr>
<td><tt><citetitle></tt></td>
<td>
<p>
The name of a book or article.
</p>
</td>
<td>
<div class="programlisting">
<pre><citetitle>The Hobbit</citetitle></pre>
</div>
</td>
</tr>
<tr>
<td><tt><classname></tt></td>
<td>
<p>
An identifier for a class in some programming
language.
</p>
</td>
<td>
<div class="programlisting">
<pre>The <classname>string</class>
class has six public methods.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><classref></tt></td>
<td>
<p>
A cross reference to a class, with special formatting such as
displaying the class name. (Used mainly in Java books.)
</p>
</td>
<td></td>
</tr>
<tr>
<td><tt><command></tt></td>
<td>
<p>
Any command one would type in a computer terminal.
</p>
</td>
<td>
<div class="programlisting">
<pre>To print the file to screen, use the
<command>lpr</command> command.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><computeroutput></tt></td>
<td>
<p>
Text that would be output by a computer program.
</p>
</td>
<td>
<div class="programlisting">
<pre>When we run the script we get the result
<computeroutput>file not found</computeroutput>.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><email></tt></td>
<td>
<p>
An email address. (Note that there may be some conflict
with the <systemitem> element.)
</p>
</td>
<td>
<div class="programlisting">
<pre>Send questions to
<email>tools@oreilly.com</email>.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><emphasis></tt></td>
<td>
<p>
Give special emphasis to a word or phrase. Usually this
formats as italic, but default formatting can be overridden with a
<tt>role</tt> attribute such as
<tt>role="bold"</tt>.
</p>
</td>
<td>
<div class="programlisting">
<pre>This step is <emphasis>very</emphasis> important</pre>
</div>
</td>
</tr>
<tr>
<td><tt><envar></tt></td>
<td>An environment variable.</td>
<td>
<div class="programlisting">
<pre>Set the variable <envar>EDITOR</envar>
to <literal>emacs</literal>.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><filename></tt></td>
<td>Tags a word as being a filename.</td>
<td>
<div class="programlisting">
<pre>Be sure to read
<filename>readme.txt</filename>.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><firstterm></tt></td>
<td>
<p>
The first time an important term is mentioned.
</p>
</td>
<td>
<div class="programlisting">
<pre>A <firstterm>squib</firstterm>
is someone born to a wizard family but who can't do magic.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><foreignphrase></tt></td>
<td>Words from another language.</td>
<td>
<div class="programlisting">
<pre>There's nothing wrong with borrowing code
<foreignphrase>per se<foreignphrase>.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><footnoteref></tt></td>
<td>
<p>
A marker that imports a <tt><footnote></tt>
where there would otherwise be a redundant footnote
definition.
</p>
</td>
<td>
<div class="programlisting">
<pre>The Eiffel Tower is huge<footnote id="ABC-CH-4-FN-2">
<para>Although, compared to a breadbox, any
building is huge.</para></footnote>. So is a redwood
tree<footnoteref linkend="ABC-CH-4-FN-2">.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><graphic></tt></td>
<td>
<p>
An icon or picture to be imported into the document.
</p>
</td>
<td>
<div class="programlisting">
<pre>Examples marked with a disk icon
<graphic fileref="figs/icon.eps"> are on
the companion disk.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><function></tt></td>
<td>
<p>
The name of a function, method, or subroutine.
</p>
</td>
<td>
<div class="programlisting">
<pre>The function
<function>alpha_sort</function> can be made more
efficient.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><guibutton></tt></td>
<td>
<p>
A clickable control (e.g. a button) in a graphical interface.
</p>
</td>
<td>
<div class="programlisting">
<pre>Select the
<guibutton>print<guibutton> button to get
hardcopy.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><guimenu></tt></td>
<td>
<p>
A menu or submenu in a graphical interface.
</p>
</td>
<td>
<div class="programlisting">
<pre>Close the program by selecting
<guimenuitem>exit</guimenuitem> from the
<guimenu>file</guimenu> menu.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><guimenuitem></tt></td>
<td>
<p>
An item in a menu or submenu in a graphical interface.
</p>
</td>
<td>
<div class="programlisting">
<pre>Close the program by selecting
<guimenuitem>exit</guimenuitem> from the
<guimenu>file</guimenu> menu.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><keycap></tt></td>
<td>
<p>
A character to be represented as a key on a keyboard.
</p>
</td>
<td>
<div class="programlisting">
<pre>Pressing <keycap>s</keycap>
will save the buffer to a file.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><keysym></tt></td>
<td></td>
<td></td>
</tr>
<tr>
<td><tt><lineannotation></tt></td>
<td>
<p>
An annotation appearing inside a <tt><screen></tt> or
<tt><programlisting></tt>.
</p>
</td>
<td>
<div class="programlisting">
<pre>for( int $i=0; $i<10; $i++ ) {
<lineannotation>body of loop</lineannotation>
}</pre>
</div>
</td>
</tr>
<tr>
<td><tt><literal></tt></td>
<td>
<p>
A token or string that is part of a computer program or
script, which should be formatted in constant width.
</p>
</td>
<td>
<div class="programlisting">
<pre>If the parameter's value is
<literal>YELLOW</literal> your subroutine will
explode.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><option></tt></td>
<td>
<p>
A code to apply an optional parameter to a command,
program, or function.
</p>
</td>
<td>
<div class="programlisting">
<pre>The command synopsis is
<command>rm <option>-i</option> *.txt</command>.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><optional></tt></td>
<td>
<p>
Designates some text as an optional item.
</p>
</td>
<td>
<div class="programlisting">
<pre>The stylesheet specification is optional:
<command>formatfiles <optional>stylesheet</optional>
in.xml<command>.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><parameter></tt></td>
<td>
<p>
The name of a parameter for a function, method, or subroutine.
</p>
</td>
<td>
<div class="programlisting">
<pre>In the <function>factorial</function>
function, there is only one parameter,
<parameter>num</parameter>.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><prompt></tt></td>
<td>
<p>
A word meant to appear as a prompt in a computer display.
</p>
</td>
<td>
<div class="programlisting">
<pre>At the prompt
<prompt>Data?</prompt>, type in your age in
hexadecimal.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><quote></tt></td>
<td>
<p>
Quoted text.
</p>
</td>
<td>
<div class="programlisting">
<pre>Our motto is
<foreignphrase>Caveat Emptor</foreignphrase>,
which means <quote>we hope you like it!</quote></pre>
</div>
</td>
</tr>
<tr>
<td><tt><replaceable></tt></td>
<td>
<p>
Marks the data as a replaceable item, a value to be filled in.
</p>
</td>
<td>
<div class="programlisting">
<pre>...where <replaceable>w</replaceable>
is the width.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><returnvalue></tt></td>
<td>
<p>
Data that has been returned from a program or function.
</p>
</td>
<td>
<div class="programlisting">
<pre>The <function>reverse_string</function>
gives the value <returnvalue>tesolcmoorb</returnvalue>.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><sgmltag></tt></td>
<td>
<p>
The name of an SGML or XML element.
</p>
</td>
<td>
<div class="programlisting">
<pre>The <sgmltag>P</sgmltag>
element adds space above and below.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><structfield></tt></td>
<td>
<p>
The name of a field in a data structure.
</p>
</td>
<td>
<div class="programlisting">
<pre><structfield>name</structfield>
is a fixed array of bytes.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><structname></tt></td>
<td>
<p>
The name of a data structure.
</p>
</td>
<td>
<div class="programlisting">
<pre>To add a record, we must create a new
<structname>PartStruct</structname>.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><subscript></tt></td>
<td>
<p>
Text that should be rendered in subscript (smaller and
below the baseline).
</p>
</td>
<td>
<div class="programlisting">
<pre>The molecule
H<subscript>2</subscript>O has many strange
properties.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><superscript></tt></td>
<td>
<p>
Text that should be rendered in superscript (smaller and
above the midline).
</p>
</td>
<td>
<div class="programlisting">
<pre>Einstein revolutionized physics with
the simple equation E=MC<superscript>2</superscript></pre>
</div>
</td>
</tr>
<tr>
<td><tt><symbol></tt></td>
<td>
<p>A special symbol or token.</p>
</td>
<td>
<div class="programlisting">
<pre>The mutant gene <symbol>BLu-6</symbol>
is responsible for Smurfs' vivid azure hue.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><systemitem></tt></td>
<td>
<p>
Designates data as a special item having to do with
computers or networks. Most common use is to encode a
URL.
</p>
</td>
<td>
<div class="programlisting">
<pre><systemitem class="url">http://www.oreilly.com</systemitem></pre>
</div>
</td>
</tr>
<tr>
<td><tt><type></tt></td>
<td>
<p>A variable or constant data type.</p>
</td>
<td>
<div class="programlisting">
<pre>The function returns a value of type
<type>boolean</type>.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><userinput></tt></td>
<td>
<p>
Text entered by a human into a computer terminal.
</p>
</td>
<td>
<div class="programlisting">
<pre>At the command line, type
<userinput>telnet bubba.beerguzzlin.org</userinput></pre>
</div>
</td>
</tr>
<tr>
<td><tt><wordasword></tt></td>
<td>
<p>A word used as an example.</p>
</td>
<td>
<div class="programlisting">
<pre>By <wordasword>snake</wordasword>,
I mean <quote>dirty, stinkin' varmint</quote>.</pre>
</div>
</td>
</tr>
<tr>
<td><tt><xref></tt></td>
<td>
<p>
A cross reference to some element in the book. The
required <tt>linkend</tt> attribute contains the
<tt>id</tt> of the element being referenced.
</p>
</td>
<td>
<div class="programlisting">
<pre>For more information, refer to
<xref linkend="XYZ-CH-4"/>.</pre>
</div>
</td>
</tr>
</table>
</div>
<a name="section-8"></a>
<div class="section">
<h2 class="stitle">8. Tables</h2>
<p>
The tables used in DocBook Lite are a slimmed-down version of the CALS
table model, a popular markup format for tables. There are two outer
elements for tables: <tt><table></tt>, which requires
a title, and <tt><informaltable></tt>, which does not.
These elements contain a <tt><tgroup></tt> element
with an attribute <tt>cols</tt> that specifies the number of
columns in the table.
</p>
<p>
The table has a head, body, and foot, contained in
<tt><thead></tt>, <tt><tbody></tt>,
and <tt><tfoot></tt> elements, respectively. Only the
body is required. The head and body contain a set of rows, each a
<tt><row></tt> element. The foot contains text that
will appear just below the table, usually within the lines.
</p>
<p>
A <tt><row></tt> element contains some number of
<tt><entry></tt>s, each corresponding to a table
cell. The entry may either contain mixed content text, or a block
element such as a paragraph. The following is an example of a simple
titled table:
</p>
<div class="programlisting">
<pre><table id="ABC-CH-1-TABLE-5">
<title>States and Their Capitals</title>
<tgroup cols="2">
<thead>
<row>
<entry>State</entry>
<entry>Capital</entry>
</row>
</thead>
<tbody>
<row>
<entry>New York</entry>
<entry>Albany</entry>
</row>
<row>
<entry>Massachusetts</entry>
<entry>Boston</entry>
</row>
<row>
<entry>Hawaii</entry>
<entry>Honalulu</entry>
</row>
</tbody>
</tgroup>
</table></pre>
</div>
<p>
To span a row, add to the <tt><entry></tt>
element an attribute <tt>morerows="N"</tt>, where N is the
number of rows to span beyond the current row. For example, to make an
entry that spans 3 rows, use <tt>morerows="2"</tt>. For each
of the following rows that are spanned, leave out an
<tt><entry></tt> element, since the spanning cell will
inhabit that space.
</p>
<p>
To span columns, it's a bit more complicated (we didn't try to fix the
weird CALS way of doing it). First, you have to name the columns.
Second, you need to create named spans. Finally, you reference the
spans within the table cells. Here's an example:
</p>
<div class="programlisting">
<pre><informaltable>
<tgroup cols="3">
<colspec colnum="1" colname="c1">
<colspec colnum="3" colname="c3">
<spanspec spanname="span13" namest="c1" nameend="c3">
<tbody>
<row>
<entry>A</entry>
<entry>B</entry>
<entry>C</entry>
</row>
<row>
<entry colspan="span13" >D</entry>
</row>
<row>
<entry>E</entry>
<entry>F</entry>
<entry>G</entry>
</row>
</tbody>
</tgroup>
</table></pre>
</div>
</div>
<a name="section-9"></a>
<div class="section">
<h2 class="stitle">9. Indexterms</h2>
<p>
We generate indexes for books automatically, with the data originating
in <tt><indexterm></tt> elements interspersed
throughout the book. An indexterm holds all the information necessary
for a single entry in an index, including the primary, secondary, and
tertiary terms, references to other entries (see, see also), how to
sort the term, and whether it should cross a range of pages. An
indexterm typically looks like this:
</p>
<div class="programlisting">
<pre><indexterm id="ixt-blather-frobozz-zmic">
<primary>blather</primary>
<secondary>frobozz</secondary>
<tertiary sortas="@">zmic</tertiary>
<seealso>fuj</seealso>
</indexterm></pre>
</div>
<p>
The term in this example is a tertiary-level term "zmic", which appears
under the secondary term "frobozz", under the primary term
"blather". It will be sorted as if it began with the character "@",
which will pull it to the top of the secondary term's listing. The
term will display "see also fuj". Here's how the final index entry
might look in an index:
</p>
<div class="screen">
<pre>blaam 24-26
blather
abba 12, 15
crufty 99-105, 411
frobozz 75
zmic 10 (see also fuj) <-- the term
asca 19, 22
gumm 82-88
splat 470
zingle (see grooby)
gurgle 99, 111
bmm (see kluk)
bravy
scoot 45-48
yodle 91</pre>
</div>
<p>
Indexterms can appear inside a wide variety of elements, but they
typically appear inside paragraphs, lists, tables, or sections. They
are forbidden from appearing in titles, and should only rarely appear
inside program listings.
</p>
<p>
To create a term that spans a segment of text, you use two
<tt><indexterm></tt> elements linked by an
<tt>id</tt>-<tt>startref</tt>
attribute pair and <tt>class</tt> attributes. For
example:
</p>
<div class="programlisting">
<pre><!-- start of the range -->
<indexterm id="idx-fooby" class="startofrange">
<primary>fooby</primary>
</indexterm>
<!-- content to be indexed -->
<sect1>
<title>Programming Your Fooby</title>
<para>Blah blah blah...</para>
...
</sect1>
<!-- end of the range -->
<indexterm class="endofrange" startref="idx-fooby"/></pre>
</div>
</div>
<a name="section-10"></a>
<div class="section">
<h2 class="stitle">10. Out-of-flow Text</h2>
<p>
Out-of-flow text is handled in several ways. Sidebars are for short
discussions that don't belong in the general flow, aren't suitable for
their own section, and can easily be encapsulated as a one-page
aside. Admonitions (e.g. warnings, cautions, tips, etc.) are like
sidebars but attract attention to themselves with more dramatic
formatting and often an icon. Footnotes are shorter notes that have
only a weak connection to the text and should be removed from view to
the bottom of the page.
</p>
<a name="section-1.1"></a>
<div class="ssection">
<h3 class="sstitle">10.1. Sidebars</h3>
<p>
A sidebar functions like a section, but cannot contain sections within
itself. Any other block content is allowed. They can appear at any
level in the document underneath the chapter level. For example:
</p>
<div class="programlisting">
<pre><section>
<title>Bathyscaph Care and Maintenance</title>
<para>The hull of your submersible chamber is warranted
for seven years against seal ruptures and corrosion of fittings.
With proper care, you can extend the usable lifetime
considerably. Barnacles are the most common cause of
metal fatigue and gasket deterioration (see the sidebar for
tips in removing these pests).</para>
<sidebar>
<title>Scraping Barnacles</title>
<para>You'll need a wire brush and a solution of equal parts
vinegar and water. Pour the solution over the barnacles and let it
sit for several hours. When the barnacle shells are soft, scrub
them vigorously with the brush...</para>
...
</sidebar>
...
</sect2></pre>
</div>
</div>
<a name="section-1.2"></a>
<div class="ssection">
<h3 class="sstitle">10.2. Admonitions</h3>
<p>
To catch a reader's attention about a serious consideration, use an
admonition. DocBook provides a whole bunch: caution, important, note, tip,
and warning. In the absence of a title, either a default will be used
(e.g. "WARNING!") or an icon will catch the reader's attention. Here's
an example:
</p>
<div class="programlisting">
<pre><caution>
<para>Make sure your craft has reached the surface
before unsealing the hatch. Otherwise, high-pressure
water will flood the compartment.</para>
</caution></pre>
</div>
<p>
An admonition can appear in any section but cannot contain
sections. Try to keep its content simple, using only paragraphs and
lists if possible.
</p>
</div>
<a name="section-1.3"></a>
<div class="ssection">
<h3 class="sstitle">10.3. Footnotes</h3>
<p>
A <tt><footnote></tt> is coded as a block that
interrupts a paragraph. It can look a little odd:
</p>
<div class="programlisting">
<pre><para>When on Mars, be sure to
visit the great volcano Olympus Mons<footnote>
<para>It happens to be the tallest mountain in the Solar
System, so bring your best hiking shoes.</para>
</footnote>...</pre>
</div>
<p>
When the same footnote applies to different places in a document, you
can use a <tt><footnoteref></tt> element to reference
it. The following example shows how:
</p>
<div class="programlisting">
<pre><table>
<tgroup cols="2">
<row>
<entry>apple</entry>
<entry>red</entry>
</row>
<row>
<entry>banana<footnote id="warning">
<para>Peel it first!</para>
</footnote></entry>
<entry>yellow</entry>
</row>
<row>
<entry>grape</entry>
<entry>purple</entry>
</row>
<row>
<entry>orange<footnoteref
linkend="warning"/></entry>
<entry>orange</entry>
</row>
</tgroup>
</table></pre>
</div>
</div>
<a name="section-1.4"></a>
<div class="ssection">
<h3 class="sstitle">10.4. Endnotes</h3>
<p>
In some cases, you want a footnote's text to appear in another section
or chapter. The <tt><endnote></tt> element serves that
function. It also stores the body of the note elsewhere. For example:
</p>
<div class="programlisting">
<pre><para>We suspect that lightning often appears in hues other
than white. This hypothesis is supported by
Dr. Indigo Riceway<endnote linkend="note-riceway"/>.</para>
...
<endnote id="note-riceway">
<para>Riceway wrote about green lightning in his
book...</para>
</endnote></pre>
</div>
</div>
</div>
<a name="section-11"></a>
<div class="section">
<h2 class="stitle">11. Reference Pages</h2>
<p>
One of the more complex block elements is
<tt><refentry></tt>. It is used to encode a compact set of
information about a command, application, or other technical
entity. There are several different ways to format a reference entry,
so we provide a <tt>role</tt> attribute to let you choose
the one that best fits your book.
</p>
<p>
There are three main types supported:
</p>
<ul>
<li>
<p>
Default
</p>
</li>
<li>
<p>
Nutshell
</p>
</li>
<li>
<p>
Java
</p>
</li>
</ul>
<a name="section-1.1"></a>
<div class="ssection">
<h3 class="sstitle">11.1. Default Reference Pages</h3>
<p>
Here are three examples of common reference pages used in DocBook Lite:
</p>
<div class="figure">
<h4 class="figuretitle">Figure 1.
A refentry from <i>Samba</i>, Appendix C
</h4>
<image src="figs/ref1.gif"></image>
</div>
<div class="example">
<h4 class="exampletitle">Example 1. How the above refentry is coded</h4>
<div class="programlisting">
<pre><refentry>
<refmeta>
<refmiscinfo class="allowable values">YES, NO</refmiscinfo>
<refmiscinfo class="default">NO</refmiscinfo>
</refmeta>
<refnamediv>
<refname>alternate permissions = boolean</refname>
</refnamediv>
<refsynopsisdiv>
<para>Obsolete. Has no effect in Samba 2. Files will be shown as
read-only if the owner can't write them. In Samba 1.9 and
earlier, setting this option would set the DOS filesystem read-only
attribute on any file the user couldn't read. This in turn
required the <literal>delete readonly</literal>
option.</para>
</refsynopsisdiv>
</refentry></pre>
</div>
</div>
<div class="figure">
<h4 class="figuretitle">Figure 2.
A refentry from <i>MySQL and mSQL</i>, Chapter 21
</h4>
<image src="figs/ref2.gif"></image>
</div>
<div class="example">
<h4 class="exampletitle">Example 2. How the above refentry is coded</h4>
<div class="programlisting">
<pre><refentry>
<refmeta>
<refentrytitle>DBI::do</refentrytitle>
</refmeta>
<refnamediv>
<refname>DBI::do</refname>
</refnamediv>
<refsynopsisdiv>
<synopsis>$rows_affected = $db-&gt;do($statement);
$rows_affected = $db-&gt;do($statement, \%unused);
$rows_affected =
$db-&gt;do($statement, \%unused, @bind_values);</synopsis>
<para><literal>DBI::do</literal> directly performs a
non-<literal>SELECT</literal> SQL statement and
returns the number of rows affected by the statement. This is
faster than a <literal>DBI::prepare/DBI::execute
</literal>pair which requires two function calls. The
first argument is the SQL statement itself. The
second argument is unused in DBD::mSQL and DBD::mysql,
but can hold a reference to a hash of attributes for other
DBD modules. The final argument is an array of values used
to replace `placeholders,' which are indicated with a
`?' in the statement. The values of the array are
substituted for the placeholders from left to right. As an
additional bonus, <literal>DBI::do</literal> will
automatically quote string values before substitution.</para>
</refsynopsisdiv>
<refsect1>
<title>Example</title>
<programlisting>use DBI;
my $db = DBI-&gt;connect('DBI:mSQL:mydata',undef,undef);
my $rows_affected =
$db-&gt;do("UPDATE mytable SET name='Joe' WHERE name='Bob'");
print "$rows_affected Joe's were changed to Bob's\n";
my $rows_affected2 =
$db-&gt;do("INSERT INTO mytable (name) VALUES (?)",
{}, ("Sheldon's Cycle"));
# After quoting and substitution, the statement:
# INSERT INTO mytable (name) VALUES ('Sheldon's Cycle')
# was sent to the database server.</programlisting>
</refsect1>
</refentry></pre>
</div>
</div>
<div class="figure">
<h4 class="figuretitle">Figure 3.
A refentry from <i>Apache: The Definitive Guide</i>,
Chapter 14
</h4>
<image src="figs/ref3.gif"></image>
</div>
<div class="example">
<h4 class="exampletitle">Example 3. How the above refentry is coded</h4>
<div class="programlisting">
<pre><refentry>
<refmeta>
<refentrytitle>ap_pstrndup</refentrytitle>
</refmeta>
<refnamediv>
<refname>ap_pstrndup</refname>
<refpurpose>duplicate a string in a pool with
limited length</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>
char *ap_pstrndup(pool *p, const char *s, int n)</synopsis>
<para>Allocates <literal>n</literal>+1 bytes
of memory and copies up to <literal>n</literal>
characters from <literal>s</literal>,
<literal>NULL</literal>- terminating the result.
The memory is destroyed when the pool is destroyed. Returns
a pointer to the new block of memory, or
<literal>NULL</literal> if <literal>s</literal>
is <literal>NULL</literal>.</para>
</refsynopsisdiv>
</refentry></pre>
</div>
</div>
</div>
<a name="section-1.2"></a>
<div class="ssection">
<h3 class="sstitle">11.2. Nutshell Type Reference Pages</h3>
<p>
Nutshell books use a particular kind of reference structure that
looks like this:
</p>
<div class="figure">
<h4 class="figuretitle">Figure 1.
A refentry from <i>Unix in a Nutshell</i>, Chapter 5
</h4>
<image src="figs/ref4.gif"></image>
</div>
<div class="example">
<h4 class="exampletitle">Example 1. How the above refentry is coded</h4>
<div class="programlisting">
<pre><nutlist longestterm="unseten">
<nutentry><term>alias</term>
<nutsynopsis><literal>alias</literal>
[<replaceable>name</replaceable>
[<replaceable>command</replaceable>]]</nutsynopsis>
<nutentrybody>
<para>Assign <emphasis>name</emphasis>
as the shorthand name, or alias, for
<emphasis>command</emphasis>. If
<emphasis>command</emphasis> is omitted, print the
alias for <emphasis>name</emphasis>;
if <emphasis>name</emphasis> is also
omitted, print all aliases. Aliases can be defined on the command
line, but they are more often stored in
<literal>.cshrc</literal>
so that they take effect after login. (See [cross ref deleted]
earlier in this chapter.) Alias definitions can reference
command-line arguments, much like the history list. Use
<literal>\!*</literal> to refer to all command-line
arguments, <literal>\!^</literal> for the first argument,
<literal>\!$</literal> for the last, etc. An alias
<emphasis>name</emphasis> can be any valid Unix
command; however, you lose the original command's meaning unless
you type <emphasis>\name</emphasis>.
See also <emphasis
role="bold">unalias</emphasis>.</para>
<refsect2><title>Examples</title>
<para>Set the size for <literal>xterm</literal>
windows under the X Window System:</para>
<programlisting>alias R 'set noglob; eval `resize`;
unset noglob'</programlisting>
<para>Show aliases that contain the string
<emphasis>ls</emphasis>:</para>
<programlisting>alias | grep ls</programlisting>
<para>Run <literal>nroff</literal>
on all command-line arguments:</para>
<programlisting>alias ms 'nroff -ms \!*'</programlisting>
<para>Copy the file that is named as the first argument:</para>
<programlisting>alias back 'cp \!^ \!^.old'</programlisting>
<para>Use the regular <literal>ls</literal>,
not its alias:</para>
<programlisting>% <userinput>\ls
</userinput></programlisting>
</refsect2>
</nutentrybody>
</nutentry>
</nutlist></pre>
</div>
</div>
</div>
<a name="section-1.3"></a>
<div class="ssection">
<h3 class="sstitle">11.3. Java Type Reference Pages</h3>
<p>
This example shows how Java <tt><refentry></tt>s
look:
</p>
<div class="figure">
<h4 class="figuretitle">Figure 1.
A refentry from <i>Java Fundamental Classes in a
Nutshell</i>, Chapter 32.
</h4>
<image src="figs/ref5.gif"></image>
</div>
<div class="example">
<h4 class="exampletitle">Example 1. How the above refentry is coded</h4>
<div class="programlisting">
<pre><refentry role="java"
id="java.io.dataoutputstream">
<refmeta>
<refmiscinfo class="version">Java 1.0</refmiscinfo>
<refmiscinfo class="package">java.io</refmiscinfo>
<refmiscinfo class="flags">PJ1.1</refmiscinfo>
</refmeta>
<refnamediv>
<refname>DataOutputStream</refname>
</refnamediv>
<refsect1 role="intro">
<para>This class is a subclass of
<literal>FilterOutputStream</literal> that allows
you to write Java primitive data types in a portable binary
format. Create a <literal>DataOutputStream</literal>
by specifying the <literal>OutputStream</literal>
that is to be filtered in the call to the constructor.
<literal>DataOutputStream</literal> has methods
that output only primitive types; use
<literal>ObjectOutputStream</literal> to output object
values. </para>
</refsect1>
<refsynopsisdiv>
<classsynopsis keyword="class">
<modifiers>public</modifiers>
<classname>DataOutputStream</classname>
<extends><classref package="java.io"
class="FilterOutputStream"/></extends>
<implements><classref
package="java.io" class="DataOutput"/></implements>
<members><title>Public Constructors</title>
<membergroup>
<funcprototype revision="" role="method" flags="">
<funcdef><modifiers>public</modifiers>
<function>DataOutputStream</function>
</funcdef>
<paramdef>
<type><classref role="includePkg"
package="java.io" class="OutputStream"/></type>
<parameter>out</parameter>
</paramdef>
</funcprototype>
</membergroup>
</members>
<members><title>Public Instance Methods</title>
<membergroup>
<funcprototype revision="" role="method" flags="">
<funcdef><modifiers>public final</modifiers>
<type>int</type>
<function>size</function>
</funcdef>
</funcprototype>
</membergroup>
</members>
<members><title>Methods Implementing
<classref package="java.io" class="DataOutput"/></title>
<membergroup>
<funcprototype revision="" role="method" flags=" synchronized">
<funcdef><modifiers>public</modifiers> <type>void</type>
<function>write</function>
</funcdef>
<paramdef><type>int</type> <parameter>b</parameter></paramdef>
<throws><classref package="java.io" class="IOException"/></throws>
</funcprototype>
</membergroup>
<membergroup>
<funcprototype revision="" role="method" flags=" synchronized">
<funcdef><modifiers>public</modifiers> <type>void</type>
<function>write</function>
</funcdef>
<paramdef>
<type>byte[&thinsp;]</type> <parameter>b</parameter></paramdef>
<paramdef><type>int</type> <parameter>off</parameter></paramdef>
<paramdef><type>int</type> <parameter>len</parameter></paramdef>
<throws><classref package="java.io" class="IOException"/></throws>
</funcprototype>
</membergroup>
<membergroup>
<funcprototype revision="" role="method" flags="">
<funcdef><modifiers>public final</modifiers> <type>void</type>
<function>writeBoolean</function>
</funcdef>
<paramdef><type>boolean</type> <parameter>v</parameter></paramdef>
<throws><classref package="java.io" class="IOException"/></throws>
</funcprototype>
</membergroup>
<membergroup>
<funcprototype revision="" role="method" flags="">
<funcdef><modifiers>public final</modifiers> <type>void</type>
<function>writeByte</function>
</funcdef>
<paramdef><type>int</type> <parameter>v</parameter></paramdef>
<throws><classref package="java.io" class="IOException"/></throws>
</funcprototype>
</membergroup>
<membergroup>
<funcprototype revision="" role="method" flags="">
<funcdef><modifiers>public final</modifiers> <type>void</type>
<function>writeInt</function>
</funcdef>
<paramdef><type>int</type> <parameter>v</parameter></paramdef>
<throws><classref package="java.io" class="IOException"/></throws>
</funcprototype>
</membergroup>
</members>
<members><title>Public Methods Overriding <classref package="java.io"
class="FilterOutputStream"/></title>
<membergroup>
<funcprototype revision="" role="method" flags="">
<funcdef><modifiers>public</modifiers> <type>void</type>
<function>flush</function>
</funcdef>
<throws><classref package="java.io" class="IOException"/></throws>
</funcprototype>
</membergroup>
</members>
<members>
<title>Protected Instance Fields</title>
<membergroup>
<funcprototype revision="" role="field" flags="">
<funcdef><modifiers>protected</modifiers> <type>int</type>
<function>written</function>
</funcdef>
</funcprototype>
</membergroup>
</members>
</classsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Hierarchy</title>
<para>
<literal><classref package="java.lang" class="Object"/> &rarr;
<classref role="includePkg" package="java.io"
class="OutputStream"/> &rarr; <classref package="java.io"
class="FilterOutputStream"/> &rarr; <classref role="includePkg"
package="java.io" class="DataOutputStream"/> (<classref
package="java.io" class="DataOutput"/>)</literal></para>
</refsect1>
</refentry></pre>
</div>
</div>
</div>
</div>
<a name="section-12"></a>
<hr>
<span class="footertitle">Written by:</span>
<br>
<b>Erik Ray <i><a href="mailto:eray@oreilly.com">eray@oreilly.com</a></i>
<br>
</b>
</body>
</html>
|