Contents of /xml/htdocs/doc/en/xml-guide.xml

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.6 - (hide annotations) (download) (as text)
Sat Jan 11 03:27:06 2003 UTC (16 years ago) by zhen
Branch: MAIN
Changes since 1.5: +32 -24 lines
File MIME type: application/xml
much needed updates

1 zhen 1.3 <?xml version='1.0' encoding="UTF-8"?>
2 drobbins 1.1 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
4 zhen 1.2 <guide link="/doc/en/xml-guide.xml">
5 drobbins 1.1 <title>Gentoo Linux Documentation Guide</title>
6 zhen 1.6 <author title="Author"><mail link="drobbins@gentoo.org">Daniel Robbins</mail></author>
7     <author title="Editor"><mail link="zhen@gentoo.org">John P. Davis</mail></author>
8 drobbins 1.1
9     <abstract>This guide shows you how to compose web documentation using the new lightweight Gentoo guide
10     XML syntax. This syntax is the official format for Gentoo Linux documentation, and this document
11     itself was created using guide XML. This guide assumes a basic working knowledge of XML and HTML.
12     </abstract>
14 zhen 1.6 <version>1.1</version>
15     <date>10 January 2002</date>
16 drobbins 1.1
17     <chapter>
18     <title>Guide basics</title>
20     <section>
21     <title>Guide XML design goals</title>
22     <body>
24     <p> The guide XML syntax is lightweight yet expressive, so that it is easy to
25     learn yet also provides all the features we need for the creation of web
26     documentation. The number of tags is kept to a minimum -- just those we need.
27     This makes it easy to transform guide into other formats, such as DocBook
28     XML/SGML or web-ready HTML. </p>
30     <p>The goal is to make it easy to <e>create</e> and <e>transform</e> guide XML
31     documents.</p>
33     </body>
34     </section>
36     <section>
37     <title>How to transform guide XML into HTML</title>
38     <body>
40     <p> Before we take a look at the guide syntax itself, it's helpful to know how
41     guide XML is transformed into web-ready HTML. To do this, we use a special
42 zhen 1.6 file called <path>guide.xsl</path>, along with a command-line XSLT processing
43     tool (also called an "engine"). The <path>guide.xsl</path> file describes
44 drobbins 1.1 exactly how to transform the contents of the source guide XML document to
45     create the target HTML file. Two popular XSLT processors are <c>sabcmd</c>
46     (included in the <path>app-text/sablotron</path> package) and <c>xsltproc</c>
47     (found in the <path>dev-libs/libxslt</path> package). From experience, we've
48     found that <c>xsltproc</c> is the higher-quality and more feature-rich XSLT
49     processor. </p>
51 zhen 1.6
52 drobbins 1.1 <p> Once you have either <c>xsltproc</c> or <c>sabcmd</c> installed, you're
53 zhen 1.6 ready to convert guide XML into web-ready HTML. In order to do this though,
54     it is necessary to get the latest snapshot of our website tree.
55     </p>
57     <p>The gzipped tarball for the website can be found
58     <uri link="http://www.gentoo.org/dyn/arch/xml-guide-latest.tar.gz">here</uri>.
59 drobbins 1.1 </p>
61 zhen 1.6 <p>Now, extract the tarball. Inside it, you'll find a <path>htdocs</path>
62     directory. Now, find <path>htdocs/doc/&lt;your lang&gt;/gentoo-x86-install.xml</path>
63     (The new user installation guide). This will be our source XML guide document.
64     The easiest way to perform the transformation is to change directories to the location of the
65     <path>guide.xsl</path> file. Then, execute <c>xsltproc</c> as follows:
66     </p>
68     <pre caption="Transforming gentoo-x86-install.xml">
69     # <c>cd gentoo-web/xsl</c>
70     # <c>xsltproc guide.xsl ../doc/&lt;your lang&gt;/gentoo-x86-install.xml &gt; /tmp/install.html</c>
71 drobbins 1.1 </pre>
73     <p> If all went well, you should have a web-ready version of
74 zhen 1.6 <path>gentoo-x86-install.xml</path> at <path>/tmp/install.html</path>. For this document
75 drobbins 1.1 to display properly in a web browser, you may have to copy some files from
76 zhen 1.6 <path>htdocs</path> to <path>/tmp</path>, such
77 drobbins 1.1 as <path>css/main-new.css</path> and (to be safe) the entire <path>images</path>
78     directory.
79     </p>
81     </body>
82     </section>
83     </chapter>
84     <chapter>
85     <title>Guide XML</title>
86     <section>
87     <title>Basic structure</title>
88     <body>
90     <p>Now that you know how to transform guide XML, you're ready to start learning
91     the guide XML syntax. We'll start with the the initial tags used in a guide
92     XML document: </p>
94     <pre caption="The initial part of a guide XML document">
95 zhen 1.6 &lt;?xml version='1.0' encoding="UTF-8"?&gt;
96     &lt;guide link="relative_link_to_your_guide"&gt;
97 drobbins 1.1 &lt;title&gt;<i>Gentoo Linux Documentation Guide</i>&lt;/title&gt;
98     &lt;author title="<i>Chief Architect</i>"&gt;&lt;mail link="<i>drobbins@gentoo.org</i>"&gt;
99     <i>Daniel Robbins</i>&lt;/mail&gt;
100     &lt;/author&gt;
101     &lt;author title="<i>Editor</i>"&gt;&lt;mail link="<i>thomasfl@gentoo.org</i>"&gt;
102     <i>Thomas Flavel</i>&lt;/mail&gt;
103     &lt;/author&gt;
105 zhen 1.6 <impo>If you are going to be submitting documents, it is necessary to read the
106     <uri link="http://www.gentoo.org/doc/en/doc-developer-guide.xml">Gentoo Documentation Developer's Policy</uri>.
107     </impo>
109 drobbins 1.1 &lt;abstract&gt;<i>This guide shows you how to compose web documentation using
110     our new lightweight Gentoo guide XML syntax. This syntax is the official
111     format for Gentoo Linux web documentation, and this document itself was created
112     using guide XML.</i> &lt;/abstract&gt;
114     &lt;version&gt;<i>1.0</i>&lt;/version&gt;
115     &lt;date&gt;<i>29 Mar 2001</i>&lt;/date&gt;
116     </pre>
118     <p>On the first, line, we see the requisite tag that identifies this as an XML
119     document. Following it, there's a <c>&lt;guide&gt;</c> tag -- the entire
120     guide document is enclosed within a <c>&lt;guide&gt; &lt;/guide&gt;</c> pair.
121     Next, there's a <c>&lt;title&gt;</c> tag, used to set the title for the entire
122     guide document. </p>
124     <p>Then, we come to the <c>&lt;author&gt;</c> tags, which contain information
125     about the various authors of the document. Each <c>&lt;author&gt;</c> tag
126     allows for an optional <c>title=</c> element, used to specify the author's
127     relationship to the document (author, co-author, editor, etc.). In this
128     particular example, the authors' names are enclosed in another tag -- a
129     <c>&lt;mail&gt;</c> tag, used to specify an email address for this particular
130     person. The <c>&lt;mail&gt;</c> tag is optional and can be omitted, and no
131     more than one <c>&lt;author&gt;</c> element is required per guide document.
132     </p>
134     <p>Next, we come to the <c>&lt;abstract&gt;</c>, <c>&lt;version&gt;</c> and
135     <c>&lt;date&gt;</c> tags, used to specify a summary of the document, the
136     current version number, and the current version date (in DD MMM YYYY format)
137     respectively. This rounds out the tags that should appear at the beginning of
138     a guide document. Besides the <c>&lt;title&gt;</c> and <c>&lt;mail&gt;</c>
139     tags, these tags shouldn't appear anywhere else except immediately inside the
140     <c>&lt;guide&gt;</c> tag, and for consistency it's recommended (but not
141     required) that these tags appear before the content of the document. </p>
143     </body>
144     </section>
146     <section>
147     <title>Chapters and sections</title>
148     <body>
149     <p>Once the initial tags have been specified, you're ready to start adding
150     the structural elements of the document. Guide documents are divided into
151     chapters, and each chapter can hold one or more sections. Every chapter
152     and section has a title. Here's an example chapter with a single section,
153     consisting of a paragraph. If you append this XML to the XML in the <uri link="#doc_pre2">previous
154     excerpt</uri> and append a <c>&lt;/guide&gt;</c> to the end of the file, you'll have a valid
155     (if minimal) guide document:
156     </p>
158     <pre>
159     &lt;chapter&gt;
160     &lt;title&gt;<i>This is my chapter</i>&lt;/title&gt;
161     &lt;section&gt;
162     &lt;title&gt;<i>This is section one of my chapter</i>&lt;/title&gt;
163     &lt;body&gt;
164     &lt;p&gt;<i>This is the actual text content of my section.</i>&lt;/p&gt;
165     &lt;/body&gt;
166     &lt;/section&gt;
167     &lt;/chapter&gt;
168     </pre>
170     <p>Above, I set the chapter title by adding a child <c>&lt;title&gt;</c>
171     element to the <c>&lt;chapter&gt;</c> element. Then, I created a section by
172     adding a <c>&lt;section&gt;</c> element. If you look inside the
173     <c>&lt;section&gt;</c> element, you'll see that it has two child elements -- a
174     <c>&lt;title&gt;</c> and a <c>&lt;body&gt;</c>. While the <c>&lt;title&gt;</c>
175     is nothing new, the <c>&lt;body&gt;</c> is -- it contains the actual text
176     content of this particular section. We'll look at the tags that are allowed
177     inside a <c>&lt;body&gt;</c> element in a bit. </p>
179     <note>A <c>&lt;guide&gt;</c> element can contain multiple
180     <c>&lt;chapter&gt;</c> elements, and a <c>&lt;chapter&gt;</c> can contain
181     multiple <c>&lt;section&gt;</c> elements. However, a <c>&lt;section&gt;</c>
182     element can only contain one <c>&lt;body&gt;</c> element. </note>
184     </body>
185     </section>
187     <section>
188     <title>An example &lt;body&gt;</title>
189     <body>
190     <p>
191     Now, it's time to learn how to mark up actual content. Here's the XML code for an example <c>&lt;body&gt;</c> element:
192     </p>
193     <pre>
194     &lt;p&gt;
195     This is a paragraph. &lt;path&gt;/etc/passwd&lt;/path&gt; is a file.
196     &lt;uri&gt;http://www.gentoo.org&lt;/uri&gt; is my favorite website.
197     Type &lt;c&gt;ls&lt;/c&gt; if you feel like it. I &lt;e&gt;really&lt;/e&gt; want to go to sleep now.
198     &lt;/p&gt;
200     &lt;pre&gt;
201     This is text output or code.
202     # &lt;i&gt;this is user input&lt;/i&gt;
204     Make HTML/XML easier to read by using selective emphasis:
205     &lt;foo&gt;&lt;i&gt;bar&lt;/i&gt;&lt;/foo&gt;
207     &lt;codenote&gt;This is how to insert an inline note into the code block&lt;/codenote&gt;
208     &lt;/pre&gt;
209     &lt;note&gt;This is a note.&lt;/note&gt;
210     &lt;warn&gt;This is a warning.&lt;/warn&gt;
211     &lt;impo&gt;This is important.&lt;/impo&gt;
212     </pre>
213     <p>Now, here's how this <c>&lt;body&gt;</c> element is rendered:</p>
215     <p>
216     This is a paragraph. <path>/etc/passwd</path> is a file.
217     <uri>http://www.gentoo.org</uri> is my favorite website.
218     Type <c>ls</c> if you feel like it. I <e>really</e> want to go to sleep now.
219     </p>
221     <pre>
222     This is text output or code.
223     # <i>this is user input</i>
225     Make HTML/XML easier to read by using selective emphasis:
226     &lt;foo&gt;<i>bar</i>&lt;/foo&gt;
228     <codenote>This is how to insert an inline note into the code block</codenote>
229     </pre>
230     <note>This is a note.</note>
231     <warn>This is a warning.</warn>
232     <impo>This is important.</impo>
233     </body>
234     </section>
236     <section>
237     <title>The &lt;body&gt; tags</title>
238     <body>
240     <p> We introduced a lot of new tags in the previous section -- here's what you
241     need to know. The <c>&lt;p&gt;</c> (paragraph), <c>&lt;pre&gt;</c> (code
242     block), <c>&lt;note&gt;</c>, <c>&lt;warn&gt;</c> (warning) and
243     <c>&lt;impo&gt;</c> (important) tags all can contain one or more lines of text.
244     Besides the <c>&lt;table&gt;</c> element (which we'll cover in just a bit),
245     these are the only tags that should appear immediately inside a
246     <c>&lt;body&gt;</c> element. Another thing -- these tags <e>should not</e> be
247     stacked -- in other words, don't put a <c>&lt;note&gt;</c> element inside a
248     <c>&lt;p&gt;</c> element. As you might guess, the <c>&lt;pre&gt;</c> element
249     preserves its whitespace exactly, making it well-suited for code excerpts.</p>
251     </body>
252     </section>
253     <section>
254     <title>&lt;path&gt;, &lt;c&gt; and &lt;e&gt;</title>
255     <body>
257     <p>The <c>&lt;path&gt;</c>, <c>&lt;c&gt;</c> and <c>&lt;e&gt;</c> elements can
258     be used inside any child <c>&lt;body&gt;</c> tag, except for
259     <c>&lt;pre&gt;</c>. </p>
261     <p>The <c>&lt;path&gt;</c> element is used to mark text that refers to an
262     <e>on-disk file</e> -- either an <e>absolute or relative path</e>, or a <e>simple filename</e>.
263     This element is generally rendered with a monospaced font to offset it from the
264     standard paragraph type. </p>
266     <p>The <c>&lt;c&gt;</c> element is used to mark up a <e>command</e> or <e>user
267     input</e>. Think of <c>&lt;c&gt;</c> as a way to alert the reader to something
268     that they can type in that will perform some kind of action. For example, all
269     the XML tags displayed in this document are enclosed in a <c>&lt;c&gt;</c>
270     element because they represent something that the user could type in that is
271     not a path. By using <c>&lt;c&gt;</c> elements, you'll help your readers
272     quickly identify commands that they need to type in. Also, because
273     <c>&lt;c&gt;</c> elements are already offset from regular text, <e>it is rarely
274     necessary to surround user input with double-quotes</e>. For example, don't
275     refer to a "<c>&lt;c&gt;</c>" element like I did in this sentence. Avoiding
276     the use of unnecessary double-quotes makes a document more readable -- and adorable!</p>
278     <p><c>&lt;e&gt;</c> is used to apply emphasis to a word or phrase; for example:
279     I <e>really</e> should use semicolons more often. As you can see, this text is
280     offset from the regular paragraph type for emphasis. This helps to give your
281     prose more <e>punch</e>!</p>
283     </body>
284     </section>
286     <section>
287     <title>&lt;mail&gt; and &lt;uri&gt;</title>
288     <body>
290     <p>We've taken a look at the <c>&lt;mail&gt;</c> tag earlier; it's used to link some text
291     with a particular email address, and takes the form <c>&lt;mail link="foo@bar.com"&gt;Mr. Foo Bar&lt;/mail&gt;</c>.</p>
293     <p>The <c>&lt;uri&gt;</c> tag is used to point to files/locations on the
294     Internet. It has two forms -- the first can be used when you want to have the
295     actual URI displayed in the body text, such as this link to
296     <uri>http://www.gentoo.org</uri>. To create this link, I typed
297     <c>&lt;uri&gt;http://www.gentoo.org&lt;/uri&gt;</c>. The alternate form is
298     when you want to associate a URI with some other text -- for example, <uri
299     link="http://www.gentoo.org">the Gentoo Linux website</uri>. To create <e>this</e>
300     link, I typed <c>&lt;uri link="http://www.gentoo.org"&gt;the Gentoo Linux website&lt;/uri&gt;</c>.
301     </p>
303     </body>
304     </section>
306     <section>
307     <title>Figures</title>
309     <body>
311     <p>Here's how to insert a figure into a document -- <c>&lt;figure
312     link="mygfx.png" short="my picture" caption="my favorite picture of all
313     time"/&gt;</c>. The <c>link=</c> attribute points to the actual graphic image,
314     the <c>short=</c> attribute specifies a short description (currently used for
315     the image's HTML <c>alt=</c> attribute), and a caption. Not too difficult
316     :) We also support the standard HTML-style &lt;img src="foo.gif"/&gt; tag
317     for adding images without captions, borders, etc.</p>
319     </body>
320     </section>
321     <section>
322     <title>Tables and lists</title>
323     <body>
325     <p>Guide supports a simplified table syntax similar to that of HTML. To start
326     a table, use a <c>&lt;table&gt;</c> tag. Start a row with a <c>&lt;tr&gt;</c>
327     tag. However, for inserting actual table data, we <e>don't</e> support the
328     HTML &lt;td&gt; tag; instead, use the <c>&lt;th&gt;</c> if you are inserting a
329     header, and <c>&lt;ti&gt;</c> if you are inserting a normal informational
330     block. You can use a <c>&lt;th&gt;</c> anywhere you can use a <c>&lt;ti&gt;</c> --
331     there's no requirement that <c>&lt;th&gt;</c> elements appear only in the
332     first row. Currently, these tags don't support any attributes, but some will
333     be added (such as a <c>caption=</c> attribute for <c>&lt;table&gt;</c>) soon.
334     </p>
336     <p> To create ordered or unordered lists, simply use the HTML-style
337     <c>&lt;ol&gt;</c>, <c>&lt;ul&gt;</c> and <c>&lt;li&gt;</c> tags. List tags
338     should only appear inside a <c>&lt;p&gt;</c>, <c>&lt;ti&gt;</c>,
339     <c>&lt;note&gt;</c>, <c>&lt;warn&gt;</c> or <c>&lt;impo&gt;</c> tag. </p>
341     </body>
342     </section>
344     <section>
345     <title>Intra-document references</title>
346     <body>
348     <p>Guide makes it really easy to reference other parts of the document using
349     hyperlinks. You can create a link pointing to <uri link="#doc_chap1">Chapter
350     One</uri> by typing <c>&lt;uri link="#doc_chap1"&gt;Chapter
351     One&lt;/uri&gt;</c>. To point to <uri link="#doc_chap1_sect2">section two of
352     Chapter One</uri>, type <c>&lt;uri link="#doc_chap1_sect2"&gt;section two of
353     Chapter One&lt;/uri&gt;</c>. To refer to figure 3 in chapter 1, type <c>&lt;uri
354     link="doc_chap1_fig3"&gt;figure 1.3&lt;/uri&gt;</c>. Or, to refer to <uri link="#doc_chap2_pre2">code listing 2 in chapter 2</uri>,
355     type <c>&lt;uri link="doc_chap2_pre2"&gt;code listing 2.2&lt;/uri&gt;</c>. We'll be
356     adding other auto-link abilities (such as table support) soon.</p>
358     </body>
359     </section>
360     </chapter>
361     <chapter>
362     <title>Resources</title>
363     <section>
364     <title>Start writing</title>
365     <body>
366     <p>Guide has been specially designed to be "lean and mean" so that developers
367     can spend more time writing documentation and less time learning the actual XML
368     syntax. Hopefully, this will allow developers who aren't unusually "doc-savvy"
369     to start writing quality Gentoo Linux documentation. If you'd like to help (or have any questions about guide), please
370     post a message to <mail link="gentoo-dev@gentoo.org">the gentoo-dev mailing list</mail>
371 zhen 1.6 and <mail link="gentoo-doc@gentoo.org">the gentoo-doc mailing list</mail>
372 drobbins 1.1 stating what you'd like to tackle.
373     Have fun!</p>
374     </body>
375     </section>
376     </chapter>
377     </guide>

  ViewVC Help
Powered by ViewVC 1.1.20