Наши партнеры








Книги по Linux (с отзывами читателей)

Библиотека сайта rus-linux.net

D.2. <section> and <sectN>: what's the difference?

NoteAcknowledgment
 

These notes were provided by: John Daily and Saqib Ali ().

<section> versus <sectN> is largely a question of flexibility. The stylesheets can make a <section> in a <section> look just like a <sect2> within a <sect1>, so there's no output advantage.

But, a <section> within a <section> can be extracted into its own top-level section, nested even more deeply, or moved to an entirely different part of the document, without it and its own <section> children being renamed. That is not true of the numbered section tags, which are very sensitive to rearrangements. This can be easier for authors who are new to DocBook than using <sectN>.

The main idea behind creating structured data is that it should be easy to access and query. One should be able to retrieve a subsection of any structured data, by using querying languages for XML (XPath and XQuery). <sectN> are useful when traversing a document using XPath/XQuery. <sectN> gives more flexibility, and control while writing an XPath expression.

A well-defined, valid and well-structured document makes it easier for one to write XPath/Query to retreive "specific" data from a document. For example you can use XPath to retrieve information in the <sect3> block with certain attributes. However if you just used <section> for all subsections, it becomes harder to retrieve the block of information that you need.

So which one should you use? The one you feel most comfortable with is a good place to start. This document is written with <section>s. You may, or may not, think this is a good idea. :)