PUBLISHING STYLESHEETS TUTORIAL
Publishing Style Sheets are the heart of CatBase. They tell the program:
-
What your Publishing Destination is (for example, are you going to publish using an Adobe InDesign layout? Or do you want to produce an XML file? Or a spreadsheet?)
-
What data to publish (e.g., which fields from a specified table)
-
Which Paragraph Style to apply to each paragraph
-
When to apply other formatting options
-
How to apply Rules to determine what to include our leave out, or how to style it
-
How to sort the records
-
Which images to include and how to size and place them
Anatomy of a Publishing Stylesheet
Paragraphs
Every publishing job can be broken down into paragraphs. There might be just one paragraph of information for each item (as in a simple telephone directory), or there might be a number of paragraphs (as in a catalogue). Each Publishing Style Sheet is constructed by adding Paragraphs in the order in which they will be published.
Each Paragraph contains one or more Elements.
Elements
Elements are the "building blocks" of Paragraphs.
An Element can contain:
-
Data from a field in the database
-
Static text (such as the word "Tel: " inserted before a telephone number)
-
A Rule. Set up "rules" that tell CatBase how to make intelligent decisions about what data to include (or leave out) and/or how to format it based on some criteria that you specify
-
Punctuation (such as a Tab character)
-
A Calculation - for example, to mark up or discount prices, or to sequentailly number items
-
A Picture
-
A Relation: include data from a related table (for example, all Contacts related to each Company, or all Parts belonging to each Product)
-
A Bar Code
You can add any number of Elements, in any order, to each Paragraph.
To illustrate the way Paragraphs and Elements are used, let's look at an entry from a basic telephone directory:
Joe Bloggs ..................123 1234
1234 Main St.
This entry consists of two Paragraphs.
The first paragraph consists of three database fields: the first name, last name, and telephone number. It also contains two additional elements: a space between the first and last names, and a Tab between the last name and phone number. So this paragraph contains five Elements:
-
Field: first name
-
Text: a space
-
Field: last name
-
Punctuation: a Tab
-
Field: telephone number.
The second paragraph contains just one Element: the address. Also, note that it's indented.
The formatting for each paragraph is determined by selecting a Paragraph Stylesheet. This determines all aspects of the formatting, such as the font, style, size, indents, tab settings, and so on.
Before proceeding with this Tutorial, you might like to review How CatBase and your Publishing Program Work Together.
CREATING A PUBLISHING STYLESHEET
You can have any number of Publishing Stylesheets. For example, you might want to create one to produce your catalogue, another to create a price list, another to create a cross-reference index for your catalog, and perhaps one to upload your data to your website's MySql or SqlServer database.
Which table to base it on?
The first thing you must decide is which table to build the Publishing Stylesheet on. It all depends on how your database tables are related together (if they are) and how you want the data to be sorted.
For example:
-
You have just one data table, containing business or individual contact details, and you want to produce a telephone directory. Your Publishing Stylesheet will be based on this table.
-
You have two related tables - for example, Products and Parts - and you want to produce a catalog sorted by Product Name, with each product's Parts listed. Your Publishing Stylesheet will be based on the Products table.
-
You have two related tables - Products and Parts - and you want to produce a list of Part Numbers and their prices, and perhaps their catalog page number. In this case your Publishing Stylesheet will be based on the Parts table.
-
You have two related tables - Products and Parts - and you want to produce a catalog sorted first by Category, then within each Category by Product Name, with each product's list of parts included. In this case you base your Publishing Stylesheet on the Products table, and select the option to organise them by Category.
Let's start by creating a simple "White Pages" telephone directory like the one shown above. We will use the Telephone Directory project from our Demo Database. This project has two tables: White Pages and Yellow Pages:
-
Select the Data Table that you are going to base your publishing Stylesheet on - in this case, White Pages.
-
Expand the Publishing Stylesheets topic on the left of the window.
-
Click New Publishing Stylesheet.
-
A new Publishing Stylesheet look like this:
-
Enter a name for this PSS into the Publishing Style Sheet Name area - eg "Telephone Directory".
-
Go to the Preferences tab:
-
Select the appropriate Default Publishing Destination for your purpose.
-
Select a Sort Order from the popup Sort Order menu, or click the New Sort Format button to create a new one.
-
Go back to the Paragraphs tab.
-
Right-click or ctrl-click on the empty Paragraphs area and choose Add a New Paragraph from the popup menu:
A new Paragraph is created:
-
Enter a name into the Paragraph Name area. This is just for your reference, so give it a descriptive name such as "name + phone number".
Style Sheet
The Style Sheet is essential, as this is what will determine how the contents of this Paragraph will be styled when the data is published.
-
Click on the Style Sheet popup menu and either choose an existing Stylesheet, or scroll down to the bottom and select Create a new Paragraph Stylesheet. In the Demo database, we'll select plain listing.
-
Save it.
You now have one Paragraph:
Now we need to choose exactly what's going in to that Paragraph We want it to look like this:
Fred Bloggs .......................123 456 7890
That's five Elements.
-
Right-click/Ctrl-click on the Paragraph and choose Add an Element:
This is how a new Element looks:
There are eight Element Types. See the Elements reference for information about the different types.
-
Leave Field selected for the Element Type.
-
Click on the popup list of fields and choose First Name.
-
Click the Save button..
Your Paragraph now looks like this:
-
Right-click on that Element and add another new Element.
-
This time, click on the Element Type popup menu and choose Text.
-
Click in the text area that appears and type a space character.
-
Save the Element.
-
Add another Element and select the Field: Last Name.
-
Add another Element and select the Element Type: Punctuation.
-
Select Tab from the Punctuation Type popup menu and save it.
-
Add another Element and select the field, Phone Number.
Now your Paragraph should look like this:
If you've got the Elements in the wrong order, you can drag and drop them within the list to re-order them.
We just need to add the second Paragraph:
-
Right-click in the empty area below the Paragraph you just created.
-
Add a new Paragraph, give it a name such as "Address line", select a Paragraph Stylesheet (for example "address line" in our Demo database), and save it.
-
Add an Element to this Paragraph and select the field, Address 1.
You should now have two Paragraphs:
That's it - you have created a Publishing Stylesheet!
LEARN MORE!
-
Find out about all the features and options in the Publishing Stylesheet Reference.
-
Find out about the various Element Types.
-
Automate your publishing projects.
-
Got a question? Contact us.