- Prev
- Users' Guide
- Next

# Chapter 6. Using sets

A set is a collection of books, published as a single output. The Services Plan for example is a set comprised of many books such as the Developer Guide, Engineering Content Services Guide and the Engineering Operations Guide to name just a few. The `$` `create_book` command creates a template for a set by setting the `type` parameter to `Set`.
There are two types of set:

- stand-alone sets
- distributed sets

## 6.1. Stand-alone sets

A stand-alone set contains the XML files for each book, all of which are located inside the directory of the set. Stand-alone sets are always built as a set; you cannot build the individual books on their own without modification.
The procedure that follows will guide you through the process of creating a stand-alone set named My Set located in a directory called `books/My_Set/`. The set will contain Book A and Book B both of which will be manually created inside the `books/My_Set/en-US` directory.

Procedure 6.1. Creating a stand-alone set

1. Run the following command in a shell in the `books/` directory to create a set named `My_Set` branded in the Red Hat style and in which the XML will be written in American English.

       publican create --type=Set --name=My_Set --brand=RedHat --lang=en-US

2. `$` `cd` into the `My_Set/en-US` directory and create two directories (not books) called `Book_A` and `Book_B`.

       $ cd My_Set/en-US
       $ mkdir Book_A Book_B

3. `$` `cd` into the `books/My_Set/en-US/Book_A` directory. Create and edit the `Book_A.xml`, `Book_Info.xml`, and any other xml files required for your book such as those required for individual chapters. Ensure that `Book_A.xml` contains the correct `xi:include` references to all of your xml files in the directory. For example, if Book A contained `Book_Info.xml` and `Chapter_1.xml`, the `Book_A.xml` file would look like this:

       <?xml version='1.0'?>
       <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
       "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
       ]>

       <book>
       	  <xi:include href="Book_Info.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
       	  <xi:include href="Chapter_1.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
       </book>

4. Use the same process for Book_B, located in the `books/My_Set/en-US/Book_B` directory, as per the step above.
5. Open the `books/My_Set/en-US/My_Set.xml` file in an editor. For each book in the set, add an `xi:include` reference to the primary xml file from the book. The primary xml file for Book A will be `Book_A.xml` and for Book B, `Book_B.xml`. The `My_Set.xml` file should now look like this:

       <?xml version="1.0"?>
       <!DOCTYPE set PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
       "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
       ]>

       <set>
       	<xi:include href="Set_Info.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
       	<xi:include href="Preface.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
       	<xi:include href="Book_A/Book_A.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
       	<xi:include href="Book_B/Book_B.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
       	<xi:include href="Revision_History.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
       </set>

6. To make your set XML valid, you will need to change the following:
   1. In `My_Set.xml`, comment out the following lines:

          <remark>NOTE: the href does not contain a language! This is CORRECT!</remark>
          <remark><xi:include href="My_Other_Book/My_Other_Book.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></remark>
          <setindex></setindex>

   2. In the `Preface.xml` and `Book_Info.xml` for each book you are using, add ../../ to the front of every Common_Content string you see. For example:

          <xi:include href="Common_Content/Conventions.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />

      This will need to become:

          <xi:include href="../../Common_Content/Conventions.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />

      This is because in a standalone set, the Common Content folder is two directories further away from where Publican usually looks for it, so it has to be told manually. To build your book individually, without building the entire set, undo this step.
7. Test your set by running the `$` `publican build --formats=test --langs=en-US` command.

If you are using pre-existing books, you will need to rearrange them so the XML files are at the level of the set and all images are inside the images directory at the same level. For example:

       -- My_Set
        |-- en-US
        |   |-- Author_Group.xml
        |   |-- Book_A.ent
        |   |-- Book_A.xml
        |   |-- Book_B.ent
        |   |-- Book_B.xml
        |   |-- Book_Info_A.xml
        |   |-- Book_Info_B.xml
        |   |-- chapter_A.xml
        |   |-- chapter_B.xml
        |   |-- images
        |   |   |-- icon.svg
        |   |   `-- image1.png
        |   |-- My_Set.ent
        |   |-- My_Set.xml
        |   |-- Preface.xml
        |   |-- Revision_History.xml
        |   `-- Set_Info.xml
        `-- publican.cfg

The XML files can also be within sub-folders to keep them separate. This is true within the images directory, as well. For example:

       -- My_Set
        |-- en-US
        |   |-- Author_Group.xml
        |   |-- Book_A
        |   |   |-- Book_A.ent
        |   |   |-- Book_A.xml
        |   |   |-- Book_Info.xml
        |   |   `-- chapter.xml
        |   |-- Book_B
        |   |   |-- Book_B.ent
        |   |   |-- Book_B.xml
        |   |   |-- Book_Info.xml
        |   |   `-- chapter.xml
        |   |-- images
        |   |   |-- icon.svg
        |   |   `-- image1.png
        |   |-- My_Set.ent
        |   |-- My_Set.xml
        |   |-- Preface.xml
        |   |-- Revision_History.xml
        |   `-- Set_Info.xml
        `-- publican.cfg

## 6.2. Distributed sets

A distributed set contains books that are located in a version-controlled repository. Although several version control systems exist, this version of Publican supports only one: Subversion (SVN). By setting the repository location and titles of the included books in the `publican.cfg` file, each book can be exported to build the entire set. The procedure that follows will guide you through the process of creating a set named My Set containing Book A and Book B.

Important

The following procedure assumes that Book A and Book B already exist and are available in your SVN repository. Currently Publican only supports SVN.

Procedure 6.2. Creating a set

1. Run the following command in a shell to create a set named `My_Set` branded in the Red Hat style and in which the XML will be written in American English.

       $ publican create --type=Set --name=My_Set --brand=RedHat  --lang=en-US

2. Add the following lines to the `publican.cfg` file:

       books: Book_A Book_B
       repo: http://PATH-TO-YOUR-SVN-REPOSITORY
       scm: SVN

   Your repository path should end in the directory before the book you need.
3. Open the `My_Set.xml` file in an editor. For each book in the set, add an `xi:include` reference to the primary XML file from the book. The primary XML file for Book A will be `Book_A.xml` and for Book B, `Book_B.xml`. The `My_Set.xml` file should now look like this:

       <?xml version="1.0"?>
       <!DOCTYPE set PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
       "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
       ]>

       <set>
       	<xi:include href="Set_Info.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
       	<xi:include href="Preface.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
       	<xi:include href="Book_A/Book_A.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
       	<xi:include href="Book_B/Book_B.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
       	<xi:include href="Revision_History.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
       </set>

4. To make your set XML valid, you will need to comment out the following lines in `My_Set.xml`

       <remark>NOTE: the href does not contain a language! This is CORRECT!</remark>
       <remark><xi:include href="My_Other_Book/My_Other_Book.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></remark>
       <setindex></setindex>

5. Test your set by running the `$` `publican build --formats=test --langs=en-US` command.

   Important

   When building a set, the `$` `publican clean_ids` command will be run over each book because of the constraint that IDs must be unique across all books. Be careful of creating IDs that rely on content that may not be available when building books independently of the set.

- PrevChapter 5. Branding
- Up
- Home
- NextChapter 7. Building a website with Publican